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

Function luaD_hook

lib/lua/src/ldo.c:328–361  ·  view source on GitHub ↗

** Call a hook for the given event. Make sure there is a hook to be ** called. (Both 'L->hook' and 'L->hookmask', which trigger this ** function, can be changed asynchronously by signals.) */

Source from the content-addressed store, hash-verified

326** function, can be changed asynchronously by signals.)
327*/
328void luaD_hook (lua_State *L, int event, int line,
329 int ftransfer, int ntransfer) {
330 lua_Hook hook = L->hook;
331 if (hook && L->allowhook) { /* make sure there is a hook */
332 int mask = CIST_HOOKED;
333 CallInfo *ci = L->ci;
334 ptrdiff_t top = savestack(L, L->top.p); /* preserve original 'top' */
335 ptrdiff_t ci_top = savestack(L, ci->top.p); /* idem for 'ci->top' */
336 lua_Debug ar;
337 ar.event = event;
338 ar.currentline = line;
339 ar.i_ci = ci;
340 if (ntransfer != 0) {
341 mask |= CIST_TRAN; /* 'ci' has transfer information */
342 ci->u2.transferinfo.ftransfer = ftransfer;
343 ci->u2.transferinfo.ntransfer = ntransfer;
344 }
345 if (isLua(ci) && L->top.p < ci->top.p)
346 L->top.p = ci->top.p; /* protect entire activation register */
347 luaD_checkstack(L, LUA_MINSTACK); /* ensure minimum stack size */
348 if (ci->top.p < L->top.p + LUA_MINSTACK)
349 ci->top.p = L->top.p + LUA_MINSTACK;
350 L->allowhook = 0; /* cannot call hooks inside a hook */
351 ci->callstatus |= mask;
352 lua_unlock(L);
353 (*hook)(L, &ar);
354 lua_lock(L);
355 lua_assert(!L->allowhook);
356 L->allowhook = 1;
357 ci->top.p = restorestack(L, ci_top);
358 L->top.p = restorestack(L, top);
359 ci->callstatus &= ~mask;
360 }
361}
362
363
364/*

Callers 4

luaG_traceexecFunction · 0.85
luaD_hookcallFunction · 0.85
rethookFunction · 0.85
precallCFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected