| 608 | |
| 609 | |
| 610 | LUA_API int lua_resume (lua_State *L, lua_State *from, int nargs) { |
| 611 | int status; |
| 612 | int oldnny = L->nny; /* save 'nny' */ |
| 613 | lua_lock(L); |
| 614 | luai_userstateresume(L, nargs); |
| 615 | L->nCcalls = (from) ? from->nCcalls + 1 : 1; |
| 616 | L->nny = 0; /* allow yields */ |
| 617 | api_checknelems(L, (L->status == LUA_OK) ? nargs + 1 : nargs); |
| 618 | status = luaD_rawrunprotected(L, resume_cb, L->top - nargs); |
| 619 | if (status == -1) /* error calling 'lua_resume'? */ |
| 620 | status = LUA_ERRRUN; |
| 621 | else { /* yield or regular error */ |
| 622 | while (status != LUA_OK && status != LUA_YIELD) { /* error? */ |
| 623 | if (recover(L, status)) /* recover point? */ |
| 624 | status = luaD_rawrunprotected(L, unroll, NULL); /* run continuation */ |
| 625 | else { /* unrecoverable error */ |
| 626 | L->status = cast_byte(status); /* mark thread as `dead' */ |
| 627 | seterrorobj(L, status, L->top); |
| 628 | L->ci->top = L->top; |
| 629 | break; |
| 630 | } |
| 631 | } |
| 632 | lua_assert(status == L->status); |
| 633 | } |
| 634 | L->nny = oldnny; /* restore 'nny' */ |
| 635 | L->nCcalls--; |
| 636 | lua_assert(L->nCcalls == ((from) ? from->nCcalls : 0)); |
| 637 | lua_unlock(L); |
| 638 | return status; |
| 639 | } |
| 640 | |
| 641 | |
| 642 | LUA_API int lua_yieldk (lua_State *L, int nresults, int ctx, lua_CFunction k) { |
no test coverage detected