new scheme to close upvalues in 'break'; jump instructions may
do the close, avoiding the need for a OP_CLOSE instruction
This commit is contained in:
15
lcode.c
15
lcode.c
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: lcode.c,v 2.49 2010/07/07 16:27:29 roberto Exp roberto $
|
||||
** $Id: lcode.c,v 2.50 2011/01/31 14:28:41 roberto Exp roberto $
|
||||
** Code generator for Lua
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@@ -171,6 +171,19 @@ void luaK_patchlist (FuncState *fs, int list, int target) {
|
||||
}
|
||||
|
||||
|
||||
LUAI_FUNC void luaK_patchclose (FuncState *fs, int list, int level) {
|
||||
level++; /* argument is +1 to reserve 0 as non-op */
|
||||
while (list != NO_JUMP) {
|
||||
int next = getjump(fs, list);
|
||||
lua_assert(GET_OPCODE(fs->f->code[list]) == OP_JMP &&
|
||||
(GETARG_A(fs->f->code[list]) == 0 ||
|
||||
GETARG_A(fs->f->code[list]) >= level));
|
||||
SETARG_A(fs->f->code[list], level);
|
||||
list = next;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void luaK_patchtohere (FuncState *fs, int list) {
|
||||
luaK_getlabel(fs);
|
||||
luaK_concat(fs, &fs->jpc, list);
|
||||
|
||||
Reference in New Issue
Block a user