diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2010-09-30 14:21:31 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2010-09-30 14:21:31 -0300 |
commit | ffff9a49da35b8b90d48f5419c9c5e0402f803af (patch) | |
tree | bd29023d29f1618ca5d4928e45d47bc218b97f27 /ldo.c | |
parent | b22356e5c5d836f72e850b5d279ea4af20b8d33c (diff) | |
download | lua-ffff9a49da35b8b90d48f5419c9c5e0402f803af.tar.gz lua-ffff9a49da35b8b90d48f5419c9c5e0402f803af.tar.bz2 lua-ffff9a49da35b8b90d48f5419c9c5e0402f803af.zip |
'nresults' in CallInfo now refers to number of results that the current
function returns (and not what it expects from a call)
Diffstat (limited to 'ldo.c')
-rw-r--r-- | ldo.c | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ldo.c,v 2.87 2010/05/05 18:49:56 roberto Exp roberto $ | 2 | ** $Id: ldo.c,v 2.88 2010/06/04 13:06:15 roberto Exp roberto $ |
3 | ** Stack and Call structure of Lua | 3 | ** Stack and Call structure of Lua |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -299,7 +299,6 @@ int luaD_precall (lua_State *L, StkId func, int nresults) { | |||
299 | if (!ttisfunction(func)) /* `func' is not a function? */ | 299 | if (!ttisfunction(func)) /* `func' is not a function? */ |
300 | func = tryfuncTM(L, func); /* check the `function' tag method */ | 300 | func = tryfuncTM(L, func); /* check the `function' tag method */ |
301 | funcr = savestack(L, func); | 301 | funcr = savestack(L, func); |
302 | L->ci->nresults = nresults; | ||
303 | if (ttislcf(func)) { /* light C function? */ | 302 | if (ttislcf(func)) { /* light C function? */ |
304 | f = fvalue(func); /* get it */ | 303 | f = fvalue(func); /* get it */ |
305 | goto isCfunc; /* go to call it */ | 304 | goto isCfunc; /* go to call it */ |
@@ -312,6 +311,7 @@ int luaD_precall (lua_State *L, StkId func, int nresults) { | |||
312 | isCfunc: /* call C function 'f' */ | 311 | isCfunc: /* call C function 'f' */ |
313 | luaD_checkstack(L, LUA_MINSTACK); /* ensure minimum stack size */ | 312 | luaD_checkstack(L, LUA_MINSTACK); /* ensure minimum stack size */ |
314 | ci = next_ci(L); /* now 'enter' new function */ | 313 | ci = next_ci(L); /* now 'enter' new function */ |
314 | ci->nresults = nresults; | ||
315 | ci->func = restorestack(L, funcr); | 315 | ci->func = restorestack(L, funcr); |
316 | ci->top = L->top + LUA_MINSTACK; | 316 | ci->top = L->top + LUA_MINSTACK; |
317 | lua_assert(ci->top <= L->stack_last); | 317 | lua_assert(ci->top <= L->stack_last); |
@@ -341,6 +341,7 @@ int luaD_precall (lua_State *L, StkId func, int nresults) { | |||
341 | else /* vararg function */ | 341 | else /* vararg function */ |
342 | base = adjust_varargs(L, p, nargs); | 342 | base = adjust_varargs(L, p, nargs); |
343 | ci = next_ci(L); /* now 'enter' new function */ | 343 | ci = next_ci(L); /* now 'enter' new function */ |
344 | ci->nresults = nresults; | ||
344 | ci->func = func; | 345 | ci->func = func; |
345 | ci->u.l.base = base; | 346 | ci->u.l.base = base; |
346 | ci->top = base + p->maxstacksize; | 347 | ci->top = base + p->maxstacksize; |
@@ -368,8 +369,8 @@ int luaD_poscall (lua_State *L, StkId firstResult) { | |||
368 | L->oldpc = ci->previous->u.l.savedpc; /* 'oldpc' for caller function */ | 369 | L->oldpc = ci->previous->u.l.savedpc; /* 'oldpc' for caller function */ |
369 | } | 370 | } |
370 | res = ci->func; /* res == final position of 1st result */ | 371 | res = ci->func; /* res == final position of 1st result */ |
371 | L->ci = ci = ci->previous; /* back to caller */ | ||
372 | wanted = ci->nresults; | 372 | wanted = ci->nresults; |
373 | L->ci = ci = ci->previous; /* back to caller */ | ||
373 | /* move results to correct place */ | 374 | /* move results to correct place */ |
374 | for (i = wanted; i != 0 && firstResult < L->top; i--) | 375 | for (i = wanted; i != 0 && firstResult < L->top; i--) |
375 | setobjs2s(L, res++, firstResult++); | 376 | setobjs2s(L, res++, firstResult++); |