| 230 | |
| 231 | |
| 232 | void luaD_hook (lua_State *L, int event, int line) { |
| 233 | lua_Hook hook = L->hook; |
| 234 | if (hook && L->allowhook) { |
| 235 | CallInfo *ci = L->ci; |
| 236 | ptrdiff_t top = savestack(L, L->top); |
| 237 | ptrdiff_t ci_top = savestack(L, ci->top); |
| 238 | lua_Debug ar; |
| 239 | ar.event = event; |
| 240 | ar.currentline = line; |
| 241 | ar.i_ci = ci; |
| 242 | luaD_checkstack(L, LUA_MINSTACK); /* ensure minimum stack size */ |
| 243 | ci->top = L->top + LUA_MINSTACK; |
| 244 | lua_assert(ci->top <= L->stack_last); |
| 245 | L->allowhook = 0; /* cannot call hooks inside a hook */ |
| 246 | ci->callstatus |= CIST_HOOKED; |
| 247 | lua_unlock(L); |
| 248 | (*hook)(L, &ar); |
| 249 | lua_lock(L); |
| 250 | lua_assert(!L->allowhook); |
| 251 | L->allowhook = 1; |
| 252 | ci->top = restorestack(L, ci_top); |
| 253 | L->top = restorestack(L, top); |
| 254 | ci->callstatus &= ~CIST_HOOKED; |
| 255 | } |
| 256 | } |
| 257 | |
| 258 | |
| 259 | static void callhook (lua_State *L, CallInfo *ci) { |
no outgoing calls
no test coverage detected