** 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.) */
| 392 | ** is done even when return hooks are off.) |
| 393 | */ |
| 394 | static void rethook (lua_State *L, CallInfo *ci, int nres) { |
| 395 | if (L->hookmask & LUA_MASKRET) { /* is return hook on? */ |
| 396 | StkId firstres = L->top.p - nres; /* index of first result */ |
| 397 | int delta = 0; /* correction for vararg functions */ |
| 398 | int ftransfer; |
| 399 | if (isLua(ci)) { |
| 400 | Proto *p = ci_func(ci)->p; |
| 401 | if (p->is_vararg) |
| 402 | delta = ci->u.l.nextraargs + p->numparams + 1; |
| 403 | } |
| 404 | ci->func.p += delta; /* if vararg, back to virtual 'func' */ |
| 405 | ftransfer = cast(unsigned short, firstres - ci->func.p); |
| 406 | luaD_hook(L, LUA_HOOKRET, -1, ftransfer, nres); /* call it */ |
| 407 | ci->func.p -= delta; |
| 408 | } |
| 409 | if (isLua(ci = ci->previous)) |
| 410 | L->oldpc = pcRel(ci->u.l.savedpc, ci_func(ci)->p); /* set 'oldpc' */ |
| 411 | } |
| 412 | |
| 413 | |
| 414 | /* |
no test coverage detected