MCPcopy Create free account
hub / github.com/CppCXY/EmmyLuaCodeStyle / rethook

Function rethook

3rd/lua-5.4.3/src/ldo.c:365–382  ·  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

363** is done even when return hooks are off.)
364*/
365static void rethook (lua_State *L, CallInfo *ci, int nres) {
366 if (L->hookmask & LUA_MASKRET) { /* is return hook on? */
367 StkId firstres = L->top - nres; /* index of first result */
368 int delta = 0; /* correction for vararg functions */
369 int ftransfer;
370 if (isLua(ci)) {
371 Proto *p = ci_func(ci)->p;
372 if (p->is_vararg)
373 delta = ci->u.l.nextraargs + p->numparams + 1;
374 }
375 ci->func += delta; /* if vararg, back to virtual 'func' */
376 ftransfer = cast(unsigned short, firstres - ci->func);
377 luaD_hook(L, LUA_HOOKRET, -1, ftransfer, nres); /* call it */
378 ci->func -= delta;
379 }
380 if (isLua(ci = ci->previous))
381 L->oldpc = pcRel(ci->u.l.savedpc, ci_func(ci)->p); /* set 'oldpc' */
382}
383
384
385/*

Callers 2

moveresultsFunction · 0.85
luaD_poscallFunction · 0.85

Calls 1

luaD_hookFunction · 0.85

Tested by

no test coverage detected