top must be updated when there is any error

This commit is contained in:
Roberto Ierusalimschy 2001-02-01 15:39:55 -02:00
parent 4ab6acacdf
commit 9a231afa97
1 changed files with 5 additions and 1 deletions

6
lvm.c
View File

@ -1,5 +1,5 @@
/* /*
** $Id: lvm.c,v 1.161 2001/01/29 17:16:58 roberto Exp roberto $ ** $Id: lvm.c,v 1.162 2001/02/01 16:03:38 roberto Exp roberto $
** Lua virtual machine ** Lua virtual machine
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@ -465,12 +465,14 @@ StkId luaV_execute (lua_State *L, const Closure *cl, StkId base) {
break; break;
} }
case OP_SETGLOBAL: { case OP_SETGLOBAL: {
L->top = top; /* primitive set may generate an error */
luaV_setglobal(L, kstr[GETARG_U(i)], top); luaV_setglobal(L, kstr[GETARG_U(i)], top);
top--; top--;
break; break;
} }
case OP_SETTABLE: { case OP_SETTABLE: {
StkId t = top-GETARG_A(i); StkId t = top-GETARG_A(i);
L->top = top; /* primitive set may generate an error */
luaV_settable(L, t, t+1, top); luaV_settable(L, t, t+1, top);
top -= GETARG_B(i); /* pop values */ top -= GETARG_B(i); /* pop values */
break; break;
@ -479,6 +481,7 @@ StkId luaV_execute (lua_State *L, const Closure *cl, StkId base) {
int aux = GETARG_A(i) * LFIELDS_PER_FLUSH; int aux = GETARG_A(i) * LFIELDS_PER_FLUSH;
int n = GETARG_B(i); int n = GETARG_B(i);
Hash *arr = hvalue(top-n-1); Hash *arr = hvalue(top-n-1);
L->top = top-n;
for (; n; n--) for (; n; n--)
setobj(luaH_setnum(L, arr, n+aux), --top); setobj(luaH_setnum(L, arr, n+aux), --top);
break; break;
@ -487,6 +490,7 @@ StkId luaV_execute (lua_State *L, const Closure *cl, StkId base) {
int n = GETARG_U(i); int n = GETARG_U(i);
StkId finaltop = top-2*n; StkId finaltop = top-2*n;
Hash *arr = hvalue(finaltop-1); Hash *arr = hvalue(finaltop-1);
L->top = finaltop;
for (; n; n--) { for (; n; n--) {
top-=2; top-=2;
setobj(luaH_set(L, arr, top), top+1); setobj(luaH_set(L, arr, top), top+1);