GRIM: LUA: Restore original callhooks

This commit is contained in:
Paweł Kołodziejski 2022-01-16 08:33:08 +01:00
parent 962d676346
commit 0375a44f66
No known key found for this signature in database
GPG Key ID: 0BDADC9E74440FF7
2 changed files with 8 additions and 6 deletions

View File

@ -137,15 +137,13 @@ static StkId callC(lua_CFunction f, StkId base) {
CS->num = numarg;
CS->lua2C = base;
CS->base = base + numarg; // == top - stack
if (lua_callhook) {
TObject *r = lua_state->stack.stack + base - 1;
(*lua_callhook)(Ref(r), "(C)", -1);
}
if (lua_callhook)
luaD_callHook(base, nullptr, 0);
lua_state->callLevelCounter++;
(*f)(); // do the actual call
lua_state->callLevelCounter--;
// if (lua_callhook) // func may have changed lua_callhook
// (*lua_callhook)(LUA_NOOBJECT, "(return)", 0);
if (lua_callhook) // func may have changed lua_callhook
luaD_callHook(base, nullptr, 1);
firstResult = CS->base;
*CS = oldCLS;
return firstResult;

View File

@ -243,6 +243,8 @@ static void adjust_varargs(StkId first_extra_arg) {
StkId luaV_execute(lua_Task *task) {
if (!task->executed) {
if (lua_callhook)
luaD_callHook(task->base, task->tf, 0);
luaD_checkstack((*task->pc++) + EXTRA_STACK);
if (*task->pc < ZEROVARARG) {
luaD_adjusttop(task->base + *(task->pc++));
@ -660,6 +662,8 @@ callfunc:
task->S->top = task->S->stack + task->base;
// fall through
case RETCODE:
if (lua_callhook)
luaD_callHook(task->base, nullptr, 1);
lua_state->callLevelCounter--;
return (task->base + ((task->aux == RETCODE) ? *task->pc : 0));
case SETLINEW: