diff options
| author | Yukihiro Matsumoto <[email protected]> | 2012-08-31 11:12:33 +0900 |
|---|---|---|
| committer | Yukihiro Matsumoto <[email protected]> | 2012-08-31 11:12:33 +0900 |
| commit | 3e924e887fb2e9e2123f8002879ef81e597d08b9 (patch) | |
| tree | d0d0484181099ce48fb46abb7c0070fbc7291657 | |
| parent | 2f21cea50a787f1d02f1390ad924e786cec357e7 (diff) | |
| download | mruby-3e924e887fb2e9e2123f8002879ef81e597d08b9.tar.gz mruby-3e924e887fb2e9e2123f8002879ef81e597d08b9.zip | |
save debugging lineno info in irep
| -rw-r--r-- | include/mruby/compile.h | 4 | ||||
| -rw-r--r-- | include/mruby/irep.h | 1 | ||||
| -rw-r--r-- | src/codegen.c | 15 |
3 files changed, 14 insertions, 6 deletions
diff --git a/include/mruby/compile.h b/include/mruby/compile.h index 4a27eaa6f..e035b9e02 100644 --- a/include/mruby/compile.h +++ b/include/mruby/compile.h @@ -20,7 +20,7 @@ typedef struct mrbc_context { mrb_sym *syms; int slen; char *filename; - int lineno; + short lineno; int capture_errors:1; int dump_result:1; int no_exec:1; @@ -33,7 +33,7 @@ const char *mrbc_filename(mrb_state *mrb, mrbc_context *c, const char *s); /* AST node structure */ typedef struct mrb_ast_node { struct mrb_ast_node *car, *cdr; - int lineno; + short lineno; } mrb_ast_node; /* lexer states */ diff --git a/include/mruby/irep.h b/include/mruby/irep.h index 720301648..9ff523d33 100644 --- a/include/mruby/irep.h +++ b/include/mruby/irep.h @@ -18,6 +18,7 @@ typedef struct mrb_irep { int nregs; mrb_code *iseq; + short *lines; mrb_value *pool; mrb_sym *syms; diff --git a/src/codegen.c b/src/codegen.c index 17608e10f..6197da33e 100644 --- a/src/codegen.c +++ b/src/codegen.c @@ -54,9 +54,10 @@ typedef struct scope { struct loopinfo *loop; int ensure_level; char *filename; - int lineno; + short lineno; mrb_code *iseq; + short *lines; int icapa; mrb_value *pool; @@ -144,8 +145,10 @@ genop(codegen_scope *s, mrb_code i) if (s->pc == s->icapa) { s->icapa *= 2; s->iseq = (mrb_code *)codegen_realloc(s, s->iseq, sizeof(mrb_code)*s->icapa); + s->lines = (short*)codegen_realloc(s, s->lines, sizeof(short)*s->icapa); } s->iseq[s->pc] = i; + s->lines[s->pc] = s->lineno; s->pc++; } @@ -2027,12 +2030,13 @@ scope_new(mrb_state *mrb, codegen_scope *prev, node *lv) p->mrb = prev->mrb; p->icapa = 1024; - p->iseq = (mrb_code *)mrb_malloc(mrb, sizeof(mrb_code)*p->icapa); + p->iseq = (mrb_code*)mrb_malloc(mrb, sizeof(mrb_code)*p->icapa); + p->lines = (short*)mrb_malloc(mrb, sizeof(short)*p->icapa); p->pcapa = 32; - p->pool = (mrb_value *)mrb_malloc(mrb, sizeof(mrb_value)*p->pcapa); + p->pool = (mrb_value*)mrb_malloc(mrb, sizeof(mrb_value)*p->pcapa); - p->syms = (mrb_sym *)mrb_malloc(mrb, sizeof(mrb_sym)*256); + p->syms = (mrb_sym*)mrb_malloc(mrb, sizeof(mrb_sym)*256); p->lv = lv; p->sp += node_len(lv)+2; @@ -2058,6 +2062,9 @@ scope_finish(codegen_scope *s, int idx) if (s->iseq) { irep->iseq = (mrb_code *)codegen_realloc(s, s->iseq, sizeof(mrb_code)*s->pc); irep->ilen = s->pc; + if (s->lines) { + irep->lines = (short *)codegen_realloc(s, s->lines, sizeof(short)*s->pc); + } } if (s->pool) { irep->pool = (mrb_value *)codegen_realloc(s, s->pool, sizeof(mrb_value)*s->plen); |
