| 683 | |
| 684 | |
| 685 | LUA_API int lua_resume(lua_State *L, lua_State *from, int nargs) { |
| 686 | int status; |
| 687 | unsigned short oldnny = L->nny; /* save "number of non-yieldable" calls */ |
| 688 | lua_lock(L); |
| 689 | luai_userstateresume(L, nargs); |
| 690 | L->nCcalls = (from) ? from->nCcalls + 1 : 1; |
| 691 | L->nny = 0; /* allow yields */ |
| 692 | api_checknelems(L, (L->status == LUA_OK) ? nargs + 1 : nargs); |
| 693 | status = luaD_rawrunprotected(L, resume, &nargs); |
| 694 | if (status == -1) /* error calling 'lua_resume'? */ |
| 695 | status = LUA_ERRRUN; |
| 696 | else { /* continue running after recoverable errors */ |
| 697 | while (errorstatus(status) && recover(L, status)) { |
| 698 | /* unroll continuation */ |
| 699 | status = luaD_rawrunprotected(L, unroll, &status); |
| 700 | } |
| 701 | if (errorstatus(status)) { /* unrecoverable error? */ |
| 702 | L->status = cast_byte(status); /* mark thread as 'dead' */ |
| 703 | seterrorobj(L, status, L->top); /* push error message */ |
| 704 | L->ci->top = L->top; |
| 705 | } |
| 706 | else lua_assert(status == L->status); /* normal end or yield */ |
| 707 | } |
| 708 | L->nny = oldnny; /* restore 'nny' */ |
| 709 | L->nCcalls--; |
| 710 | lua_assert(L->nCcalls == ((from) ? from->nCcalls : 0)); |
| 711 | lua_unlock(L); |
| 712 | return status; |
| 713 | } |
| 714 | |
| 715 | |
| 716 | LUA_API int lua_isyieldable(lua_State *L) { |
no test coverage detected