** 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.) */
| 363 | ** is done even when return hooks are off.) |
| 364 | */ |
| 365 | static void rethook (lua_State *L, CallInfo *ci, int nres) { |
| 366 | if (L->hookmask & LUA_MASKRET) { /* is return hook on? */ |
| 367 | StkId firstres = L->top - nres; /* index of first result */ |
| 368 | int delta = 0; /* correction for vararg functions */ |
| 369 | int ftransfer; |
| 370 | if (isLua(ci)) { |
| 371 | Proto *p = ci_func(ci)->p; |
| 372 | if (p->is_vararg) |
| 373 | delta = ci->u.l.nextraargs + p->numparams + 1; |
| 374 | } |
| 375 | ci->func += delta; /* if vararg, back to virtual 'func' */ |
| 376 | ftransfer = cast(unsigned short, firstres - ci->func); |
| 377 | luaD_hook(L, LUA_HOOKRET, -1, ftransfer, nres); /* call it */ |
| 378 | ci->func -= delta; |
| 379 | } |
| 380 | if (isLua(ci = ci->previous)) |
| 381 | L->oldpc = pcRel(ci->u.l.savedpc, ci_func(ci)->p); /* set 'oldpc' */ |
| 382 | } |
| 383 | |
| 384 | |
| 385 | /* |
no test coverage detected