** 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
| 673 | ** multiple runs, changing only if there is a new error. |
| 674 | */ |
| 675 | static int finishpcallk (lua_State *L, CallInfo *ci) { |
| 676 | int status = getcistrecst(ci); /* get original status */ |
| 677 | if (l_likely(status == LUA_OK)) /* no error? */ |
| 678 | status = LUA_YIELD; /* was interrupted by an yield */ |
| 679 | else { /* error */ |
| 680 | StkId func = restorestack(L, ci->u2.funcidx); |
| 681 | L->allowhook = getoah(ci->callstatus); /* restore 'allowhook' */ |
| 682 | func = luaF_close(L, func, status, 1); /* can yield or raise an error */ |
| 683 | luaD_seterrorobj(L, status, func); |
| 684 | luaD_shrinkstack(L); /* restore stack size in case of overflow */ |
| 685 | setcistrecst(ci, LUA_OK); /* clear original status */ |
| 686 | } |
| 687 | ci->callstatus &= ~CIST_YPCALL; |
| 688 | L->errfunc = ci->u.c.old_errfunc; |
| 689 | /* if it is here, there were errors or yields; unlike 'lua_pcallk', |
| 690 | do not change status */ |
| 691 | return status; |
| 692 | } |
| 693 | |
| 694 | |
| 695 | /* |
no test coverage detected