** Finish the job of 'lua_pcallk' after it was interrupted by an yield. ** (The caller, 'finishCcall', does the final call to 'adjustresults'.) ** The main job is to complete the 'luaD_pcall' called by 'lua_pcallk'. ** If a '__close' method yields here, eventually control will be back ** to 'finishCcall' (when that '__close' method finally returns) and ** 'finishpcallk' will run again and close an
| 613 | ** multiple runs, changing only if there is a new error. |
| 614 | */ |
| 615 | static int finishpcallk (lua_State *L, CallInfo *ci) { |
| 616 | int status = getcistrecst(ci); /* get original status */ |
| 617 | if (l_likely(status == LUA_OK)) /* no error? */ |
| 618 | status = LUA_YIELD; /* was interrupted by an yield */ |
| 619 | else { /* error */ |
| 620 | StkId func = restorestack(L, ci->u2.funcidx); |
| 621 | L->allowhook = getoah(ci->callstatus); /* restore 'allowhook' */ |
| 622 | luaF_close(L, func, status, 1); /* can yield or raise an error */ |
| 623 | func = restorestack(L, ci->u2.funcidx); /* stack may be moved */ |
| 624 | luaD_seterrorobj(L, status, func); |
| 625 | luaD_shrinkstack(L); /* restore stack size in case of overflow */ |
| 626 | setcistrecst(ci, LUA_OK); /* clear original status */ |
| 627 | } |
| 628 | ci->callstatus &= ~CIST_YPCALL; |
| 629 | L->errfunc = ci->u.c.old_errfunc; |
| 630 | /* if it is here, there were errors or yields; unlike 'lua_pcallk', |
| 631 | do not change status */ |
| 632 | return status; |
| 633 | } |
| 634 | |
| 635 | |
| 636 | /* |
no test coverage detected