Skip to content

Commit b5d4181

Browse files
authored
Fix bytecode stack frame printing (#686)
Handle OP_get_loc0_loc1 specially. Fixes an off-by-one when printing variable names. Fixes: #683
1 parent 6d7448e commit b5d4181

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

quickjs.c

+11-2
Original file line numberDiff line numberDiff line change
@@ -28783,8 +28783,17 @@ static void dump_byte_code(JSContext *ctx, int pass,
2878328783
printf(",%u", get_u16(tab + pos + 8));
2878428784
break;
2878528785
case OP_FMT_none_loc:
28786-
idx = (op - OP_get_loc0_loc1) % 4;
28787-
goto has_loc;
28786+
if (op == OP_get_loc0_loc1) {
28787+
printf(" 0, 1 ; ");
28788+
if (var_count > 0)
28789+
print_atom(ctx, vars[0].var_name);
28790+
if (var_count > 1)
28791+
print_atom(ctx, vars[1].var_name);
28792+
} else {
28793+
idx = (op - OP_get_loc0) % 4;
28794+
goto has_loc;
28795+
}
28796+
break;
2878828797
case OP_FMT_loc8:
2878928798
idx = get_u8(tab + pos);
2879028799
goto has_loc;

0 commit comments

Comments
 (0)