** Executes a return hook for Lua and C functions and sets/corrects ** 'oldpc'. (Note that this correction is needed by the line hook, so it ** is done even when return hooks are off.) */
| 492 | ** is done even when return hooks are off.) |
| 493 | */ |
| 494 | static void rethook (lua_State *L, CallInfo *ci, int nres) { |
| 495 | if (L->hookmask & LUA_MASKRET) { /* is return hook on? */ |
| 496 | StkId firstres = L->top.p - nres; /* index of first result */ |
| 497 | int delta = 0; /* correction for vararg functions */ |
| 498 | int ftransfer; |
| 499 | if (isLua(ci)) { |
| 500 | Proto *p = ci_func(ci)->p; |
| 501 | if (p->flag & PF_VAHID) |
| 502 | delta = ci->u.l.nextraargs + p->numparams + 1; |
| 503 | } |
| 504 | ci->func.p += delta; /* if vararg, back to virtual 'func' */ |
| 505 | ftransfer = cast_int(firstres - ci->func.p); |
| 506 | luaD_hook(L, LUA_HOOKRET, -1, ftransfer, nres); /* call it */ |
| 507 | ci->func.p -= delta; |
| 508 | } |
| 509 | if (isLua(ci = ci->previous)) |
| 510 | L->oldpc = pcRel(ci->u.l.savedpc, ci_func(ci)->p); /* set 'oldpc' */ |
| 511 | } |
| 512 | |
| 513 | |
| 514 | /* |
no test coverage detected