From 9e8face8d83646c830cc932bf97ae1c3f5fb48ba Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Wed, 11 Dec 2002 10:34:22 -0200 Subject: [PATCH] must move call results in the last iteration, too --- lvm.c | 17 +++++++++-------- 1 file 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 @@ /* -** $Id: lvm.c,v 1.271 2002/12/04 17:38:31 roberto Exp roberto $ +** $Id: lvm.c,v 1.272 2002/12/06 17:09:00 roberto Exp roberto $ ** Lua virtual machine ** See Copyright Notice in lua.h */ @@ -679,15 +679,16 @@ StkId luaV_execute (lua_State *L) { L->top = cb+3; /* func. + 2 args (state and index) */ luaD_call(L, cb, nvar); L->top = L->ci->top; - ra = XRA(i); /* call may change stack */ - cb = ra + nvar + 2; - if (ttisnil(cb)) /* break loop? */ + ra = XRA(i) + 2; /* final position of first result */ + cb = ra + nvar; + do { /* move results to proper positions */ + nvar--; + setobjs2s(ra+nvar, cb+nvar); + } while (nvar > 0); + if (ttisnil(ra)) /* break loop? */ pc++; /* skip jump (break loop) */ - else { - while (nvar--) /* move results to proper positions */ - setobjs2s(ra+2+nvar, cb+nvar); + else dojump(pc, GETARG_sBx(*pc) + 1); /* jump back */ - } break; } case OP_TFORPREP: { /* for compatibility only */