summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2001-09-28 13:48:16 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2001-09-28 13:48:16 -0300
commitf54cdb33a565aacd41fe00a172a3062a4a33118b (patch)
treed238f343f2430acae38b1a914d681e9ee3c9723b
parent8e9b1e4ae979aec95dcceb0db177367f5e865041 (diff)
downloadlua-f54cdb33a565aacd41fe00a172a3062a4a33118b.tar.gz
lua-f54cdb33a565aacd41fe00a172a3062a4a33118b.tar.bz2
lua-f54cdb33a565aacd41fe00a172a3062a4a33118b.zip
small bug in close x return
-rw-r--r--ldebug.c3
-rw-r--r--lparser.c14
-rw-r--r--lvm.c6
3 files changed, 12 insertions, 11 deletions
diff --git a/ldebug.c b/ldebug.c
index 57215028..cf397bd2 100644
--- a/ldebug.c
+++ b/ldebug.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ldebug.c,v 1.87 2001/07/03 17:01:34 roberto Exp $ 2** $Id: ldebug.c,v 1.88 2001/09/07 17:39:10 roberto Exp $
3** Debug Interface 3** Debug Interface
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -331,7 +331,6 @@ static int checkopenop (const Proto *pt, int pc) {
331 check(GETARG_B(i) == NO_REG); 331 check(GETARG_B(i) == NO_REG);
332 return 1; 332 return 1;
333 } 333 }
334 case OP_CLOSE: return checkopenop(pt, pc+1);
335 case OP_SETLISTO: return 1; 334 case OP_SETLISTO: return 1;
336 default: return 0; /* invalid instruction after an open call */ 335 default: return 0; /* invalid instruction after an open call */
337 } 336 }
diff --git a/lparser.c b/lparser.c
index b3fb7e5e..833f1592 100644
--- a/lparser.c
+++ b/lparser.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lparser.c,v 1.156 2001/09/07 17:39:10 roberto Exp $ 2** $Id: lparser.c,v 1.157 2001/09/25 17:06:48 roberto Exp $
3** Lua Parser 3** Lua Parser
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -184,9 +184,10 @@ static void closelevel (LexState *ls, int level) {
184} 184}
185 185
186 186
187static void removelocalvars (LexState *ls, int nvars) { 187static void removelocalvars (LexState *ls, int nvars, int toclose) {
188 FuncState *fs = ls->fs; 188 FuncState *fs = ls->fs;
189 closelevel(ls, fs->nactloc - nvars); 189 if (toclose)
190 closelevel(ls, fs->nactloc - nvars);
190 while (nvars--) 191 while (nvars--)
191 fs->f->locvars[fs->actloc[--fs->nactloc]].endpc = fs->pc; 192 fs->f->locvars[fs->actloc[--fs->nactloc]].endpc = fs->pc;
192} 193}
@@ -333,7 +334,7 @@ static void close_func (LexState *ls) {
333 lua_State *L = ls->L; 334 lua_State *L = ls->L;
334 FuncState *fs = ls->fs; 335 FuncState *fs = ls->fs;
335 Proto *f = fs->f; 336 Proto *f = fs->f;
336 removelocalvars(ls, fs->nactloc); 337 removelocalvars(ls, fs->nactloc, 0);
337 luaK_codeABC(fs, OP_RETURN, 0, 0, 0); /* final return */ 338 luaK_codeABC(fs, OP_RETURN, 0, 0, 0); /* final return */
338 luaK_getlabel(fs); /* close eventual list of pending jumps */ 339 luaK_getlabel(fs); /* close eventual list of pending jumps */
339 lua_assert(G(L)->roottable == fs->h); 340 lua_assert(G(L)->roottable == fs->h);
@@ -816,7 +817,7 @@ static void block (LexState *ls) {
816 FuncState *fs = ls->fs; 817 FuncState *fs = ls->fs;
817 int nactloc = fs->nactloc; 818 int nactloc = fs->nactloc;
818 chunk(ls); 819 chunk(ls);
819 removelocalvars(ls, fs->nactloc - nactloc); 820 removelocalvars(ls, fs->nactloc - nactloc, 1);
820 fs->freereg = nactloc; /* free registers used by locals */ 821 fs->freereg = nactloc; /* free registers used by locals */
821} 822}
822 823
@@ -951,7 +952,7 @@ static void forbody (LexState *ls, int nvar, OpCode prepfor, OpCode loopfor) {
951 block(ls); 952 block(ls);
952 luaK_patchlist(fs, luaK_codeAsBc(fs, loopfor, basereg, NO_JUMP), blockinit); 953 luaK_patchlist(fs, luaK_codeAsBc(fs, loopfor, basereg, NO_JUMP), blockinit);
953 luaK_fixfor(fs, prep, luaK_getlabel(fs)); 954 luaK_fixfor(fs, prep, luaK_getlabel(fs));
954 removelocalvars(ls, nvar); 955 removelocalvars(ls, nvar, 1);
955} 956}
956 957
957 958
@@ -1128,7 +1129,6 @@ static void retstat (LexState *ls) {
1128 nret = fs->freereg - first; /* return all `active' values */ 1129 nret = fs->freereg - first; /* return all `active' values */
1129 } 1130 }
1130 } 1131 }
1131 closelevel(ls, 0);
1132 luaK_codeABC(fs, OP_RETURN, first, nret, 0); 1132 luaK_codeABC(fs, OP_RETURN, first, nret, 0);
1133 fs->freereg = fs->nactloc; /* removes all temp values */ 1133 fs->freereg = fs->nactloc; /* removes all temp values */
1134} 1134}
diff --git a/lvm.c b/lvm.c
index 1d16a7b5..1fe4aad5 100644
--- a/lvm.c
+++ b/lvm.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lvm.c,v 1.190 2001/06/28 14:57:17 roberto Exp roberto $ 2** $Id: lvm.c,v 1.193 2001/09/07 17:39:10 roberto Exp $
3** Lua virtual machine 3** Lua virtual machine
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -556,7 +556,9 @@ StkId luaV_execute (lua_State *L, const Closure *cl, StkId base) {
556 break; 556 break;
557 } 557 }
558 case OP_RETURN: { 558 case OP_RETURN: {
559 int b = GETARG_B(i); 559 int b;
560 luaF_close(L, base);
561 b = GETARG_B(i);
560 if (b != NO_REG) 562 if (b != NO_REG)
561 L->top = ra+b; 563 L->top = ra+b;
562 return ra; 564 return ra;