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

Function luaD_hook

third-party/lua-5.5.0/src/ldo.c:439–468  ·  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

437** function, can be changed asynchronously by signals.)
438*/
439void luaD_hook (lua_State *L, int event, int line,
440 int ftransfer, int ntransfer) {
441 lua_Hook hook = L->hook;
442 if (hook && L->allowhook) { /* make sure there is a hook */
443 CallInfo *ci = L->ci;
444 ptrdiff_t top = savestack(L, L->top.p); /* preserve original 'top' */
445 ptrdiff_t ci_top = savestack(L, ci->top.p); /* idem for 'ci->top' */
446 lua_Debug ar;
447 ar.event = event;
448 ar.currentline = line;
449 ar.i_ci = ci;
450 L->transferinfo.ftransfer = ftransfer;
451 L->transferinfo.ntransfer = ntransfer;
452 if (isLua(ci) && L->top.p < ci->top.p)
453 L->top.p = ci->top.p; /* protect entire activation register */
454 luaD_checkstack(L, LUA_MINSTACK); /* ensure minimum stack size */
455 if (ci->top.p < L->top.p + LUA_MINSTACK)
456 ci->top.p = L->top.p + LUA_MINSTACK;
457 L->allowhook = 0; /* cannot call hooks inside a hook */
458 ci->callstatus |= CIST_HOOKED;
459 lua_unlock(L);
460 (*hook)(L, &ar);
461 lua_lock(L);
462 lua_assert(!L->allowhook);
463 L->allowhook = 1;
464 ci->top.p = restorestack(L, ci_top);
465 L->top.p = restorestack(L, top);
466 ci->callstatus &= ~CIST_HOOKED;
467 }
468}
469
470
471/*

Callers 4

luaG_traceexecFunction · 0.70
luaD_hookcallFunction · 0.70
rethookFunction · 0.70
precallCFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected