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

Function rethook

third-party/lua-5.4.6/src/ldo.c:394–411  ·  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

392** is done even when return hooks are off.)
393*/
394static void rethook (lua_State *L, CallInfo *ci, int nres) {
395 if (L->hookmask & LUA_MASKRET) { /* is return hook on? */
396 StkId firstres = L->top.p - nres; /* index of first result */
397 int delta = 0; /* correction for vararg functions */
398 int ftransfer;
399 if (isLua(ci)) {
400 Proto *p = ci_func(ci)->p;
401 if (p->is_vararg)
402 delta = ci->u.l.nextraargs + p->numparams + 1;
403 }
404 ci->func.p += delta; /* if vararg, back to virtual 'func' */
405 ftransfer = cast(unsigned short, firstres - ci->func.p);
406 luaD_hook(L, LUA_HOOKRET, -1, ftransfer, nres); /* call it */
407 ci->func.p -= delta;
408 }
409 if (isLua(ci = ci->previous))
410 L->oldpc = pcRel(ci->u.l.savedpc, ci_func(ci)->p); /* set 'oldpc' */
411}
412
413
414/*

Callers 2

moveresultsFunction · 0.70
luaD_poscallFunction · 0.70

Calls 1

luaD_hookFunction · 0.70

Tested by

no test coverage detected