MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / rethook

Function rethook

lib/lua/src/ldo.c:387–404  ·  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

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

Callers 2

moveresultsFunction · 0.85
luaD_poscallFunction · 0.85

Calls 1

luaD_hookFunction · 0.85

Tested by

no test coverage detected