| 285 | |
| 286 | |
| 287 | void luaD_hook (lua_State *L, int event, int line) { |
| 288 | lua_Hook hook = L->hook; |
| 289 | if (hook && L->allowhook) { |
| 290 | CallInfo *ci = L->ci; |
| 291 | ptrdiff_t top = savestack(L, L->top); |
| 292 | ptrdiff_t ci_top = savestack(L, ci->top); |
| 293 | lua_Debug ar; |
| 294 | ar.event = event; |
| 295 | ar.currentline = line; |
| 296 | ar.i_ci = ci; |
| 297 | luaD_checkstack(L, LUA_MINSTACK); /* ensure minimum stack size */ |
| 298 | ci->top = L->top + LUA_MINSTACK; |
| 299 | lua_assert(ci->top <= L->stack_last); |
| 300 | L->allowhook = 0; /* cannot call hooks inside a hook */ |
| 301 | ci->callstatus |= CIST_HOOKED; |
| 302 | lua_unlock(L); |
| 303 | (*hook)(L, &ar); |
| 304 | lua_lock(L); |
| 305 | lua_assert(!L->allowhook); |
| 306 | L->allowhook = 1; |
| 307 | ci->top = restorestack(L, ci_top); |
| 308 | L->top = restorestack(L, top); |
| 309 | ci->callstatus &= ~CIST_HOOKED; |
| 310 | } |
| 311 | } |
| 312 | |
| 313 | |
| 314 | static void callhook (lua_State *L, CallInfo *ci) { |
no outgoing calls
no test coverage detected