| 325 | |
| 326 | |
| 327 | static StkId rethook (lua_State *L, CallInfo *ci, StkId firstres, int nres) { |
| 328 | ptrdiff_t oldtop = savestack(L, L->top); /* hook may change top */ |
| 329 | int delta = 0; |
| 330 | if (isLuacode(ci)) { |
| 331 | Proto *p = clLvalue(s2v(ci->func))->p; |
| 332 | if (p->is_vararg) |
| 333 | delta = ci->u.l.nextraargs + p->numparams + 1; |
| 334 | if (L->top < ci->top) |
| 335 | L->top = ci->top; /* correct top to run hook */ |
| 336 | } |
| 337 | if (L->hookmask & LUA_MASKRET) { /* is return hook on? */ |
| 338 | int ftransfer; |
| 339 | ci->func += delta; /* if vararg, back to virtual 'func' */ |
| 340 | ftransfer = cast(unsigned short, firstres - ci->func); |
| 341 | luaD_hook(L, LUA_HOOKRET, -1, ftransfer, nres); /* call it */ |
| 342 | ci->func -= delta; |
| 343 | } |
| 344 | if (isLua(ci->previous)) |
| 345 | L->oldpc = ci->previous->u.l.savedpc; /* update 'oldpc' */ |
| 346 | return restorestack(L, oldtop); |
| 347 | } |
| 348 | |
| 349 | |
| 350 | /* |
no test coverage detected