mirror of https://github.com/rusefi/lua.git
'nresults' in CallInfo now refers to number of results that the current
function returns (and not what it expects from a call)
This commit is contained in:
parent
b22356e5c5
commit
ffff9a49da
7
ldo.c
7
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++);
|
||||
|
|
4
lstate.h
4
lstate.h
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
** $Id: lstate.h,v 2.65 2010/05/03 17:39:48 roberto Exp roberto $
|
||||
** $Id: lstate.h,v 2.66 2010/09/03 14:14:01 roberto Exp roberto $
|
||||
** Global State
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
@ -72,7 +72,7 @@ typedef struct CallInfo {
|
|||
StkId func; /* function index in the stack */
|
||||
StkId top; /* top for this function */
|
||||
struct CallInfo *previous, *next; /* dynamic call link */
|
||||
short nresults; /* expected number of results from a call */
|
||||
short nresults; /* expected number of results from this function */
|
||||
lu_byte callstatus;
|
||||
union {
|
||||
struct { /* only for Lua functions */
|
||||
|
|
Loading…
Reference in New Issue