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

Function luaD_hook

third-party/lua-5.4.6/src/ldo.c:335–368  ·  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

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

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