** Call hook function registered at hook table for the current ** thread (if there is one) */
| 321 | ** thread (if there is one) |
| 322 | */ |
| 323 | static void hookf (lua_State *L, lua_Debug *ar) { |
| 324 | static const char *const hooknames[] = |
| 325 | {"call", "return", "line", "count", "tail call"}; |
| 326 | lua_getfield(L, LUA_REGISTRYINDEX, HOOKKEY); |
| 327 | lua_pushthread(L); |
| 328 | if (lua_rawget(L, -2) == LUA_TFUNCTION) { /* is there a hook function? */ |
| 329 | lua_pushstring(L, hooknames[(int)ar->event]); /* push event name */ |
| 330 | if (ar->currentline >= 0) |
| 331 | lua_pushinteger(L, ar->currentline); /* push current line */ |
| 332 | else lua_pushnil(L); |
| 333 | lua_assert(lua_getinfo(L, "lS", ar)); |
| 334 | lua_call(L, 2, 0); /* call hook function */ |
| 335 | } |
| 336 | } |
| 337 | |
| 338 | |
| 339 | /* |
nothing calls this directly
no test coverage detected