'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:
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
|
** Stack and Call structure of Lua
|
||||||
** See Copyright Notice in lua.h
|
** 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? */
|
if (!ttisfunction(func)) /* `func' is not a function? */
|
||||||
func = tryfuncTM(L, func); /* check the `function' tag method */
|
func = tryfuncTM(L, func); /* check the `function' tag method */
|
||||||
funcr = savestack(L, func);
|
funcr = savestack(L, func);
|
||||||
L->ci->nresults = nresults;
|
|
||||||
if (ttislcf(func)) { /* light C function? */
|
if (ttislcf(func)) { /* light C function? */
|
||||||
f = fvalue(func); /* get it */
|
f = fvalue(func); /* get it */
|
||||||
goto isCfunc; /* go to call 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' */
|
isCfunc: /* call C function 'f' */
|
||||||
luaD_checkstack(L, LUA_MINSTACK); /* ensure minimum stack size */
|
luaD_checkstack(L, LUA_MINSTACK); /* ensure minimum stack size */
|
||||||
ci = next_ci(L); /* now 'enter' new function */
|
ci = next_ci(L); /* now 'enter' new function */
|
||||||
|
ci->nresults = nresults;
|
||||||
ci->func = restorestack(L, funcr);
|
ci->func = restorestack(L, funcr);
|
||||||
ci->top = L->top + LUA_MINSTACK;
|
ci->top = L->top + LUA_MINSTACK;
|
||||||
lua_assert(ci->top <= L->stack_last);
|
lua_assert(ci->top <= L->stack_last);
|
||||||
@@ -341,6 +341,7 @@ int luaD_precall (lua_State *L, StkId func, int nresults) {
|
|||||||
else /* vararg function */
|
else /* vararg function */
|
||||||
base = adjust_varargs(L, p, nargs);
|
base = adjust_varargs(L, p, nargs);
|
||||||
ci = next_ci(L); /* now 'enter' new function */
|
ci = next_ci(L); /* now 'enter' new function */
|
||||||
|
ci->nresults = nresults;
|
||||||
ci->func = func;
|
ci->func = func;
|
||||||
ci->u.l.base = base;
|
ci->u.l.base = base;
|
||||||
ci->top = base + p->maxstacksize;
|
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 */
|
L->oldpc = ci->previous->u.l.savedpc; /* 'oldpc' for caller function */
|
||||||
}
|
}
|
||||||
res = ci->func; /* res == final position of 1st result */
|
res = ci->func; /* res == final position of 1st result */
|
||||||
L->ci = ci = ci->previous; /* back to caller */
|
|
||||||
wanted = ci->nresults;
|
wanted = ci->nresults;
|
||||||
|
L->ci = ci = ci->previous; /* back to caller */
|
||||||
/* move results to correct place */
|
/* move results to correct place */
|
||||||
for (i = wanted; i != 0 && firstResult < L->top; i--)
|
for (i = wanted; i != 0 && firstResult < L->top; i--)
|
||||||
setobjs2s(L, res++, firstResult++);
|
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
|
** Global State
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@@ -72,7 +72,7 @@ typedef struct CallInfo {
|
|||||||
StkId func; /* function index in the stack */
|
StkId func; /* function index in the stack */
|
||||||
StkId top; /* top for this function */
|
StkId top; /* top for this function */
|
||||||
struct CallInfo *previous, *next; /* dynamic call link */
|
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;
|
lu_byte callstatus;
|
||||||
union {
|
union {
|
||||||
struct { /* only for Lua functions */
|
struct { /* only for Lua functions */
|
||||||
|
|||||||
Reference in New Issue
Block a user