MCPcopy Create free account
hub / github.com/ObEngine/ObEngine / rethook

Function rethook

extlibs/lua/src/ldo.c:327–347  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

325
326
327static StkId rethook (lua_State *L, CallInfo *ci, StkId firstres, int nres) {
328 ptrdiff_t oldtop = savestack(L, L->top); /* hook may change top */
329 int delta = 0;
330 if (isLuacode(ci)) {
331 Proto *p = clLvalue(s2v(ci->func))->p;
332 if (p->is_vararg)
333 delta = ci->u.l.nextraargs + p->numparams + 1;
334 if (L->top < ci->top)
335 L->top = ci->top; /* correct top to run hook */
336 }
337 if (L->hookmask & LUA_MASKRET) { /* is return hook on? */
338 int ftransfer;
339 ci->func += delta; /* if vararg, back to virtual 'func' */
340 ftransfer = cast(unsigned short, firstres - ci->func);
341 luaD_hook(L, LUA_HOOKRET, -1, ftransfer, nres); /* call it */
342 ci->func -= delta;
343 }
344 if (isLua(ci->previous))
345 L->oldpc = ci->previous->u.l.savedpc; /* update 'oldpc' */
346 return restorestack(L, oldtop);
347}
348
349
350/*

Callers 1

luaD_poscallFunction · 0.85

Calls 1

luaD_hookFunction · 0.85

Tested by

no test coverage detected