aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2009-04-15 13:53:39 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2009-04-15 13:53:39 -0300
commit311e9f3ceb19eefe30a1b5f90dfad9898d8bac74 (patch)
treea55686841303166bed3326092299b2f8c94fa164
parent8775f25830df02bc736296f70573032fa7781761 (diff)
downloadlua-311e9f3ceb19eefe30a1b5f90dfad9898d8bac74.tar.gz
lua-311e9f3ceb19eefe30a1b5f90dfad9898d8bac74.tar.bz2
lua-311e9f3ceb19eefe30a1b5f90dfad9898d8bac74.zip
'nresults' is saved in CallInfo from the caller, not the called
-rw-r--r--ldo.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/ldo.c b/ldo.c
index 79bc41d6..28560e0a 100644
--- a/ldo.c
+++ b/ldo.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ldo.c,v 2.57 2009/03/26 12:56:38 roberto Exp roberto $ 2** $Id: ldo.c,v 2.58 2009/04/08 18:04:33 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*/
@@ -251,6 +251,7 @@ int luaD_precall (lua_State *L, StkId func, int nresults) {
251 funcr = savestack(L, func); 251 funcr = savestack(L, func);
252 cl = &clvalue(func)->l; 252 cl = &clvalue(func)->l;
253 L->ci->savedpc = L->savedpc; 253 L->ci->savedpc = L->savedpc;
254 L->ci->nresults = nresults;
254 if (!cl->isC) { /* Lua function? prepare its call */ 255 if (!cl->isC) { /* Lua function? prepare its call */
255 CallInfo *ci; 256 CallInfo *ci;
256 StkId st, base; 257 StkId st, base;
@@ -272,7 +273,6 @@ int luaD_precall (lua_State *L, StkId func, int nresults) {
272 L->savedpc = p->code; /* starting point */ 273 L->savedpc = p->code; /* starting point */
273 ci->u.l.tailcalls = 0; 274 ci->u.l.tailcalls = 0;
274 ci->callstatus = CIST_LUA; 275 ci->callstatus = CIST_LUA;
275 ci->nresults = nresults;
276 for (st = L->top; st < ci->top; st++) 276 for (st = L->top; st < ci->top; st++)
277 setnilvalue(st); 277 setnilvalue(st);
278 L->top = ci->top; 278 L->top = ci->top;
@@ -292,7 +292,6 @@ int luaD_precall (lua_State *L, StkId func, int nresults) {
292 L->base = ci->base = ci->func + 1; 292 L->base = ci->base = ci->func + 1;
293 ci->top = L->top + LUA_MINSTACK; 293 ci->top = L->top + LUA_MINSTACK;
294 lua_assert(ci->top <= L->stack_last); 294 lua_assert(ci->top <= L->stack_last);
295 ci->nresults = nresults;
296 ci->callstatus = 0; 295 ci->callstatus = 0;
297 if (L->hookmask & LUA_MASKCALL) 296 if (L->hookmask & LUA_MASKCALL)
298 luaD_callhook(L, LUA_HOOKCALL, -1); 297 luaD_callhook(L, LUA_HOOKCALL, -1);
@@ -327,7 +326,7 @@ int luaD_poscall (lua_State *L, StkId firstResult) {
327 } 326 }
328 ci = L->ci--; 327 ci = L->ci--;
329 res = ci->func; /* res == final position of 1st result */ 328 res = ci->func; /* res == final position of 1st result */
330 wanted = ci->nresults; 329 wanted = (ci - 1)->nresults;
331 L->base = (ci - 1)->base; /* restore base */ 330 L->base = (ci - 1)->base; /* restore base */
332 L->savedpc = (ci - 1)->savedpc; /* restore savedpc */ 331 L->savedpc = (ci - 1)->savedpc; /* restore savedpc */
333 /* move results to correct place */ 332 /* move results to correct place */
@@ -370,7 +369,7 @@ static void finishCcall (lua_State *L) {
370 /* finish 'luaD_call' */ 369 /* finish 'luaD_call' */
371 G(L)->nCcalls--; 370 G(L)->nCcalls--;
372 /* finish 'lua_callk' */ 371 /* finish 'lua_callk' */
373 adjustresults(L, (L->ci + 1)->nresults); 372 adjustresults(L, L->ci->nresults);
374 /* call continuation function */ 373 /* call continuation function */
375 if (!(L->ci->callstatus & CIST_STAT)) /* no call status? */ 374 if (!(L->ci->callstatus & CIST_STAT)) /* no call status? */
376 L->ci->u.c.status = LUA_YIELD; /* 'default' status */ 375 L->ci->u.c.status = LUA_YIELD; /* 'default' status */