better codedump formatting

parent 3244ddf0
...@@ -2664,7 +2664,9 @@ print_lv(mrb_state *mrb, mrb_irep *irep, mrb_code c, int r) ...@@ -2664,7 +2664,9 @@ print_lv(mrb_state *mrb, mrb_irep *irep, mrb_code c, int r)
{ {
int pre = 0; int pre = 0;
if (!irep->lv) { if (!irep->lv
|| ((!(r & RA) || GETARG_A(c) >= irep->nlocals)
&& (!(r & RB) || GETARG_B(c) >= irep->nlocals))) {
printf("\n"); printf("\n");
return; return;
} }
...@@ -2703,7 +2705,11 @@ codedump(mrb_state *mrb, mrb_irep *irep) ...@@ -2703,7 +2705,11 @@ codedump(mrb_state *mrb, mrb_irep *irep)
print_lv(mrb, irep, c, RAB); print_lv(mrb, irep, c, RAB);
break; break;
case OP_LOADL: case OP_LOADL:
printf("OP_LOADL\tR%d\tL(%d)", GETARG_A(c), GETARG_Bx(c)); {
mrb_value v = irep->pool[GETARG_Bx(c)];
mrb_value s = mrb_inspect(mrb, v);
printf("OP_LOADL\tR%d\tL(%d)\t; %s", GETARG_A(c), GETARG_Bx(c), RSTRING_PTR(s));
}
print_lv(mrb, irep, c, RA); print_lv(mrb, irep, c, RA);
break; break;
case OP_LOADI: case OP_LOADI:
...@@ -2964,8 +2970,9 @@ codedump(mrb_state *mrb, mrb_irep *irep) ...@@ -2964,8 +2970,9 @@ codedump(mrb_state *mrb, mrb_irep *irep)
{ {
mrb_value v = irep->pool[GETARG_Bx(c)]; mrb_value v = irep->pool[GETARG_Bx(c)];
mrb_value s = mrb_str_dump(mrb, mrb_str_new(mrb, RSTRING_PTR(v), RSTRING_LEN(v))); mrb_value s = mrb_str_dump(mrb, mrb_str_new(mrb, RSTRING_PTR(v), RSTRING_LEN(v)));
printf("OP_STRING\tR%d\t%s\n", GETARG_A(c), RSTRING_PTR(s)); printf("OP_STRING\tR%d\tL(%d)\t; %s", GETARG_A(c), GETARG_B(c), RSTRING_PTR(s));
} }
print_lv(mrb, irep, c, RA);
break; break;
case OP_STRCAT: case OP_STRCAT:
printf("OP_STRCAT\tR%d\tR%d", GETARG_A(c), GETARG_B(c)); printf("OP_STRCAT\tR%d\tR%d", GETARG_A(c), GETARG_B(c));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment