diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2011-02-01 16:03:10 -0200 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2011-02-01 16:03:10 -0200 |
| commit | dd547c55c85ba48f481836ba76ecdfe69960bcd0 (patch) | |
| tree | d75d864ae35fc5bafacf3c206eaa20885b03a3d1 /lcode.c | |
| parent | f6bd8b1147d58c35e73225b4adc5499c11d2bf0f (diff) | |
| download | lua-dd547c55c85ba48f481836ba76ecdfe69960bcd0.tar.gz lua-dd547c55c85ba48f481836ba76ecdfe69960bcd0.tar.bz2 lua-dd547c55c85ba48f481836ba76ecdfe69960bcd0.zip | |
new scheme to close upvalues in 'break'; jump instructions may
do the close, avoiding the need for a OP_CLOSE instruction
Diffstat (limited to 'lcode.c')
| -rw-r--r-- | lcode.c | 15 |
1 files changed, 14 insertions, 1 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lcode.c,v 2.49 2010/07/07 16:27:29 roberto Exp roberto $ | 2 | ** $Id: lcode.c,v 2.50 2011/01/31 14:28:41 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 | */ |
| @@ -171,6 +171,19 @@ void luaK_patchlist (FuncState *fs, int list, int target) { | |||
| 171 | } | 171 | } |
| 172 | 172 | ||
| 173 | 173 | ||
| 174 | LUAI_FUNC void luaK_patchclose (FuncState *fs, int list, int level) { | ||
| 175 | level++; /* argument is +1 to reserve 0 as non-op */ | ||
| 176 | while (list != NO_JUMP) { | ||
| 177 | int next = getjump(fs, list); | ||
| 178 | lua_assert(GET_OPCODE(fs->f->code[list]) == OP_JMP && | ||
| 179 | (GETARG_A(fs->f->code[list]) == 0 || | ||
| 180 | GETARG_A(fs->f->code[list]) >= level)); | ||
| 181 | SETARG_A(fs->f->code[list], level); | ||
| 182 | list = next; | ||
| 183 | } | ||
| 184 | } | ||
| 185 | |||
| 186 | |||
| 174 | void luaK_patchtohere (FuncState *fs, int list) { | 187 | void luaK_patchtohere (FuncState *fs, int list) { |
| 175 | luaK_getlabel(fs); | 188 | luaK_getlabel(fs); |
| 176 | luaK_concat(fs, &fs->jpc, list); | 189 | luaK_concat(fs, &fs->jpc, list); |
