diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2018-11-15 23:29:55 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2018-11-15 23:34:32 +0900 |
| commit | 418ad65db40200058a023b57682f4a3853fd63bc (patch) | |
| tree | e8752f370c6022b80eae635bb8bca7274cd42582 /mrbgems/mruby-compiler/core | |
| parent | 7e3e8d8ed5d9d12e7d3b0d616bf9b770f07e0d4f (diff) | |
| download | mruby-418ad65db40200058a023b57682f4a3853fd63bc.tar.gz mruby-418ad65db40200058a023b57682f4a3853fd63bc.zip | |
Fixed a bug in continuous read of target files; ref #4138
Line number information in a compiled file was wrong.
Diffstat (limited to 'mrbgems/mruby-compiler/core')
| -rw-r--r-- | mrbgems/mruby-compiler/core/codegen.c | 5 | ||||
| -rw-r--r-- | mrbgems/mruby-compiler/core/parse.y | 4 |
2 files changed, 8 insertions, 1 deletions
diff --git a/mrbgems/mruby-compiler/core/codegen.c b/mrbgems/mruby-compiler/core/codegen.c index dbd3b8ecf..ba7d8cf63 100644 --- a/mrbgems/mruby-compiler/core/codegen.c +++ b/mrbgems/mruby-compiler/core/codegen.c @@ -156,7 +156,10 @@ emit_B(codegen_scope *s, uint32_t pc, uint8_t i) } } if (s->lines) { - s->lines[pc] = s->lineno; + if (s->lineno > 0 || pc == 0) + s->lines[pc] = s->lineno; + else + s->lines[pc] = s->lines[pc-1]; } s->iseq[pc] = i; } diff --git a/mrbgems/mruby-compiler/core/parse.y b/mrbgems/mruby-compiler/core/parse.y index 1c06be839..ac8724377 100644 --- a/mrbgems/mruby-compiler/core/parse.y +++ b/mrbgems/mruby-compiler/core/parse.y @@ -133,6 +133,10 @@ cons_gen(parser_state *p, node *car, node *cdr) c->cdr = cdr; c->lineno = p->lineno; c->filename_index = p->current_filename_index; + /* beginning of next partial file; need to point the previous file */ + if (p->lineno == 0 && p->current_filename_index > 0) { + c->filename_index-- ; + } return c; } #define cons(a,b) cons_gen(p,(a),(b)) |
