1 | #include "mruby.h"
|
---|
2 | #include "mruby/irep.h"
|
---|
3 | #include "mruby/debug.h"
|
---|
4 | #include "mruby/opcode.h"
|
---|
5 | #include "mruby/string.h"
|
---|
6 | #include "mruby/proc.h"
|
---|
7 |
|
---|
8 | #ifndef MRB_DISABLE_STDIO
|
---|
9 | static int
|
---|
10 | print_r(mrb_state *mrb, mrb_irep *irep, size_t n, int pre)
|
---|
11 | {
|
---|
12 | size_t i;
|
---|
13 |
|
---|
14 | if (n == 0) return 0;
|
---|
15 |
|
---|
16 | for (i=0; i+1<irep->nlocals; i++) {
|
---|
17 | if (irep->lv[i].r == n) {
|
---|
18 | mrb_sym sym = irep->lv[i].name;
|
---|
19 | if (pre) printf(" ");
|
---|
20 | printf("R%d:%s", (int)n, mrb_sym2name(mrb, sym));
|
---|
21 | return 1;
|
---|
22 | }
|
---|
23 | }
|
---|
24 | return 0;
|
---|
25 | }
|
---|
26 |
|
---|
27 | #define RA 1
|
---|
28 | #define RB 2
|
---|
29 | #define RAB 3
|
---|
30 |
|
---|
31 | static void
|
---|
32 | print_lv(mrb_state *mrb, mrb_irep *irep, mrb_code c, int r)
|
---|
33 | {
|
---|
34 | int pre = 0;
|
---|
35 |
|
---|
36 | if (!irep->lv
|
---|
37 | || ((!(r & RA) || GETARG_A(c) >= irep->nlocals)
|
---|
38 | && (!(r & RB) || GETARG_B(c) >= irep->nlocals))) {
|
---|
39 | printf("\n");
|
---|
40 | return;
|
---|
41 | }
|
---|
42 | printf("\t; ");
|
---|
43 | if (r & RA) {
|
---|
44 | pre = print_r(mrb, irep, GETARG_A(c), 0);
|
---|
45 | }
|
---|
46 | if (r & RB) {
|
---|
47 | print_r(mrb, irep, GETARG_B(c), pre);
|
---|
48 | }
|
---|
49 | printf("\n");
|
---|
50 | }
|
---|
51 | #endif
|
---|
52 |
|
---|
53 | static void
|
---|
54 | codedump(mrb_state *mrb, mrb_irep *irep)
|
---|
55 | {
|
---|
56 | #ifndef MRB_DISABLE_STDIO
|
---|
57 | int i;
|
---|
58 | int ai;
|
---|
59 | mrb_code c;
|
---|
60 | const char *file = NULL, *next_file;
|
---|
61 | int32_t line;
|
---|
62 |
|
---|
63 | if (!irep) return;
|
---|
64 | printf("irep %p nregs=%d nlocals=%d pools=%d syms=%d reps=%d\n", (void*)irep,
|
---|
65 | irep->nregs, irep->nlocals, (int)irep->plen, (int)irep->slen, (int)irep->rlen);
|
---|
66 |
|
---|
67 | for (i = 0; i < (int)irep->ilen; i++) {
|
---|
68 | ai = mrb_gc_arena_save(mrb);
|
---|
69 |
|
---|
70 | next_file = mrb_debug_get_filename(irep, i);
|
---|
71 | if (next_file && file != next_file) {
|
---|
72 | printf("file: %s\n", next_file);
|
---|
73 | file = next_file;
|
---|
74 | }
|
---|
75 | line = mrb_debug_get_line(irep, i);
|
---|
76 | if (line < 0) {
|
---|
77 | printf(" ");
|
---|
78 | }
|
---|
79 | else {
|
---|
80 | printf("%5d ", line);
|
---|
81 | }
|
---|
82 |
|
---|
83 | printf("%03d ", i);
|
---|
84 | c = irep->iseq[i];
|
---|
85 | switch (GET_OPCODE(c)) {
|
---|
86 | case OP_NOP:
|
---|
87 | printf("OP_NOP\n");
|
---|
88 | break;
|
---|
89 | case OP_MOVE:
|
---|
90 | printf("OP_MOVE\tR%d\tR%d\t", GETARG_A(c), GETARG_B(c));
|
---|
91 | print_lv(mrb, irep, c, RAB);
|
---|
92 | break;
|
---|
93 | case OP_LOADL:
|
---|
94 | {
|
---|
95 | mrb_value v = irep->pool[GETARG_Bx(c)];
|
---|
96 | mrb_value s = mrb_inspect(mrb, v);
|
---|
97 | printf("OP_LOADL\tR%d\tL(%d)\t; %s", GETARG_A(c), GETARG_Bx(c), RSTRING_PTR(s));
|
---|
98 | }
|
---|
99 | print_lv(mrb, irep, c, RA);
|
---|
100 | break;
|
---|
101 | case OP_LOADI:
|
---|
102 | printf("OP_LOADI\tR%d\t%d\t", GETARG_A(c), GETARG_sBx(c));
|
---|
103 | print_lv(mrb, irep, c, RA);
|
---|
104 | break;
|
---|
105 | case OP_LOADSYM:
|
---|
106 | printf("OP_LOADSYM\tR%d\t:%s", GETARG_A(c),
|
---|
107 | mrb_sym2name(mrb, irep->syms[GETARG_Bx(c)]));
|
---|
108 | print_lv(mrb, irep, c, RA);
|
---|
109 | break;
|
---|
110 | case OP_LOADNIL:
|
---|
111 | printf("OP_LOADNIL\tR%d\t\t", GETARG_A(c));
|
---|
112 | print_lv(mrb, irep, c, RA);
|
---|
113 | break;
|
---|
114 | case OP_LOADSELF:
|
---|
115 | printf("OP_LOADSELF\tR%d\t\t", GETARG_A(c));
|
---|
116 | print_lv(mrb, irep, c, RA);
|
---|
117 | break;
|
---|
118 | case OP_LOADT:
|
---|
119 | printf("OP_LOADT\tR%d\t\t", GETARG_A(c));
|
---|
120 | print_lv(mrb, irep, c, RA);
|
---|
121 | break;
|
---|
122 | case OP_LOADF:
|
---|
123 | printf("OP_LOADF\tR%d\t\t", GETARG_A(c));
|
---|
124 | print_lv(mrb, irep, c, RA);
|
---|
125 | break;
|
---|
126 | case OP_GETGLOBAL:
|
---|
127 | printf("OP_GETGLOBAL\tR%d\t:%s", GETARG_A(c),
|
---|
128 | mrb_sym2name(mrb, irep->syms[GETARG_Bx(c)]));
|
---|
129 | print_lv(mrb, irep, c, RA);
|
---|
130 | break;
|
---|
131 | case OP_SETGLOBAL:
|
---|
132 | printf("OP_SETGLOBAL\t:%s\tR%d\t",
|
---|
133 | mrb_sym2name(mrb, irep->syms[GETARG_Bx(c)]),
|
---|
134 | GETARG_A(c));
|
---|
135 | print_lv(mrb, irep, c, RA);
|
---|
136 | break;
|
---|
137 | case OP_GETCONST:
|
---|
138 | printf("OP_GETCONST\tR%d\t:%s", GETARG_A(c),
|
---|
139 | mrb_sym2name(mrb, irep->syms[GETARG_Bx(c)]));
|
---|
140 | print_lv(mrb, irep, c, RA);
|
---|
141 | break;
|
---|
142 | case OP_SETCONST:
|
---|
143 | printf("OP_SETCONST\t:%s\tR%d\t",
|
---|
144 | mrb_sym2name(mrb, irep->syms[GETARG_Bx(c)]),
|
---|
145 | GETARG_A(c));
|
---|
146 | print_lv(mrb, irep, c, RA);
|
---|
147 | break;
|
---|
148 | case OP_GETMCNST:
|
---|
149 | printf("OP_GETMCNST\tR%d\tR%d::%s", GETARG_A(c), GETARG_A(c),
|
---|
150 | mrb_sym2name(mrb, irep->syms[GETARG_Bx(c)]));
|
---|
151 | print_lv(mrb, irep, c, RAB);
|
---|
152 | break;
|
---|
153 | case OP_SETMCNST:
|
---|
154 | printf("OP_SETMCNST\tR%d::%s\tR%d", GETARG_A(c)+1,
|
---|
155 | mrb_sym2name(mrb, irep->syms[GETARG_Bx(c)]),
|
---|
156 | GETARG_A(c));
|
---|
157 | print_lv(mrb, irep, c, RA);
|
---|
158 | break;
|
---|
159 | case OP_GETIV:
|
---|
160 | printf("OP_GETIV\tR%d\t%s", GETARG_A(c),
|
---|
161 | mrb_sym2name(mrb, irep->syms[GETARG_Bx(c)]));
|
---|
162 | print_lv(mrb, irep, c, RA);
|
---|
163 | break;
|
---|
164 | case OP_SETIV:
|
---|
165 | printf("OP_SETIV\t%s\tR%d",
|
---|
166 | mrb_sym2name(mrb, irep->syms[GETARG_Bx(c)]),
|
---|
167 | GETARG_A(c));
|
---|
168 | print_lv(mrb, irep, c, RA);
|
---|
169 | break;
|
---|
170 | case OP_GETUPVAR:
|
---|
171 | printf("OP_GETUPVAR\tR%d\t%d\t%d",
|
---|
172 | GETARG_A(c), GETARG_B(c), GETARG_C(c));
|
---|
173 | print_lv(mrb, irep, c, RA);
|
---|
174 | break;
|
---|
175 | case OP_SETUPVAR:
|
---|
176 | printf("OP_SETUPVAR\tR%d\t%d\t%d",
|
---|
177 | GETARG_A(c), GETARG_B(c), GETARG_C(c));
|
---|
178 | print_lv(mrb, irep, c, RA);
|
---|
179 | break;
|
---|
180 | case OP_GETCV:
|
---|
181 | printf("OP_GETCV\tR%d\t%s", GETARG_A(c),
|
---|
182 | mrb_sym2name(mrb, irep->syms[GETARG_Bx(c)]));
|
---|
183 | print_lv(mrb, irep, c, RA);
|
---|
184 | break;
|
---|
185 | case OP_SETCV:
|
---|
186 | printf("OP_SETCV\t%s\tR%d",
|
---|
187 | mrb_sym2name(mrb, irep->syms[GETARG_Bx(c)]),
|
---|
188 | GETARG_A(c));
|
---|
189 | print_lv(mrb, irep, c, RA);
|
---|
190 | break;
|
---|
191 | case OP_JMP:
|
---|
192 | printf("OP_JMP\t%03d\n", i+GETARG_sBx(c));
|
---|
193 | break;
|
---|
194 | case OP_JMPIF:
|
---|
195 | printf("OP_JMPIF\tR%d\t%03d\n", GETARG_A(c), i+GETARG_sBx(c));
|
---|
196 | break;
|
---|
197 | case OP_JMPNOT:
|
---|
198 | printf("OP_JMPNOT\tR%d\t%03d\n", GETARG_A(c), i+GETARG_sBx(c));
|
---|
199 | break;
|
---|
200 | case OP_SEND:
|
---|
201 | printf("OP_SEND\tR%d\t:%s\t%d\n", GETARG_A(c),
|
---|
202 | mrb_sym2name(mrb, irep->syms[GETARG_B(c)]),
|
---|
203 | GETARG_C(c));
|
---|
204 | break;
|
---|
205 | case OP_SENDB:
|
---|
206 | printf("OP_SENDB\tR%d\t:%s\t%d\n", GETARG_A(c),
|
---|
207 | mrb_sym2name(mrb, irep->syms[GETARG_B(c)]),
|
---|
208 | GETARG_C(c));
|
---|
209 | break;
|
---|
210 | case OP_TAILCALL:
|
---|
211 | printf("OP_TAILCALL\tR%d\t:%s\t%d\n", GETARG_A(c),
|
---|
212 | mrb_sym2name(mrb, irep->syms[GETARG_B(c)]),
|
---|
213 | GETARG_C(c));
|
---|
214 | break;
|
---|
215 | case OP_SUPER:
|
---|
216 | printf("OP_SUPER\tR%d\t%d\n", GETARG_A(c),
|
---|
217 | GETARG_C(c));
|
---|
218 | break;
|
---|
219 | case OP_ARGARY:
|
---|
220 | printf("OP_ARGARY\tR%d\t%d:%d:%d:%d", GETARG_A(c),
|
---|
221 | (GETARG_Bx(c)>>10)&0x3f,
|
---|
222 | (GETARG_Bx(c)>>9)&0x1,
|
---|
223 | (GETARG_Bx(c)>>4)&0x1f,
|
---|
224 | (GETARG_Bx(c)>>0)&0xf);
|
---|
225 | print_lv(mrb, irep, c, RA);
|
---|
226 | break;
|
---|
227 |
|
---|
228 | case OP_ENTER:
|
---|
229 | printf("OP_ENTER\t%d:%d:%d:%d:%d:%d:%d\n",
|
---|
230 | (GETARG_Ax(c)>>18)&0x1f,
|
---|
231 | (GETARG_Ax(c)>>13)&0x1f,
|
---|
232 | (GETARG_Ax(c)>>12)&0x1,
|
---|
233 | (GETARG_Ax(c)>>7)&0x1f,
|
---|
234 | (GETARG_Ax(c)>>2)&0x1f,
|
---|
235 | (GETARG_Ax(c)>>1)&0x1,
|
---|
236 | GETARG_Ax(c) & 0x1);
|
---|
237 | break;
|
---|
238 | case OP_RETURN:
|
---|
239 | printf("OP_RETURN\tR%d", GETARG_A(c));
|
---|
240 | switch (GETARG_B(c)) {
|
---|
241 | case OP_R_NORMAL:
|
---|
242 | case OP_R_RETURN:
|
---|
243 | printf("\treturn\t"); break;
|
---|
244 | case OP_R_BREAK:
|
---|
245 | printf("\tbreak\t"); break;
|
---|
246 | default:
|
---|
247 | printf("\tbroken\t"); break;
|
---|
248 | break;
|
---|
249 | }
|
---|
250 | print_lv(mrb, irep, c, RA);
|
---|
251 | break;
|
---|
252 | case OP_BLKPUSH:
|
---|
253 | printf("OP_BLKPUSH\tR%d\t%d:%d:%d:%d", GETARG_A(c),
|
---|
254 | (GETARG_Bx(c)>>10)&0x3f,
|
---|
255 | (GETARG_Bx(c)>>9)&0x1,
|
---|
256 | (GETARG_Bx(c)>>4)&0x1f,
|
---|
257 | (GETARG_Bx(c)>>0)&0xf);
|
---|
258 | print_lv(mrb, irep, c, RA);
|
---|
259 | break;
|
---|
260 |
|
---|
261 | case OP_LAMBDA:
|
---|
262 | printf("OP_LAMBDA\tR%d\tI(%+d)\t%d", GETARG_A(c), GETARG_b(c)+1, GETARG_c(c));
|
---|
263 | print_lv(mrb, irep, c, RA);
|
---|
264 | break;
|
---|
265 | case OP_RANGE:
|
---|
266 | printf("OP_RANGE\tR%d\tR%d\t%d", GETARG_A(c), GETARG_B(c), GETARG_C(c));
|
---|
267 | print_lv(mrb, irep, c, RAB);
|
---|
268 | break;
|
---|
269 | case OP_METHOD:
|
---|
270 | printf("OP_METHOD\tR%d\t:%s", GETARG_A(c),
|
---|
271 | mrb_sym2name(mrb, irep->syms[GETARG_B(c)]));
|
---|
272 | print_lv(mrb, irep, c, RA);
|
---|
273 | break;
|
---|
274 |
|
---|
275 | case OP_ADD:
|
---|
276 | printf("OP_ADD\tR%d\t:%s\t%d\n", GETARG_A(c),
|
---|
277 | mrb_sym2name(mrb, irep->syms[GETARG_B(c)]),
|
---|
278 | GETARG_C(c));
|
---|
279 | break;
|
---|
280 | case OP_ADDI:
|
---|
281 | printf("OP_ADDI\tR%d\t:%s\t%d\n", GETARG_A(c),
|
---|
282 | mrb_sym2name(mrb, irep->syms[GETARG_B(c)]),
|
---|
283 | GETARG_C(c));
|
---|
284 | break;
|
---|
285 | case OP_SUB:
|
---|
286 | printf("OP_SUB\tR%d\t:%s\t%d\n", GETARG_A(c),
|
---|
287 | mrb_sym2name(mrb, irep->syms[GETARG_B(c)]),
|
---|
288 | GETARG_C(c));
|
---|
289 | break;
|
---|
290 | case OP_SUBI:
|
---|
291 | printf("OP_SUBI\tR%d\t:%s\t%d\n", GETARG_A(c),
|
---|
292 | mrb_sym2name(mrb, irep->syms[GETARG_B(c)]),
|
---|
293 | GETARG_C(c));
|
---|
294 | break;
|
---|
295 | case OP_MUL:
|
---|
296 | printf("OP_MUL\tR%d\t:%s\t%d\n", GETARG_A(c),
|
---|
297 | mrb_sym2name(mrb, irep->syms[GETARG_B(c)]),
|
---|
298 | GETARG_C(c));
|
---|
299 | break;
|
---|
300 | case OP_DIV:
|
---|
301 | printf("OP_DIV\tR%d\t:%s\t%d\n", GETARG_A(c),
|
---|
302 | mrb_sym2name(mrb, irep->syms[GETARG_B(c)]),
|
---|
303 | GETARG_C(c));
|
---|
304 | break;
|
---|
305 | case OP_LT:
|
---|
306 | printf("OP_LT\tR%d\t:%s\t%d\n", GETARG_A(c),
|
---|
307 | mrb_sym2name(mrb, irep->syms[GETARG_B(c)]),
|
---|
308 | GETARG_C(c));
|
---|
309 | break;
|
---|
310 | case OP_LE:
|
---|
311 | printf("OP_LE\tR%d\t:%s\t%d\n", GETARG_A(c),
|
---|
312 | mrb_sym2name(mrb, irep->syms[GETARG_B(c)]),
|
---|
313 | GETARG_C(c));
|
---|
314 | break;
|
---|
315 | case OP_GT:
|
---|
316 | printf("OP_GT\tR%d\t:%s\t%d\n", GETARG_A(c),
|
---|
317 | mrb_sym2name(mrb, irep->syms[GETARG_B(c)]),
|
---|
318 | GETARG_C(c));
|
---|
319 | break;
|
---|
320 | case OP_GE:
|
---|
321 | printf("OP_GE\tR%d\t:%s\t%d\n", GETARG_A(c),
|
---|
322 | mrb_sym2name(mrb, irep->syms[GETARG_B(c)]),
|
---|
323 | GETARG_C(c));
|
---|
324 | break;
|
---|
325 | case OP_EQ:
|
---|
326 | printf("OP_EQ\tR%d\t:%s\t%d\n", GETARG_A(c),
|
---|
327 | mrb_sym2name(mrb, irep->syms[GETARG_B(c)]),
|
---|
328 | GETARG_C(c));
|
---|
329 | break;
|
---|
330 |
|
---|
331 | case OP_STOP:
|
---|
332 | printf("OP_STOP\n");
|
---|
333 | break;
|
---|
334 |
|
---|
335 | case OP_ARRAY:
|
---|
336 | printf("OP_ARRAY\tR%d\tR%d\t%d", GETARG_A(c), GETARG_B(c), GETARG_C(c));
|
---|
337 | print_lv(mrb, irep, c, RAB);
|
---|
338 | break;
|
---|
339 | case OP_ARYCAT:
|
---|
340 | printf("OP_ARYCAT\tR%d\tR%d\t", GETARG_A(c), GETARG_B(c));
|
---|
341 | print_lv(mrb, irep, c, RAB);
|
---|
342 | break;
|
---|
343 | case OP_ARYPUSH:
|
---|
344 | printf("OP_ARYPUSH\tR%d\tR%d\t", GETARG_A(c), GETARG_B(c));
|
---|
345 | print_lv(mrb, irep, c, RAB);
|
---|
346 | break;
|
---|
347 | case OP_AREF:
|
---|
348 | printf("OP_AREF\tR%d\tR%d\t%d", GETARG_A(c), GETARG_B(c), GETARG_C(c));
|
---|
349 | print_lv(mrb, irep, c, RAB);
|
---|
350 | break;
|
---|
351 | case OP_APOST:
|
---|
352 | printf("OP_APOST\tR%d\t%d\t%d", GETARG_A(c), GETARG_B(c), GETARG_C(c));
|
---|
353 | print_lv(mrb, irep, c, RA);
|
---|
354 | break;
|
---|
355 | case OP_STRING:
|
---|
356 | {
|
---|
357 | mrb_value v = irep->pool[GETARG_Bx(c)];
|
---|
358 | mrb_value s = mrb_str_dump(mrb, mrb_str_new(mrb, RSTRING_PTR(v), RSTRING_LEN(v)));
|
---|
359 | printf("OP_STRING\tR%d\tL(%d)\t; %s", GETARG_A(c), GETARG_Bx(c), RSTRING_PTR(s));
|
---|
360 | }
|
---|
361 | print_lv(mrb, irep, c, RA);
|
---|
362 | break;
|
---|
363 | case OP_STRCAT:
|
---|
364 | printf("OP_STRCAT\tR%d\tR%d\t", GETARG_A(c), GETARG_B(c));
|
---|
365 | print_lv(mrb, irep, c, RAB);
|
---|
366 | break;
|
---|
367 | case OP_HASH:
|
---|
368 | printf("OP_HASH\tR%d\tR%d\t%d", GETARG_A(c), GETARG_B(c), GETARG_C(c));
|
---|
369 | print_lv(mrb, irep, c, RAB);
|
---|
370 | break;
|
---|
371 |
|
---|
372 | case OP_OCLASS:
|
---|
373 | printf("OP_OCLASS\tR%d\t\t", GETARG_A(c));
|
---|
374 | print_lv(mrb, irep, c, RA);
|
---|
375 | break;
|
---|
376 | case OP_CLASS:
|
---|
377 | printf("OP_CLASS\tR%d\t:%s", GETARG_A(c),
|
---|
378 | mrb_sym2name(mrb, irep->syms[GETARG_B(c)]));
|
---|
379 | print_lv(mrb, irep, c, RA);
|
---|
380 | break;
|
---|
381 | case OP_MODULE:
|
---|
382 | printf("OP_MODULE\tR%d\t:%s", GETARG_A(c),
|
---|
383 | mrb_sym2name(mrb, irep->syms[GETARG_B(c)]));
|
---|
384 | print_lv(mrb, irep, c, RA);
|
---|
385 | break;
|
---|
386 | case OP_EXEC:
|
---|
387 | printf("OP_EXEC\tR%d\tI(%+d)", GETARG_A(c), GETARG_Bx(c)+1);
|
---|
388 | print_lv(mrb, irep, c, RA);
|
---|
389 | break;
|
---|
390 | case OP_SCLASS:
|
---|
391 | printf("OP_SCLASS\tR%d\tR%d\t", GETARG_A(c), GETARG_B(c));
|
---|
392 | print_lv(mrb, irep, c, RAB);
|
---|
393 | break;
|
---|
394 | case OP_TCLASS:
|
---|
395 | printf("OP_TCLASS\tR%d\t\t", GETARG_A(c));
|
---|
396 | print_lv(mrb, irep, c, RA);
|
---|
397 | break;
|
---|
398 | case OP_ERR:
|
---|
399 | {
|
---|
400 | mrb_value v = irep->pool[GETARG_Bx(c)];
|
---|
401 | mrb_value s = mrb_str_dump(mrb, mrb_str_new(mrb, RSTRING_PTR(v), RSTRING_LEN(v)));
|
---|
402 | printf("OP_ERR\t%s\n", RSTRING_PTR(s));
|
---|
403 | }
|
---|
404 | break;
|
---|
405 | case OP_EPUSH:
|
---|
406 | printf("OP_EPUSH\t:I(%+d)\n", GETARG_Bx(c)+1);
|
---|
407 | break;
|
---|
408 | case OP_ONERR:
|
---|
409 | printf("OP_ONERR\t%03d\n", i+GETARG_sBx(c));
|
---|
410 | break;
|
---|
411 | case OP_RESCUE:
|
---|
412 | printf("OP_RESCUE\tR%d\t\t", GETARG_A(c));
|
---|
413 | print_lv(mrb, irep, c, RA);
|
---|
414 | break;
|
---|
415 | case OP_RAISE:
|
---|
416 | printf("OP_RAISE\tR%d\t\t", GETARG_A(c));
|
---|
417 | print_lv(mrb, irep, c, RA);
|
---|
418 | break;
|
---|
419 | case OP_POPERR:
|
---|
420 | printf("OP_POPERR\t%d\t\t", GETARG_A(c));
|
---|
421 | print_lv(mrb, irep, c, RA);
|
---|
422 | break;
|
---|
423 | case OP_EPOP:
|
---|
424 | printf("OP_EPOP\t%d\n", GETARG_A(c));
|
---|
425 | break;
|
---|
426 |
|
---|
427 | default:
|
---|
428 | printf("OP_unknown %d\t%d\t%d\t%d\n", GET_OPCODE(c),
|
---|
429 | GETARG_A(c), GETARG_B(c), GETARG_C(c));
|
---|
430 | break;
|
---|
431 | }
|
---|
432 | mrb_gc_arena_restore(mrb, ai);
|
---|
433 | }
|
---|
434 | printf("\n");
|
---|
435 | #endif
|
---|
436 | }
|
---|
437 |
|
---|
438 | static void
|
---|
439 | codedump_recur(mrb_state *mrb, mrb_irep *irep)
|
---|
440 | {
|
---|
441 | size_t i;
|
---|
442 |
|
---|
443 | codedump(mrb, irep);
|
---|
444 | for (i=0; i<irep->rlen; i++) {
|
---|
445 | codedump_recur(mrb, irep->reps[i]);
|
---|
446 | }
|
---|
447 | }
|
---|
448 |
|
---|
449 | void
|
---|
450 | mrb_codedump_all(mrb_state *mrb, struct RProc *proc)
|
---|
451 | {
|
---|
452 | codedump_recur(mrb, proc->body.irep);
|
---|
453 | }
|
---|