diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2000-06-21 15:13:56 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2000-06-21 15:13:56 -0300 |
| commit | b69e712713785394ceefa11ab3e5f9636abea733 (patch) | |
| tree | 0fa1b8b00ffbb5cfe0113d290b48b4fc528d2695 /lcode.c | |
| parent | f51775950737eb4d097cda0bba143973b5385947 (diff) | |
| download | lua-b69e712713785394ceefa11ab3e5f9636abea733.tar.gz lua-b69e712713785394ceefa11ab3e5f9636abea733.tar.bz2 lua-b69e712713785394ceefa11ab3e5f9636abea733.zip | |
new way to generate SETLINEs
Diffstat (limited to 'lcode.c')
| -rw-r--r-- | lcode.c | 19 |
1 files changed, 13 insertions, 6 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lcode.c,v 1.36 2000/06/16 17:51:40 roberto Exp roberto $ | 2 | ** $Id: lcode.c,v 1.37 2000/06/21 17:05:49 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 | */ |
| @@ -307,9 +307,8 @@ static void luaK_goiffalse (FuncState *fs, expdesc *v, int keepvalue) { | |||
| 307 | 307 | ||
| 308 | 308 | ||
| 309 | static int code_label (FuncState *fs, OpCode op, int arg) { | 309 | static int code_label (FuncState *fs, OpCode op, int arg) { |
| 310 | int j = luaK_getlabel(fs); | 310 | luaK_getlabel(fs); /* those instructions may be jump targets */ |
| 311 | luaK_code1(fs, op, arg); | 311 | return luaK_code1(fs, op, arg); |
| 312 | return j; | ||
| 313 | } | 312 | } |
| 314 | 313 | ||
| 315 | 314 | ||
| @@ -624,9 +623,17 @@ int luaK_code2 (FuncState *fs, OpCode o, int arg1, int arg2) { | |||
| 624 | case iS: i = CREATE_S(o, arg1); break; | 623 | case iS: i = CREATE_S(o, arg1); break; |
| 625 | case iAB: i = CREATE_AB(o, arg1, arg2); break; | 624 | case iAB: i = CREATE_AB(o, arg1, arg2); break; |
| 626 | } | 625 | } |
| 627 | /* put new instruction in code array */ | 626 | /* check space for new instruction plus eventual SETLINE */ |
| 628 | luaM_growvector(fs->L, fs->f->code, fs->pc, 1, Instruction, | 627 | luaM_growvector(fs->L, fs->f->code, fs->pc, 2, Instruction, |
| 629 | "code size overflow", MAX_INT); | 628 | "code size overflow", MAX_INT); |
| 629 | /* check the need for SETLINE */ | ||
| 630 | if (fs->debug && fs->ls->lastline != fs->lastsetline) { | ||
| 631 | LexState *ls = fs->ls; | ||
| 632 | luaX_checklimit(ls, ls->lastline, MAXARG_U, "lines in a chunk"); | ||
| 633 | fs->f->code[fs->pc++] = CREATE_U(OP_SETLINE, ls->lastline); | ||
| 634 | fs->lastsetline = ls->lastline; | ||
| 635 | } | ||
| 636 | /* put new instruction in code array */ | ||
| 630 | fs->f->code[fs->pc] = i; | 637 | fs->f->code[fs->pc] = i; |
| 631 | return fs->pc++; | 638 | return fs->pc++; |
| 632 | } | 639 | } |
