protoverse

A metaverse protocol
git clone git://jb55.com/protoverse
Log | Files | Refs | README | LICENSE

commit 6196956d8d92147bed38e49d0fd6300c6c306ac7
parent 7c94b80a9e626948bf1ebe2af7eefea9bfeee898
Author: William Casarin <jb55@jb55.com>
Date:   Sun, 18 Jul 2021 20:20:23 -0700

resolving label debug

Signed-off-by: William Casarin <jb55@jb55.com>

Diffstat:
Msrc/wasm.c | 18+++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/src/wasm.c b/src/wasm.c @@ -1605,17 +1605,18 @@ static int parse_instrs_until(struct expr_parser *p, u8 stop_instr, if (!pull_byte(p->code, &tag)) return note_error(p->errs, p->code, "oob"); - if (!parse_instr(p, tag, &op)) { - return note_error(p->errs, p->code, - "parse %s instr (0x%x)", instr_name(tag), tag); - } - if (tag == stop_instr || (stop_instr == i_if && (tag == i_else || tag == i_end))) { //debug("parse_instrs_until ending\n"); *instr_len = p->code->p - *parsed_instrs; return 1; } + + if (!parse_instr(p, tag, &op)) { + return note_error(p->errs, p->code, + "parse %s instr (0x%x)", instr_name(tag), tag); + } + } } @@ -2796,6 +2797,10 @@ static INLINE int resolve_label(struct label *label, struct cursor *code) label->jump = code->p - code->start; label->instr_pos |= 0x80000000; + debug("resolving label %04x to %04x\n", + label_instr_pos(label), + label->jump); + return 1; } @@ -3072,9 +3077,8 @@ static int parse_br_table(struct cursor *code, struct errors *errs, static int parse_instr(struct expr_parser *p, u8 tag, struct instr *op) { - /*debug("%04lX parsing instr %s (0x%02x)\n", + debug("%04lX parsing instr %s (0x%02x)\n", p->code->p - 1 - p->code->start, instr_name(tag), tag); - */ op->pos = p->code->p - 1 - p->code->start; op->tag = tag;