MCPcopy Create free account
hub / github.com/EmmyLua/EmmyLuaDebugger / rethook

Function rethook

third-party/lua-5.5.0/src/ldo.c:494–511  ·  view source on GitHub ↗

** Executes a return hook for Lua and C functions and sets/corrects ** 'oldpc'. (Note that this correction is needed by the line hook, so it ** is done even when return hooks are off.) */

Source from the content-addressed store, hash-verified

492** is done even when return hooks are off.)
493*/
494static void rethook (lua_State *L, CallInfo *ci, int nres) {
495 if (L->hookmask & LUA_MASKRET) { /* is return hook on? */
496 StkId firstres = L->top.p - nres; /* index of first result */
497 int delta = 0; /* correction for vararg functions */
498 int ftransfer;
499 if (isLua(ci)) {
500 Proto *p = ci_func(ci)->p;
501 if (p->flag & PF_VAHID)
502 delta = ci->u.l.nextraargs + p->numparams + 1;
503 }
504 ci->func.p += delta; /* if vararg, back to virtual 'func' */
505 ftransfer = cast_int(firstres - ci->func.p);
506 luaD_hook(L, LUA_HOOKRET, -1, ftransfer, nres); /* call it */
507 ci->func.p -= delta;
508 }
509 if (isLua(ci = ci->previous))
510 L->oldpc = pcRel(ci->u.l.savedpc, ci_func(ci)->p); /* set 'oldpc' */
511}
512
513
514/*

Callers 2

moveresultsFunction · 0.70
luaD_poscallFunction · 0.70

Calls 1

luaD_hookFunction · 0.70

Tested by

no test coverage detected