diff options
Diffstat (limited to 'ldo.c')
-rw-r--r-- | ldo.c | 9 |
1 files changed, 6 insertions, 3 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ldo.c,v 2.181 2017/12/15 13:07:10 roberto Exp roberto $ | 2 | ** $Id: ldo.c,v 2.182 2017/12/19 16:40:17 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,6 +299,7 @@ static void callhook (lua_State *L, CallInfo *ci, int istail) { | |||
299 | ci->u.l.trap = 1; | 299 | ci->u.l.trap = 1; |
300 | if (!(L->hookmask & LUA_MASKCALL)) | 300 | if (!(L->hookmask & LUA_MASKCALL)) |
301 | return; /* some other hook */ | 301 | return; /* some other hook */ |
302 | L->top = ci->top; /* prepare top */ | ||
302 | ci->u.l.savedpc++; /* hooks assume 'pc' is already incremented */ | 303 | ci->u.l.savedpc++; /* hooks assume 'pc' is already incremented */ |
303 | if (istail) { | 304 | if (istail) { |
304 | ci->callstatus |= CIST_TAIL; | 305 | ci->callstatus |= CIST_TAIL; |
@@ -312,6 +313,8 @@ static void callhook (lua_State *L, CallInfo *ci, int istail) { | |||
312 | 313 | ||
313 | 314 | ||
314 | static void rethook (lua_State *L, CallInfo *ci) { | 315 | static void rethook (lua_State *L, CallInfo *ci) { |
316 | if (isLuacode(ci)) | ||
317 | L->top = ci->top; /* prepare top */ | ||
315 | if (L->hookmask & LUA_MASKRET) /* is return hook on? */ | 318 | if (L->hookmask & LUA_MASKRET) /* is return hook on? */ |
316 | luaD_hook(L, LUA_HOOKRET, -1); /* call it */ | 319 | luaD_hook(L, LUA_HOOKRET, -1); /* call it */ |
317 | if (isLua(ci->previous)) | 320 | if (isLua(ci->previous)) |
@@ -421,7 +424,7 @@ void luaD_pretailcall (lua_State *L, CallInfo *ci, StkId func, int n) { | |||
421 | L->top -= (func - ci->func); /* move down top */ | 424 | L->top -= (func - ci->func); /* move down top */ |
422 | luaT_adjustvarargs(L, p, n - 1); | 425 | luaT_adjustvarargs(L, p, n - 1); |
423 | } | 426 | } |
424 | L->top = ci->top = ci->func + 1 + fsize; /* top for new function */ | 427 | ci->top = ci->func + 1 + fsize; /* top for new function */ |
425 | lua_assert(ci->top <= L->stack_last); | 428 | lua_assert(ci->top <= L->stack_last); |
426 | ci->u.l.savedpc = p->code; /* starting point */ | 429 | ci->u.l.savedpc = p->code; /* starting point */ |
427 | ci->callstatus |= CIST_TAIL; | 430 | ci->callstatus |= CIST_TAIL; |
@@ -476,7 +479,7 @@ void luaD_call (lua_State *L, StkId func, int nresults) { | |||
476 | ci = next_ci(L); /* now 'enter' new function */ | 479 | ci = next_ci(L); /* now 'enter' new function */ |
477 | ci->nresults = nresults; | 480 | ci->nresults = nresults; |
478 | ci->func = func; | 481 | ci->func = func; |
479 | L->top = ci->top = func + 1 + fsize; | 482 | ci->top = func + 1 + fsize; |
480 | lua_assert(ci->top <= L->stack_last); | 483 | lua_assert(ci->top <= L->stack_last); |
481 | ci->u.l.savedpc = p->code; /* starting point */ | 484 | ci->u.l.savedpc = p->code; /* starting point */ |
482 | ci->callstatus = 0; | 485 | ci->callstatus = 0; |