| 569 | |
| 570 | |
| 571 | LUA_API int lua_resume (lua_State *L, lua_State *from, int nargs) { |
| 572 | int status; |
| 573 | int oldnny = L->nny; /* save "number of non-yieldable" calls */ |
| 574 | lua_lock(L); |
| 575 | luai_userstateresume(L, nargs); |
| 576 | L->nCcalls = (from) ? from->nCcalls + 1 : 1; |
| 577 | L->nny = 0; /* allow yields */ |
| 578 | api_checknelems(L, (L->status == LUA_OK) ? nargs + 1 : nargs); |
| 579 | status = luaD_rawrunprotected(L, resume, L->top - nargs); |
| 580 | if (status == -1) /* error calling 'lua_resume'? */ |
| 581 | status = LUA_ERRRUN; |
| 582 | else { /* continue running after recoverable errors */ |
| 583 | while (errorstatus(status) && recover(L, status)) { |
| 584 | /* unroll continuation */ |
| 585 | status = luaD_rawrunprotected(L, unroll, &status); |
| 586 | } |
| 587 | if (errorstatus(status)) { /* unrecoverable error? */ |
| 588 | L->status = cast_byte(status); /* mark thread as 'dead' */ |
| 589 | seterrorobj(L, status, L->top); /* push error message */ |
| 590 | L->ci->top = L->top; |
| 591 | } |
| 592 | else lua_assert(status == L->status); /* normal end or yield */ |
| 593 | } |
| 594 | L->nny = oldnny; /* restore 'nny' */ |
| 595 | L->nCcalls--; |
| 596 | lua_assert(L->nCcalls == ((from) ? from->nCcalls : 0)); |
| 597 | lua_unlock(L); |
| 598 | return status; |
| 599 | } |
| 600 | |
| 601 | |
| 602 | LUA_API int lua_isyieldable (lua_State *L) { |
no test coverage detected