From ffff9a49da35b8b90d48f5419c9c5e0402f803af Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Thu, 30 Sep 2010 14:21:31 -0300 Subject: 'nresults' in CallInfo now refers to number of results that the current function returns (and not what it expects from a call) --- ldo.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'ldo.c') diff --git a/ldo.c b/ldo.c index 0003e6c8..1b675264 100644 --- a/ldo.c +++ b/ldo.c @@ -1,5 +1,5 @@ /* -** $Id: ldo.c,v 2.87 2010/05/05 18:49:56 roberto Exp roberto $ +** $Id: ldo.c,v 2.88 2010/06/04 13:06:15 roberto Exp roberto $ ** Stack and Call structure of Lua ** See Copyright Notice in lua.h */ @@ -299,7 +299,6 @@ int luaD_precall (lua_State *L, StkId func, int nresults) { if (!ttisfunction(func)) /* `func' is not a function? */ func = tryfuncTM(L, func); /* check the `function' tag method */ funcr = savestack(L, func); - L->ci->nresults = nresults; if (ttislcf(func)) { /* light C function? */ f = fvalue(func); /* get it */ goto isCfunc; /* go to call it */ @@ -312,6 +311,7 @@ int luaD_precall (lua_State *L, StkId func, int nresults) { isCfunc: /* call C function 'f' */ luaD_checkstack(L, LUA_MINSTACK); /* ensure minimum stack size */ ci = next_ci(L); /* now 'enter' new function */ + ci->nresults = nresults; ci->func = restorestack(L, funcr); ci->top = L->top + LUA_MINSTACK; lua_assert(ci->top <= L->stack_last); @@ -341,6 +341,7 @@ int luaD_precall (lua_State *L, StkId func, int nresults) { else /* vararg function */ base = adjust_varargs(L, p, nargs); ci = next_ci(L); /* now 'enter' new function */ + ci->nresults = nresults; ci->func = func; ci->u.l.base = base; ci->top = base + p->maxstacksize; @@ -368,8 +369,8 @@ int luaD_poscall (lua_State *L, StkId firstResult) { L->oldpc = ci->previous->u.l.savedpc; /* 'oldpc' for caller function */ } res = ci->func; /* res == final position of 1st result */ - L->ci = ci = ci->previous; /* back to caller */ wanted = ci->nresults; + L->ci = ci = ci->previous; /* back to caller */ /* move results to correct place */ for (i = wanted; i != 0 && firstResult < L->top; i--) setobjs2s(L, res++, firstResult++); -- cgit v1.2.3-55-g6feb