summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2014-04-28 08:02:47 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2014-04-28 08:02:47 +0900
commitb53e69f18d3d7471f8afc3d839ed5f6012b30f79 (patch)
treeea3c029c568a18000b2af9a5202876bae61a1fdd
parent3244ddf0c396cc1878579d12eb69e2fdc3c4ffa2 (diff)
downloadmruby-b53e69f18d3d7471f8afc3d839ed5f6012b30f79.tar.gz
mruby-b53e69f18d3d7471f8afc3d839ed5f6012b30f79.zip
better codedump formatting
-rw-r--r--src/codegen.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/codegen.c b/src/codegen.c
index 81369c822..9bf7e0328 100644
--- a/src/codegen.c
+++ b/src/codegen.c
@@ -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;
}
@@ -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:
@@ -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));