Skip to content

Commit

Permalink
better codedump formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
matz committed Apr 27, 2014
1 parent 3244ddf commit b53e69f
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/codegen.c
Expand Up @@ -2664,7 +2664,9 @@ print_lv(mrb_state *mrb, mrb_irep *irep, mrb_code c, int r)
{
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");
return;
}
Expand Down Expand Up @@ -2703,7 +2705,11 @@ codedump(mrb_state *mrb, mrb_irep *irep)
print_lv(mrb, irep, c, RAB);
break;
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);
break;
case OP_LOADI:
Expand Down Expand Up @@ -2964,8 +2970,9 @@ codedump(mrb_state *mrb, mrb_irep *irep)
{
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)));
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;
case OP_STRCAT:
printf("OP_STRCAT\tR%d\tR%d", GETARG_A(c), GETARG_B(c));
Expand Down

0 comments on commit b53e69f

Please sign in to comment.