diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2002-12-11 10:34:22 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2002-12-11 10:34:22 -0200 |
commit | 73517e86b02b47531bec189d4230e359274d8d04 (patch) | |
tree | d5ccf4675f7923be9cc328a210947afa71482a66 | |
parent | 9e8face8d83646c830cc932bf97ae1c3f5fb48ba (diff) | |
download | lua-73517e86b02b47531bec189d4230e359274d8d04.tar.gz lua-73517e86b02b47531bec189d4230e359274d8d04.tar.bz2 lua-73517e86b02b47531bec189d4230e359274d8d04.zip |
OP_TFORLOOP uses extra stack space
-rw-r--r-- | lcode.c | 4 | ||||
-rw-r--r-- | lcode.h | 3 | ||||
-rw-r--r-- | ldebug.c | 4 | ||||
-rw-r--r-- | lparser.c | 3 |
4 files changed, 8 insertions, 6 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lcode.c,v 1.113 2002/11/14 16:15:53 roberto Exp roberto $ | 2 | ** $Id: lcode.c,v 1.114 2002/12/04 17:38:31 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 | */ |
@@ -176,7 +176,7 @@ void luaK_concat (FuncState *fs, int *l1, int l2) { | |||
176 | } | 176 | } |
177 | 177 | ||
178 | 178 | ||
179 | static void luaK_checkstack (FuncState *fs, int n) { | 179 | void luaK_checkstack (FuncState *fs, int n) { |
180 | int newstack = fs->freereg + n; | 180 | int newstack = fs->freereg + n; |
181 | if (newstack > fs->f->maxstacksize) { | 181 | if (newstack > fs->f->maxstacksize) { |
182 | if (newstack >= MAXSTACK) | 182 | if (newstack >= MAXSTACK) |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lcode.h,v 1.36 2002/05/13 13:07:48 roberto Exp roberto $ | 2 | ** $Id: lcode.h,v 1.37 2002/06/12 19:16:00 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 | */ |
@@ -47,6 +47,7 @@ int luaK_codeABC (FuncState *fs, OpCode o, int A, int B, int C); | |||
47 | void luaK_fixline (FuncState *fs, int line); | 47 | void luaK_fixline (FuncState *fs, int line); |
48 | void luaK_nil (FuncState *fs, int from, int n); | 48 | void luaK_nil (FuncState *fs, int from, int n); |
49 | void luaK_reserveregs (FuncState *fs, int n); | 49 | void luaK_reserveregs (FuncState *fs, int n); |
50 | void luaK_checkstack (FuncState *fs, int n); | ||
50 | int luaK_stringK (FuncState *fs, TString *s); | 51 | int luaK_stringK (FuncState *fs, TString *s); |
51 | int luaK_numberK (FuncState *fs, lua_Number r); | 52 | int luaK_numberK (FuncState *fs, lua_Number r); |
52 | void luaK_dischargevars (FuncState *fs, expdesc *e); | 53 | void luaK_dischargevars (FuncState *fs, expdesc *e); |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ldebug.c,v 1.141 2002/12/04 17:38:31 roberto Exp roberto $ | 2 | ** $Id: ldebug.c,v 1.142 2002/12/06 17:15:35 roberto Exp roberto $ |
3 | ** Debug Interface | 3 | ** Debug Interface |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -364,7 +364,7 @@ static Instruction luaG_symbexec (const Proto *pt, int lastpc, int reg) { | |||
364 | break; | 364 | break; |
365 | } | 365 | } |
366 | case OP_TFORLOOP: | 366 | case OP_TFORLOOP: |
367 | checkreg(pt, a+2+c); | 367 | checkreg(pt, a+c+5); |
368 | if (reg >= a) last = pc; /* affect all registers above base */ | 368 | if (reg >= a) last = pc; /* affect all registers above base */ |
369 | /* go through */ | 369 | /* go through */ |
370 | case OP_FORLOOP: | 370 | case OP_FORLOOP: |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lparser.c,v 1.200 2002/12/04 17:38:31 roberto Exp roberto $ | 2 | ** $Id: lparser.c,v 1.201 2002/12/06 17:09:00 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 | */ |
@@ -1070,6 +1070,7 @@ static void forlist (LexState *ls, TString *indexname) { | |||
1070 | check(ls, TK_IN); | 1070 | check(ls, TK_IN); |
1071 | line = ls->linenumber; | 1071 | line = ls->linenumber; |
1072 | adjust_assign(ls, nvars, explist1(ls, &e), &e); | 1072 | adjust_assign(ls, nvars, explist1(ls, &e), &e); |
1073 | luaK_checkstack(fs, 3); /* extra space to call generator */ | ||
1073 | luaK_codeAsBx(fs, OP_TFORPREP, base, NO_JUMP); | 1074 | luaK_codeAsBx(fs, OP_TFORPREP, base, NO_JUMP); |
1074 | forbody(ls, base, line, nvars, 0); | 1075 | forbody(ls, base, line, nvars, 0); |
1075 | } | 1076 | } |