aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2002-12-11 10:34:22 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2002-12-11 10:34:22 -0200
commit9e8face8d83646c830cc932bf97ae1c3f5fb48ba (patch)
treed75e11c37f1faeab3f932cf3517eb96f1d347873
parent64864f094b9be22662fe1d0becb02dee97851067 (diff)
downloadlua-9e8face8d83646c830cc932bf97ae1c3f5fb48ba.tar.gz
lua-9e8face8d83646c830cc932bf97ae1c3f5fb48ba.tar.bz2
lua-9e8face8d83646c830cc932bf97ae1c3f5fb48ba.zip
must move call results in the last iteration, too
-rw-r--r--lvm.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/lvm.c b/lvm.c
index 7e7f5dda..ab065d7d 100644
--- a/lvm.c
+++ b/lvm.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lvm.c,v 1.271 2002/12/04 17:38:31 roberto Exp roberto $ 2** $Id: lvm.c,v 1.272 2002/12/06 17:09:00 roberto Exp roberto $
3** Lua virtual machine 3** Lua virtual machine
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -679,15 +679,16 @@ StkId luaV_execute (lua_State *L) {
679 L->top = cb+3; /* func. + 2 args (state and index) */ 679 L->top = cb+3; /* func. + 2 args (state and index) */
680 luaD_call(L, cb, nvar); 680 luaD_call(L, cb, nvar);
681 L->top = L->ci->top; 681 L->top = L->ci->top;
682 ra = XRA(i); /* call may change stack */ 682 ra = XRA(i) + 2; /* final position of first result */
683 cb = ra + nvar + 2; 683 cb = ra + nvar;
684 if (ttisnil(cb)) /* break loop? */ 684 do { /* move results to proper positions */
685 nvar--;
686 setobjs2s(ra+nvar, cb+nvar);
687 } while (nvar > 0);
688 if (ttisnil(ra)) /* break loop? */
685 pc++; /* skip jump (break loop) */ 689 pc++; /* skip jump (break loop) */
686 else { 690 else
687 while (nvar--) /* move results to proper positions */
688 setobjs2s(ra+2+nvar, cb+nvar);
689 dojump(pc, GETARG_sBx(*pc) + 1); /* jump back */ 691 dojump(pc, GETARG_sBx(*pc) + 1); /* jump back */
690 }
691 break; 692 break;
692 } 693 }
693 case OP_TFORPREP: { /* for compatibility only */ 694 case OP_TFORPREP: { /* for compatibility only */