diff options
Diffstat (limited to 'ldo.c')
-rw-r--r-- | ldo.c | 14 |
1 files changed, 7 insertions, 7 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ldo.c,v 2.185 2017/12/29 15:44:51 roberto Exp roberto $ | 2 | ** $Id: ldo.c,v 2.186 2018/01/10 19:19:27 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 | */ |
@@ -417,14 +417,14 @@ void luaD_pretailcall (lua_State *L, CallInfo *ci, StkId func, int n) { | |||
417 | checkstackp(L, fsize, func); | 417 | checkstackp(L, fsize, func); |
418 | for (; i <= p->numparams; i++) | 418 | for (; i <= p->numparams; i++) |
419 | setnilvalue(s2v(ci->func + i)); /* complete missing arguments */ | 419 | setnilvalue(s2v(ci->func + i)); /* complete missing arguments */ |
420 | if (p->is_vararg) { | ||
421 | L->top -= (func - ci->func); /* move down top */ | ||
422 | luaT_adjustvarargs(L, p, n - 1); | ||
423 | } | ||
424 | ci->top = ci->func + 1 + fsize; /* top for new function */ | 420 | ci->top = ci->func + 1 + fsize; /* top for new function */ |
425 | lua_assert(ci->top <= L->stack_last); | 421 | lua_assert(ci->top <= L->stack_last); |
426 | ci->u.l.savedpc = p->code; /* starting point */ | 422 | ci->u.l.savedpc = p->code; /* starting point */ |
427 | ci->callstatus |= CIST_TAIL; | 423 | ci->callstatus |= CIST_TAIL; |
424 | if (p->is_vararg) { | ||
425 | L->top -= (func - ci->func); /* move down top */ | ||
426 | luaT_adjustvarargs(L, p, n - 1); | ||
427 | } | ||
428 | if (L->hookmask) | 428 | if (L->hookmask) |
429 | hookcall(L, ci, 1); | 429 | hookcall(L, ci, 1); |
430 | } | 430 | } |
@@ -471,8 +471,6 @@ void luaD_call (lua_State *L, StkId func, int nresults) { | |||
471 | checkstackp(L, fsize, func); | 471 | checkstackp(L, fsize, func); |
472 | for (; n < p->numparams; n++) | 472 | for (; n < p->numparams; n++) |
473 | setnilvalue(s2v(L->top++)); /* complete missing arguments */ | 473 | setnilvalue(s2v(L->top++)); /* complete missing arguments */ |
474 | if (p->is_vararg) | ||
475 | luaT_adjustvarargs(L, p, n); | ||
476 | ci = next_ci(L); /* now 'enter' new function */ | 474 | ci = next_ci(L); /* now 'enter' new function */ |
477 | ci->nresults = nresults; | 475 | ci->nresults = nresults; |
478 | ci->func = func; | 476 | ci->func = func; |
@@ -480,6 +478,8 @@ void luaD_call (lua_State *L, StkId func, int nresults) { | |||
480 | lua_assert(ci->top <= L->stack_last); | 478 | lua_assert(ci->top <= L->stack_last); |
481 | ci->u.l.savedpc = p->code; /* starting point */ | 479 | ci->u.l.savedpc = p->code; /* starting point */ |
482 | ci->callstatus = 0; | 480 | ci->callstatus = 0; |
481 | if (p->is_vararg) | ||
482 | luaT_adjustvarargs(L, p, n); /* may invoke GC */ | ||
483 | if (L->hookmask) | 483 | if (L->hookmask) |
484 | hookcall(L, ci, 0); | 484 | hookcall(L, ci, 0); |
485 | luaV_execute(L, ci); /* run the function */ | 485 | luaV_execute(L, ci); /* run the function */ |