Skip to content

Commit b53e69f

Browse files
committed
better codedump formatting
1 parent 3244ddf commit b53e69f

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

src/codegen.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2664,7 +2664,9 @@ print_lv(mrb_state *mrb, mrb_irep *irep, mrb_code c, int r)
26642664
{
26652665
int pre = 0;
26662666

2667-
if (!irep->lv) {
2667+
if (!irep->lv
2668+
|| ((!(r & RA) || GETARG_A(c) >= irep->nlocals)
2669+
&& (!(r & RB) || GETARG_B(c) >= irep->nlocals))) {
26682670
printf("\n");
26692671
return;
26702672
}
@@ -2703,7 +2705,11 @@ codedump(mrb_state *mrb, mrb_irep *irep)
27032705
print_lv(mrb, irep, c, RAB);
27042706
break;
27052707
case OP_LOADL:
2706-
printf("OP_LOADL\tR%d\tL(%d)", GETARG_A(c), GETARG_Bx(c));
2708+
{
2709+
mrb_value v = irep->pool[GETARG_Bx(c)];
2710+
mrb_value s = mrb_inspect(mrb, v);
2711+
printf("OP_LOADL\tR%d\tL(%d)\t; %s", GETARG_A(c), GETARG_Bx(c), RSTRING_PTR(s));
2712+
}
27072713
print_lv(mrb, irep, c, RA);
27082714
break;
27092715
case OP_LOADI:
@@ -2964,8 +2970,9 @@ codedump(mrb_state *mrb, mrb_irep *irep)
29642970
{
29652971
mrb_value v = irep->pool[GETARG_Bx(c)];
29662972
mrb_value s = mrb_str_dump(mrb, mrb_str_new(mrb, RSTRING_PTR(v), RSTRING_LEN(v)));
2967-
printf("OP_STRING\tR%d\t%s\n", GETARG_A(c), RSTRING_PTR(s));
2973+
printf("OP_STRING\tR%d\tL(%d)\t; %s", GETARG_A(c), GETARG_B(c), RSTRING_PTR(s));
29682974
}
2975+
print_lv(mrb, irep, c, RA);
29692976
break;
29702977
case OP_STRCAT:
29712978
printf("OP_STRCAT\tR%d\tR%d", GETARG_A(c), GETARG_B(c));

0 commit comments

Comments
 (0)