diff options
Diffstat (limited to 'lcode.c')
-rw-r--r-- | lcode.c | 23 |
1 files changed, 16 insertions, 7 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lcode.c,v 1.41 2000/06/30 14:35:17 roberto Exp roberto $ | 2 | ** $Id: lcode.c,v 1.42 2000/08/04 19:38:35 roberto Exp roberto $ |
3 | ** Code generator for Lua | 3 | ** Code generator for Lua |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -413,6 +413,19 @@ void luaK_posfix (LexState *ls, int op, expdesc *v1, expdesc *v2) { | |||
413 | } | 413 | } |
414 | 414 | ||
415 | 415 | ||
416 | static void codelineinfo (FuncState *fs) { | ||
417 | LexState *ls = fs->ls; | ||
418 | if (ls->lastline > fs->lastline) { | ||
419 | luaM_growvector(fs->L, fs->f->lineinfo, fs->nlineinfo, 2, int, | ||
420 | "line info overflow", MAX_INT); | ||
421 | if (ls->lastline > fs->lastline+1) | ||
422 | fs->f->lineinfo[fs->nlineinfo++] = -(ls->lastline - (fs->lastline+1)); | ||
423 | fs->f->lineinfo[fs->nlineinfo++] = fs->pc; | ||
424 | fs->lastline = ls->lastline; | ||
425 | } | ||
426 | } | ||
427 | |||
428 | |||
416 | int luaK_code0 (FuncState *fs, OpCode o) { | 429 | int luaK_code0 (FuncState *fs, OpCode o) { |
417 | return luaK_code2(fs, o, 0, 0); | 430 | return luaK_code2(fs, o, 0, 0); |
418 | } | 431 | } |
@@ -618,12 +631,8 @@ int luaK_code2 (FuncState *fs, OpCode o, int arg1, int arg2) { | |||
618 | case iS: i = CREATE_S(o, arg1); break; | 631 | case iS: i = CREATE_S(o, arg1); break; |
619 | case iAB: i = CREATE_AB(o, arg1, arg2); break; | 632 | case iAB: i = CREATE_AB(o, arg1, arg2); break; |
620 | } | 633 | } |
621 | if (fs->debug) { | 634 | if (fs->debug) |
622 | LexState *ls = fs->ls; | 635 | codelineinfo(fs); |
623 | luaM_growvector(fs->L, fs->f->lines, fs->pc, 1, int, | ||
624 | "code size overflow", MAX_INT); | ||
625 | fs->f->lines[fs->pc] = ls->lastline; | ||
626 | } | ||
627 | /* put new instruction in code array */ | 636 | /* put new instruction in code array */ |
628 | luaM_growvector(fs->L, fs->f->code, fs->pc, 1, Instruction, | 637 | luaM_growvector(fs->L, fs->f->code, fs->pc, 1, Instruction, |
629 | "code size overflow", MAX_INT); | 638 | "code size overflow", MAX_INT); |