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 /lparser.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 'lparser.c')
| -rw-r--r-- | lparser.c | 8 |
1 files changed, 4 insertions, 4 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lparser.c,v 2.94 2010/12/17 12:03:41 roberto Exp roberto $ | 2 | ** $Id: lparser.c,v 2.95 2011/01/26 16:30:02 roberto Exp roberto $ |
| 3 | ** Lua Parser | 3 | ** Lua Parser |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -245,7 +245,7 @@ static int searchvar (FuncState *fs, TString *n) { | |||
| 245 | 245 | ||
| 246 | /* | 246 | /* |
| 247 | Mark block where variable at given level was defined | 247 | Mark block where variable at given level was defined |
| 248 | (to emit OP_CLOSE later). | 248 | (to emit close instructions later). |
| 249 | */ | 249 | */ |
| 250 | static void markupval (FuncState *fs, int level) { | 250 | static void markupval (FuncState *fs, int level) { |
| 251 | BlockCnt *bl = fs->bl; | 251 | BlockCnt *bl = fs->bl; |
| @@ -1053,9 +1053,9 @@ static void breakstat (LexState *ls) { | |||
| 1053 | } | 1053 | } |
| 1054 | if (!bl) | 1054 | if (!bl) |
| 1055 | luaX_syntaxerror(ls, "no loop to break"); | 1055 | luaX_syntaxerror(ls, "no loop to break"); |
| 1056 | if (upval) | ||
| 1057 | luaK_codeABC(fs, OP_CLOSE, bl->nactvar, 0, 0); | ||
| 1058 | luaK_concat(fs, &bl->breaklist, luaK_jump(fs)); | 1056 | luaK_concat(fs, &bl->breaklist, luaK_jump(fs)); |
| 1057 | if (upval) | ||
| 1058 | luaK_patchclose(fs, bl->breaklist, bl->nactvar); | ||
| 1059 | } | 1059 | } |
| 1060 | 1060 | ||
| 1061 | 1061 | ||
