diff options
| -rw-r--r-- | lcode.c | 21 |
1 files changed, 12 insertions, 9 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lcode.c,v 2.15 2005/08/17 18:32:09 roberto Exp $ | 2 | ** $Id: lcode.c,v 2.16 2005/08/29 20:49:21 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 | */ |
| @@ -29,14 +29,17 @@ | |||
| 29 | 29 | ||
| 30 | void luaK_nil (FuncState *fs, int from, int n) { | 30 | void luaK_nil (FuncState *fs, int from, int n) { |
| 31 | Instruction *previous; | 31 | Instruction *previous; |
| 32 | if (fs->pc > fs->lasttarget && /* no jumps to current position? */ | 32 | if (fs->pc > fs->lasttarget) { /* no jumps to current position? */ |
| 33 | GET_OPCODE(*(previous = &fs->f->code[fs->pc-1])) == OP_LOADNIL) { | 33 | if (fs->pc == 0) /* function start? */ |
| 34 | int pfrom = GETARG_A(*previous); | 34 | return; /* positions are already clean */ |
| 35 | int pto = GETARG_B(*previous); | 35 | if (GET_OPCODE(*(previous = &fs->f->code[fs->pc-1])) == OP_LOADNIL) { |
| 36 | if (pfrom <= from && from <= pto+1) { /* can connect both? */ | 36 | int pfrom = GETARG_A(*previous); |
| 37 | if (from+n-1 > pto) | 37 | int pto = GETARG_B(*previous); |
| 38 | SETARG_B(*previous, from+n-1); | 38 | if (pfrom <= from && from <= pto+1) { /* can connect both? */ |
| 39 | return; | 39 | if (from+n-1 > pto) |
| 40 | SETARG_B(*previous, from+n-1); | ||
| 41 | return; | ||
| 42 | } | ||
| 40 | } | 43 | } |
| 41 | } | 44 | } |
| 42 | luaK_codeABC(fs, OP_LOADNIL, from, from+n-1, 0); /* else no optimization */ | 45 | luaK_codeABC(fs, OP_LOADNIL, from, from+n-1, 0); /* else no optimization */ |
