summaryrefslogtreecommitdiffhomepage
path: root/src/codedump.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/codedump.c')
-rw-r--r--src/codedump.c284
1 files changed, 166 insertions, 118 deletions
diff --git a/src/codedump.c b/src/codedump.c
index 30a14f937..4d1d96171 100644
--- a/src/codedump.c
+++ b/src/codedump.c
@@ -4,25 +4,20 @@
#include <mruby/opcode.h>
#include <mruby/string.h>
#include <mruby/proc.h>
+#include <mruby/dump.h>
-#ifndef MRB_DISABLE_STDIO
+#ifndef MRB_NO_STDIO
static void
-print_r(mrb_state *mrb, mrb_irep *irep, size_t n)
+print_r(mrb_state *mrb, const mrb_irep *irep, size_t n)
{
- size_t i;
-
if (n == 0) return;
-
- for (i=0; i+1<irep->nlocals; i++) {
- if (irep->lv[i].r == n) {
- mrb_sym sym = irep->lv[i].name;
- printf(" R%d:%s", (int)n, mrb_sym2name(mrb, sym));
- }
- }
+ if (n >= irep->nlocals) return;
+ if (!irep->lv[n-1]) return;
+ printf(" R%d:%s", (int)n, mrb_sym_dump(mrb, irep->lv[n-1]));
}
static void
-print_lv_a(mrb_state *mrb, mrb_irep *irep, uint16_t a)
+print_lv_a(mrb_state *mrb, const mrb_irep *irep, uint16_t a)
{
if (!irep->lv || a >= irep->nlocals || a == 0) {
printf("\n");
@@ -34,7 +29,7 @@ print_lv_a(mrb_state *mrb, mrb_irep *irep, uint16_t a)
}
static void
-print_lv_ab(mrb_state *mrb, mrb_irep *irep, uint16_t a, uint16_t b)
+print_lv_ab(mrb_state *mrb, const mrb_irep *irep, uint16_t a, uint16_t b)
{
if (!irep->lv || (a >= irep->nlocals && b >= irep->nlocals) || a+b == 0) {
printf("\n");
@@ -47,11 +42,11 @@ print_lv_ab(mrb_state *mrb, mrb_irep *irep, uint16_t a, uint16_t b)
}
static void
-print_header(mrb_irep *irep, ptrdiff_t i)
+print_header(mrb_state *mrb, const mrb_irep *irep, uint32_t i)
{
int32_t line;
- line = mrb_debug_get_line(irep, i);
+ line = mrb_debug_get_line(mrb, irep, i);
if (line < 0) {
printf(" ");
}
@@ -65,24 +60,52 @@ print_header(mrb_irep *irep, ptrdiff_t i)
#define CASE(insn,ops) case insn: FETCH_ ## ops (); L_ ## insn
static void
-codedump(mrb_state *mrb, mrb_irep *irep)
+codedump(mrb_state *mrb, const mrb_irep *irep)
{
int ai;
- mrb_code *pc, *pcend;
+ const mrb_code *pc, *pcend;
mrb_code ins;
const char *file = NULL, *next_file;
if (!irep) return;
- printf("irep %p nregs=%d nlocals=%d pools=%d syms=%d reps=%d\n", (void*)irep,
- irep->nregs, irep->nlocals, (int)irep->plen, (int)irep->slen, (int)irep->rlen);
+ printf("irep %p nregs=%d nlocals=%d pools=%d syms=%d reps=%d iseq=%d\n", (void*)irep,
+ irep->nregs, irep->nlocals, (int)irep->plen, (int)irep->slen, (int)irep->rlen, (int)irep->ilen);
if (irep->lv) {
int i;
printf("local variable names:\n");
for (i = 1; i < irep->nlocals; ++i) {
- char const *n = mrb_sym2name(mrb, irep->lv[i - 1].name);
- printf(" R%d:%s\n", irep->lv[i - 1].r, n? n : "");
+ char const *s = mrb_sym_dump(mrb, irep->lv[i - 1]);
+ printf(" R%d:%s\n", i, s ? s : "");
+ }
+ }
+
+ if (irep->clen > 0) {
+ int i = irep->clen;
+ const struct mrb_irep_catch_handler *e = mrb_irep_catch_handler_table(irep);
+
+ for (; i > 0; i --, e ++) {
+ uint32_t begin = mrb_irep_catch_handler_unpack(e->begin);
+ uint32_t end = mrb_irep_catch_handler_unpack(e->end);
+ uint32_t target = mrb_irep_catch_handler_unpack(e->target);
+ char buf[20];
+ const char *type;
+
+ switch (e->type) {
+ case MRB_CATCH_RESCUE:
+ type = "rescue";
+ break;
+ case MRB_CATCH_ENSURE:
+ type = "ensure";
+ break;
+ default:
+ buf[0] = '\0';
+ snprintf(buf, sizeof(buf), "0x%02x <unknown>", (int)e->type);
+ type = buf;
+ break;
+ }
+ printf("catch type: %-8s begin: %04" PRIu32 " end: %04" PRIu32 " target: %04" PRIu32 "\n", type, begin, end, target);
}
}
@@ -92,17 +115,17 @@ codedump(mrb_state *mrb, mrb_irep *irep)
ptrdiff_t i;
uint32_t a;
uint16_t b;
- uint8_t c;
+ uint16_t c;
ai = mrb_gc_arena_save(mrb);
i = pc - irep->iseq;
- next_file = mrb_debug_get_filename(irep, i);
+ next_file = mrb_debug_get_filename(mrb, irep, (uint32_t)i);
if (next_file && file != next_file) {
printf("file: %s\n", next_file);
file = next_file;
}
- print_header(irep, i);
+ print_header(mrb, irep, (uint32_t)i);
ins = READ_B();
switch (ins) {
CASE(OP_NOP, Z):
@@ -112,11 +135,25 @@ codedump(mrb_state *mrb, mrb_irep *irep)
printf("OP_MOVE\tR%d\tR%d\t", a, b);
print_lv_ab(mrb, irep, a, b);
break;
+
CASE(OP_LOADL, BB):
- {
- mrb_value v = irep->pool[b];
- mrb_value s = mrb_inspect(mrb, v);
- printf("OP_LOADL\tR%d\tL(%d)\t; %s", a, b, RSTRING_PTR(s));
+ switch (irep->pool[b].tt) {
+#ifndef MRB_NO_FLOAT
+ case IREP_TT_FLOAT:
+ printf("OP_LOADL\tR%d\tL(%d)\t; %f", a, b, (double)irep->pool[b].u.f);
+ break;
+#endif
+ case IREP_TT_INT32:
+ printf("OP_LOADL\tR%d\tL(%d)\t; %" PRId32, a, b, irep->pool[b].u.i32);
+ break;
+#ifdef MRB_64BIT
+ case IREP_TT_INT64:
+ printf("OP_LOADL\tR%d\tL(%d)\t; %" PRId64, a, b, irep->pool[b].u.i64);
+ break;
+#endif
+ default:
+ printf("OP_LOADL\tR%d\tL(%d)\t", a, b);
+ break;
}
print_lv_a(mrb, irep, a);
break;
@@ -128,6 +165,14 @@ codedump(mrb_state *mrb, mrb_irep *irep)
printf("OP_LOADI\tR%d\t-%d\t", a, b);
print_lv_a(mrb, irep, a);
break;
+ CASE(OP_LOADI16, BS):
+ printf("OP_LOADI16\tR%d\t%d\t", a, (int)(int16_t)b);
+ print_lv_a(mrb, irep, a);
+ break;
+ CASE(OP_LOADI32, BSS):
+ printf("OP_LOADI32\tR%d\t%d\t", a, (int32_t)(((uint32_t)b<<16)+c));
+ print_lv_a(mrb, irep, a);
+ break;
CASE(OP_LOADI__1, B):
printf("OP_LOADI__1\tR%d\t\t", a);
print_lv_a(mrb, irep, a);
@@ -145,7 +190,7 @@ codedump(mrb_state *mrb, mrb_irep *irep)
print_lv_a(mrb, irep, a);
break;
CASE(OP_LOADSYM, BB):
- printf("OP_LOADSYM\tR%d\t:%s\t", a, mrb_sym2name(mrb, irep->syms[b]));
+ printf("OP_LOADSYM\tR%d\t:%s\t", a, mrb_sym_dump(mrb, irep->syms[b]));
print_lv_a(mrb, irep, a);
break;
CASE(OP_LOADNIL, B):
@@ -165,43 +210,43 @@ codedump(mrb_state *mrb, mrb_irep *irep)
print_lv_a(mrb, irep, a);
break;
CASE(OP_GETGV, BB):
- printf("OP_GETGV\tR%d\t:%s", a, mrb_sym2name(mrb, irep->syms[b]));
+ printf("OP_GETGV\tR%d\t:%s", a, mrb_sym_dump(mrb, irep->syms[b]));
print_lv_a(mrb, irep, a);
break;
CASE(OP_SETGV, BB):
- printf("OP_SETGV\t:%s\tR%d", mrb_sym2name(mrb, irep->syms[b]), a);
+ printf("OP_SETGV\t:%s\tR%d", mrb_sym_dump(mrb, irep->syms[b]), a);
print_lv_a(mrb, irep, a);
break;
CASE(OP_GETSV, BB):
- printf("OP_GETSV\tR%d\t:%s", a, mrb_sym2name(mrb, irep->syms[b]));
+ printf("OP_GETSV\tR%d\t:%s", a, mrb_sym_dump(mrb, irep->syms[b]));
print_lv_a(mrb, irep, a);
break;
CASE(OP_SETSV, BB):
- printf("OP_SETSV\t:%s\tR%d", mrb_sym2name(mrb, irep->syms[b]), a);
+ printf("OP_SETSV\t:%s\tR%d", mrb_sym_dump(mrb, irep->syms[b]), a);
print_lv_a(mrb, irep, a);
break;
CASE(OP_GETCONST, BB):
- printf("OP_GETCONST\tR%d\t:%s", a, mrb_sym2name(mrb, irep->syms[b]));
+ printf("OP_GETCONST\tR%d\t:%s", a, mrb_sym_dump(mrb, irep->syms[b]));
print_lv_a(mrb, irep, a);
break;
CASE(OP_SETCONST, BB):
- printf("OP_SETCONST\t:%s\tR%d", mrb_sym2name(mrb, irep->syms[b]), a);
+ printf("OP_SETCONST\t:%s\tR%d", mrb_sym_dump(mrb, irep->syms[b]), a);
print_lv_a(mrb, irep, a);
break;
CASE(OP_GETMCNST, BB):
- printf("OP_GETMCNST\tR%d\tR%d::%s", a, a, mrb_sym2name(mrb, irep->syms[b]));
+ printf("OP_GETMCNST\tR%d\tR%d::%s", a, a, mrb_sym_dump(mrb, irep->syms[b]));
print_lv_a(mrb, irep, a);
break;
CASE(OP_SETMCNST, BB):
- printf("OP_SETMCNST\tR%d::%s\tR%d", a+1, mrb_sym2name(mrb, irep->syms[b]), a);
+ printf("OP_SETMCNST\tR%d::%s\tR%d", a+1, mrb_sym_dump(mrb, irep->syms[b]), a);
print_lv_a(mrb, irep, a);
break;
CASE(OP_GETIV, BB):
- printf("OP_GETIV\tR%d\t%s", a, mrb_sym2name(mrb, irep->syms[b]));
+ printf("OP_GETIV\tR%d\t%s", a, mrb_sym_dump(mrb, irep->syms[b]));
print_lv_a(mrb, irep, a);
break;
CASE(OP_SETIV, BB):
- printf("OP_SETIV\t%s\tR%d", mrb_sym2name(mrb, irep->syms[b]), a);
+ printf("OP_SETIV\t%s\tR%d", mrb_sym_dump(mrb, irep->syms[b]), a);
print_lv_a(mrb, irep, a);
break;
CASE(OP_GETUPVAR, BBB):
@@ -213,39 +258,50 @@ codedump(mrb_state *mrb, mrb_irep *irep)
print_lv_a(mrb, irep, a);
break;
CASE(OP_GETCV, BB):
- printf("OP_GETCV\tR%d\t%s", a, mrb_sym2name(mrb, irep->syms[b]));
+ printf("OP_GETCV\tR%d\t%s", a, mrb_sym_dump(mrb, irep->syms[b]));
print_lv_a(mrb, irep, a);
break;
CASE(OP_SETCV, BB):
- printf("OP_SETCV\t%s\tR%d", mrb_sym2name(mrb, irep->syms[b]), a);
+ printf("OP_SETCV\t%s\tR%d", mrb_sym_dump(mrb, irep->syms[b]), a);
print_lv_a(mrb, irep, a);
break;
CASE(OP_JMP, S):
- printf("OP_JMP\t\t%03d\n", a);
+ i = pc - irep->iseq;
+ printf("OP_JMP\t\t%03d\n", (int)i+(int16_t)a);
+ break;
+ CASE(OP_JMPUW, S):
+ i = pc - irep->iseq;
+ printf("OP_JMPUW\t\t%03d\n", (int)i+(int16_t)a);
break;
CASE(OP_JMPIF, BS):
- printf("OP_JMPIF\tR%d\t%03d\t", a, b);
+ i = pc - irep->iseq;
+ printf("OP_JMPIF\tR%d\t%03d\t", a, (int)i+(int16_t)b);
print_lv_a(mrb, irep, a);
break;
CASE(OP_JMPNOT, BS):
- printf("OP_JMPNOT\tR%d\t%03d\t", a, b);
+ i = pc - irep->iseq;
+ printf("OP_JMPNOT\tR%d\t%03d\t", a, (int)i+(int16_t)b);
print_lv_a(mrb, irep, a);
break;
CASE(OP_JMPNIL, BS):
- printf("OP_JMPNIL\tR%d\t%03d\t", a, b);
+ i = pc - irep->iseq;
+ printf("OP_JMPNIL\tR%d\t%03d\t", a, (int)i+(int16_t)b);
print_lv_a(mrb, irep, a);
break;
CASE(OP_SENDV, BB):
- printf("OP_SENDV\tR%d\t:%s\n", a, mrb_sym2name(mrb, irep->syms[b]));
+ printf("OP_SENDV\tR%d\t:%s\n", a, mrb_sym_dump(mrb, irep->syms[b]));
break;
CASE(OP_SENDVB, BB):
- printf("OP_SENDVB\tR%d\t:%s\n", a, mrb_sym2name(mrb, irep->syms[b]));
+ printf("OP_SENDVB\tR%d\t:%s\n", a, mrb_sym_dump(mrb, irep->syms[b]));
break;
CASE(OP_SEND, BBB):
- printf("OP_SEND\tR%d\t:%s\t%d\n", a, mrb_sym2name(mrb, irep->syms[b]), c);
+ printf("OP_SEND\tR%d\t:%s\t%d\n", a, mrb_sym_dump(mrb, irep->syms[b]), c);
break;
CASE(OP_SENDB, BBB):
- printf("OP_SENDB\tR%d\t:%s\t%d\n", a, mrb_sym2name(mrb, irep->syms[b]), c);
+ printf("OP_SENDB\tR%d\t:%s\t%d\n", a, mrb_sym_dump(mrb, irep->syms[b]), c);
+ break;
+ CASE(OP_SENDVK, BB):
+ printf("OP_SENDVK\tR%d\t:%s\n", a, mrb_sym_dump(mrb, irep->syms[b]));
break;
CASE(OP_CALL, Z):
printf("OP_CALL\n");
@@ -264,23 +320,23 @@ codedump(mrb_state *mrb, mrb_irep *irep)
break;
CASE(OP_ENTER, W):
printf("OP_ENTER\t%d:%d:%d:%d:%d:%d:%d\n",
- (a>>18)&0x1f,
- (a>>13)&0x1f,
- (a>>12)&0x1,
- (a>>7)&0x1f,
- (a>>2)&0x1f,
- (a>>1)&0x1,
- a & 0x1);
+ MRB_ASPEC_REQ(a),
+ MRB_ASPEC_OPT(a),
+ MRB_ASPEC_REST(a),
+ MRB_ASPEC_POST(a),
+ MRB_ASPEC_KEY(a),
+ MRB_ASPEC_KDICT(a),
+ MRB_ASPEC_BLOCK(a));
break;
CASE(OP_KEY_P, BB):
- printf("OP_KEY_P\tR%d\t:%s\t", a, mrb_sym2name(mrb, irep->syms[b]));
+ printf("OP_KEY_P\tR%d\t:%s\t", a, mrb_sym_dump(mrb, irep->syms[b]));
print_lv_a(mrb, irep, a);
break;
CASE(OP_KEYEND, Z):
printf("OP_KEYEND\n");
break;
CASE(OP_KARG, BB):
- printf("OP_KARG\tR%d\t:%s\t", a, mrb_sym2name(mrb, irep->syms[b]));
+ printf("OP_KARG\tR%d\t:%s\t", a, mrb_sym_dump(mrb, irep->syms[b]));
print_lv_a(mrb, irep, a);
break;
CASE(OP_RETURN, B):
@@ -305,13 +361,13 @@ codedump(mrb_state *mrb, mrb_irep *irep)
print_lv_a(mrb, irep, a);
break;
CASE(OP_LAMBDA, BB):
- printf("OP_LAMBDA\tR%d\tI(%d:%p)\n", a, b, irep->reps[b]);
+ printf("OP_LAMBDA\tR%d\tI(%d:%p)\n", a, b, (void*)irep->reps[b]);
break;
CASE(OP_BLOCK, BB):
- printf("OP_BLOCK\tR%d\tI(%d:%p)\n", a, b, irep->reps[b]);
+ printf("OP_BLOCK\tR%d\tI(%d:%p)\n", a, b, (void*)irep->reps[b]);
break;
CASE(OP_METHOD, BB):
- printf("OP_METHOD\tR%d\tI(%d:%p)\n", a, b, irep->reps[b]);
+ printf("OP_METHOD\tR%d\tI(%d:%p)\n", a, b, (void*)irep->reps[b]);
break;
CASE(OP_RANGE_INC, B):
printf("OP_RANGE_INC\tR%d\n", a);
@@ -320,46 +376,46 @@ codedump(mrb_state *mrb, mrb_irep *irep)
printf("OP_RANGE_EXC\tR%d\n", a);
break;
CASE(OP_DEF, BB):
- printf("OP_DEF\tR%d\t:%s\n", a, mrb_sym2name(mrb, irep->syms[b]));
+ printf("OP_DEF\tR%d\t:%s\n", a, mrb_sym_dump(mrb, irep->syms[b]));
break;
CASE(OP_UNDEF, B):
- printf("OP_UNDEF\t:%s\n", mrb_sym2name(mrb, irep->syms[a]));
+ printf("OP_UNDEF\t:%s\n", mrb_sym_dump(mrb, irep->syms[a]));
break;
CASE(OP_ALIAS, BB):
- printf("OP_ALIAS\t:%s\t%s\n", mrb_sym2name(mrb, irep->syms[a]), mrb_sym2name(mrb, irep->syms[b]));
+ printf("OP_ALIAS\t:%s\t%s\n", mrb_sym_dump(mrb, irep->syms[a]), mrb_sym_dump(mrb, irep->syms[b]));
break;
- CASE(OP_ADD, BB):
- printf("OP_ADD\tR%d\t:%s\t\n", a, mrb_sym2name(mrb, irep->syms[b]));
+ CASE(OP_ADD, B):
+ printf("OP_ADD\tR%d\tR%d\n", a, a+1);
break;
- CASE(OP_ADDI, BBB):
- printf("OP_ADDI\tR%d\t:%s\t%d\n", a, mrb_sym2name(mrb, irep->syms[b]), c);
+ CASE(OP_ADDI, BB):
+ printf("OP_ADDI\tR%d\t%d\n", a, b);
break;
- CASE(OP_SUB, BB):
- printf("OP_SUB\tR%d\t:%s\t\n", a, mrb_sym2name(mrb, irep->syms[b]));
+ CASE(OP_SUB, B):
+ printf("OP_SUB\tR%d\tR%d\n", a, a+1);
break;
- CASE(OP_SUBI, BBB):
- printf("OP_SUBI\tR%d\t:%s\t%d\n", a, mrb_sym2name(mrb, irep->syms[b]), c);
+ CASE(OP_SUBI, BB):
+ printf("OP_SUBI\tR%d\t%d\n", a, b);
break;
- CASE(OP_MUL, BB):
- printf("OP_MUL\tR%d\t:%s\t\n", a, mrb_sym2name(mrb, irep->syms[b]));
+ CASE(OP_MUL, B):
+ printf("OP_MUL\tR%d\tR%d\n", a, a+1);
break;
- CASE(OP_DIV, BB):
- printf("OP_DIV\tR%d\t:%s\t\n", a, mrb_sym2name(mrb, irep->syms[b]));
+ CASE(OP_DIV, B):
+ printf("OP_DIV\tR%d\tR%d\n", a, a+1);
break;
- CASE(OP_LT, BB):
- printf("OP_LT\t\tR%d\t:%s\t\n", a, mrb_sym2name(mrb, irep->syms[b]));
+ CASE(OP_LT, B):
+ printf("OP_LT\t\tR%d\tR%d\n", a, a+1);
break;
- CASE(OP_LE, BB):
- printf("OP_LE\t\tR%d\t:%s\t\n", a, mrb_sym2name(mrb, irep->syms[b]));
+ CASE(OP_LE, B):
+ printf("OP_LE\t\tR%d\tR%d\n", a, a+1);
break;
- CASE(OP_GT, BB):
- printf("OP_GT\t\tR%d\t:%s\t\n", a, mrb_sym2name(mrb, irep->syms[b]));
+ CASE(OP_GT, B):
+ printf("OP_GT\t\tR%d\tR%d\n", a, a+1);
break;
- CASE(OP_GE, BB):
- printf("OP_GE\t\tR%d\t:%s\t\n", a, mrb_sym2name(mrb, irep->syms[b]));
+ CASE(OP_GE, B):
+ printf("OP_GE\t\tR%d\tR%d\n", a, a+1);
break;
- CASE(OP_EQ, BB):
- printf("OP_EQ\t\tR%d\t:%s\t\n", a, mrb_sym2name(mrb, irep->syms[b]));
+ CASE(OP_EQ, B):
+ printf("OP_EQ\t\tR%d\tR%d\n", a, a+1);
break;
CASE(OP_ARRAY, BB):
printf("OP_ARRAY\tR%d\t%d\t", a, b);
@@ -398,10 +454,11 @@ codedump(mrb_state *mrb, mrb_irep *irep)
print_lv_a(mrb, irep, a);
break;
CASE(OP_STRING, BB):
- {
- mrb_value v = irep->pool[b];
- mrb_value s = mrb_str_dump(mrb, mrb_str_new(mrb, RSTRING_PTR(v), RSTRING_LEN(v)));
- printf("OP_STRING\tR%d\tL(%d)\t; %s", a, b, RSTRING_PTR(s));
+ if ((irep->pool[b].tt & IREP_TT_NFLAG) == 0) {
+ printf("OP_STRING\tR%d\tL(%d)\t; %s", a, b, irep->pool[b].u.str);
+ }
+ else {
+ printf("OP_STRING\tR%d\tL(%d)\t", a, b);
}
print_lv_a(mrb, irep, a);
break;
@@ -427,15 +484,15 @@ codedump(mrb_state *mrb, mrb_irep *irep)
print_lv_a(mrb, irep, a);
break;
CASE(OP_CLASS, BB):
- printf("OP_CLASS\tR%d\t:%s", a, mrb_sym2name(mrb, irep->syms[b]));
+ printf("OP_CLASS\tR%d\t:%s", a, mrb_sym_dump(mrb, irep->syms[b]));
print_lv_a(mrb, irep, a);
break;
CASE(OP_MODULE, BB):
- printf("OP_MODULE\tR%d\t:%s", a, mrb_sym2name(mrb, irep->syms[b]));
+ printf("OP_MODULE\tR%d\t:%s", a, mrb_sym_dump(mrb, irep->syms[b]));
print_lv_a(mrb, irep, a);
break;
CASE(OP_EXEC, BB):
- printf("OP_EXEC\tR%d\tI(%d:%p)", a, b, irep->reps[b]);
+ printf("OP_EXEC\tR%d\tI(%d:%p)", a, b, (void*)irep->reps[b]);
print_lv_a(mrb, irep, a);
break;
CASE(OP_SCLASS, B):
@@ -447,17 +504,12 @@ codedump(mrb_state *mrb, mrb_irep *irep)
print_lv_a(mrb, irep, a);
break;
CASE(OP_ERR, B):
- {
- mrb_value v = irep->pool[a];
- mrb_value s = mrb_str_dump(mrb, mrb_str_new(mrb, RSTRING_PTR(v), RSTRING_LEN(v)));
- printf("OP_ERR\t%s\n", RSTRING_PTR(s));
+ if ((irep->pool[a].tt & IREP_TT_NFLAG) == 0) {
+ printf("OP_ERR\t%s\n", irep->pool[a].u.str);
+ }
+ else {
+ printf("OP_ERR\tL(%d)\n", a);
}
- break;
- CASE(OP_EPUSH, B):
- printf("OP_EPUSH\t\t:I(%d:%p)\n", a, irep->reps[a]);
- break;
- CASE(OP_ONERR, S):
- printf("OP_ONERR\t%03d\n", a);
break;
CASE(OP_EXCEPT, B):
printf("OP_EXCEPT\tR%d\t\t", a);
@@ -467,16 +519,10 @@ codedump(mrb_state *mrb, mrb_irep *irep)
printf("OP_RESCUE\tR%d\tR%d", a, b);
print_lv_ab(mrb, irep, a, b);
break;
- CASE(OP_RAISE, B):
- printf("OP_RAISE\tR%d\t\t", a);
+ CASE(OP_RAISEIF, B):
+ printf("OP_RAISEIF\tR%d\t\t", a);
print_lv_a(mrb, irep, a);
break;
- CASE(OP_POPERR, B):
- printf("OP_POPERR\t%d\t\t\n", a);
- break;
- CASE(OP_EPOP, B):
- printf("OP_EPOP\t%d\n", a);
- break;
CASE(OP_DEBUG, BBB):
printf("OP_DEBUG\t%d\t%d\t%d\n", a, b, c);
@@ -489,7 +535,7 @@ codedump(mrb_state *mrb, mrb_irep *irep)
CASE(OP_EXT1, Z):
ins = READ_B();
printf("OP_EXT1\n");
- print_header(irep, pc-irep->iseq-2);
+ print_header(mrb, irep, pc-irep->iseq-2);
switch (ins) {
#define OPCODE(i,x) case OP_ ## i: FETCH_ ## x ## _1 (); goto L_OP_ ## i;
#include "mruby/ops.h"
@@ -499,7 +545,7 @@ codedump(mrb_state *mrb, mrb_irep *irep)
CASE(OP_EXT2, Z):
ins = READ_B();
printf("OP_EXT2\n");
- print_header(irep, pc-irep->iseq-2);
+ print_header(mrb, irep, pc-irep->iseq-2);
switch (ins) {
#define OPCODE(i,x) case OP_ ## i: FETCH_ ## x ## _2 (); goto L_OP_ ## i;
#include "mruby/ops.h"
@@ -509,7 +555,7 @@ codedump(mrb_state *mrb, mrb_irep *irep)
CASE(OP_EXT3, Z):
ins = READ_B();
printf("OP_EXT3\n");
- print_header(irep, pc-irep->iseq-2);
+ print_header(mrb, irep, pc-irep->iseq-2);
switch (ins) {
#define OPCODE(i,x) case OP_ ## i: FETCH_ ## x ## _3 (); goto L_OP_ ## i;
#include "mruby/ops.h"
@@ -527,13 +573,15 @@ codedump(mrb_state *mrb, mrb_irep *irep)
}
static void
-codedump_recur(mrb_state *mrb, mrb_irep *irep)
+codedump_recur(mrb_state *mrb, const mrb_irep *irep)
{
int i;
codedump(mrb, irep);
- for (i=0; i<irep->rlen; i++) {
- codedump_recur(mrb, irep->reps[i]);
+ if (irep->reps) {
+ for (i=0; i<irep->rlen; i++) {
+ codedump_recur(mrb, irep->reps[i]);
+ }
}
}
#endif
@@ -541,7 +589,7 @@ codedump_recur(mrb_state *mrb, mrb_irep *irep)
void
mrb_codedump_all(mrb_state *mrb, struct RProc *proc)
{
-#ifndef MRB_DISABLE_STDIO
+#ifndef MRB_NO_STDIO
codedump_recur(mrb, proc->body.irep);
#endif
}