| 272 | |
| 273 | |
| 274 | void luaD_hook(lua_State *L, int event, int line) { |
| 275 | lua_Hook hook = L->hook; |
| 276 | if (hook && L->allowhook) { |
| 277 | CallInfo *ci = L->ci; |
| 278 | ptrdiff_t top = savestack(L, L->top); |
| 279 | ptrdiff_t ci_top = savestack(L, ci->top); |
| 280 | lua_Debug ar; |
| 281 | ar.event = event; |
| 282 | ar.currentline = line; |
| 283 | ar.i_ci = ci; |
| 284 | luaD_checkstack(L, LUA_MINSTACK); /* ensure minimum stack size */ |
| 285 | ci->top = L->top + LUA_MINSTACK; |
| 286 | lua_assert(ci->top <= L->stack_last); |
| 287 | L->allowhook = 0; /* cannot call hooks inside a hook */ |
| 288 | ci->callstatus |= CIST_HOOKED; |
| 289 | lua_unlock(L); |
| 290 | (*hook)(L, &ar); |
| 291 | lua_lock(L); |
| 292 | lua_assert(!L->allowhook); |
| 293 | L->allowhook = 1; |
| 294 | ci->top = restorestack(L, ci_top); |
| 295 | L->top = restorestack(L, top); |
| 296 | ci->callstatus &= ~CIST_HOOKED; |
| 297 | } |
| 298 | } |
| 299 | |
| 300 | |
| 301 | static void callhook(lua_State *L, CallInfo *ci) { |
no outgoing calls
no test coverage detected