diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2001-01-29 13:26:40 -0200 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2001-01-29 13:26:40 -0200 |
| commit | 3b6f8bfbe688fdd0f1c17bd023140804155624f3 (patch) | |
| tree | 9cb2bedcaded8e46e9cd471f7247ddce2916d633 /lcode.c | |
| parent | caf01b5bfa33617b7bb2c40292f74599f6030eba (diff) | |
| download | lua-3b6f8bfbe688fdd0f1c17bd023140804155624f3.tar.gz lua-3b6f8bfbe688fdd0f1c17bd023140804155624f3.tar.bz2 lua-3b6f8bfbe688fdd0f1c17bd023140804155624f3.zip | |
simpler implementation of for loops
Diffstat (limited to 'lcode.c')
| -rw-r--r-- | lcode.c | 13 |
1 files changed, 12 insertions, 1 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lcode.c,v 1.57 2001/01/19 13:20:30 roberto Exp roberto $ | 2 | ** $Id: lcode.c,v 1.58 2001/01/29 13:14: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 | */ |
| @@ -59,6 +59,17 @@ static void luaK_fixjump (FuncState *fs, int pc, int dest) { | |||
| 59 | } | 59 | } |
| 60 | 60 | ||
| 61 | 61 | ||
| 62 | /* | ||
| 63 | ** prep-for instructions (OP_FORPREP & OP_LFORPREP) have a negated jump, | ||
| 64 | ** as they simulate the real jump... | ||
| 65 | */ | ||
| 66 | void luaK_fixfor (FuncState *fs, int pc, int dest) { | ||
| 67 | Instruction *jmp = &fs->f->code[pc]; | ||
| 68 | int offset = dest-(pc+1); | ||
| 69 | SETARG_S(*jmp, -offset); | ||
| 70 | } | ||
| 71 | |||
| 72 | |||
| 62 | static int luaK_getjump (FuncState *fs, int pc) { | 73 | static int luaK_getjump (FuncState *fs, int pc) { |
| 63 | int offset = GETARG_S(fs->f->code[pc]); | 74 | int offset = GETARG_S(fs->f->code[pc]); |
| 64 | if (offset == NO_JUMP) /* point to itself represents end of list */ | 75 | if (offset == NO_JUMP) /* point to itself represents end of list */ |
