| 533 | |
| 534 | |
| 535 | LUA_API int lua_resume (lua_State *L, lua_State *from, int nargs) { |
| 536 | int status; |
| 537 | int oldnny = L->nny; /* save 'nny' */ |
| 538 | lua_lock(L); |
| 539 | luai_userstateresume(L, nargs); |
| 540 | L->nCcalls = (from) ? from->nCcalls + 1 : 1; |
| 541 | L->nny = 0; /* allow yields */ |
| 542 | api_checknelems(L, (L->status == LUA_OK) ? nargs + 1 : nargs); |
| 543 | status = luaD_rawrunprotected(L, resume, L->top - nargs); |
| 544 | if (status == -1) /* error calling 'lua_resume'? */ |
| 545 | status = LUA_ERRRUN; |
| 546 | else { /* yield or regular error */ |
| 547 | while (status != LUA_OK && status != LUA_YIELD) { /* error? */ |
| 548 | if (recover(L, status)) /* recover point? */ |
| 549 | status = luaD_rawrunprotected(L, unroll, NULL); /* run continuation */ |
| 550 | else { /* unrecoverable error */ |
| 551 | L->status = cast_byte(status); /* mark thread as `dead' */ |
| 552 | seterrorobj(L, status, L->top); |
| 553 | L->ci->top = L->top; |
| 554 | break; |
| 555 | } |
| 556 | } |
| 557 | lua_assert(status == L->status); |
| 558 | } |
| 559 | L->nny = oldnny; /* restore 'nny' */ |
| 560 | L->nCcalls--; |
| 561 | lua_assert(L->nCcalls == ((from) ? from->nCcalls : 0)); |
| 562 | lua_unlock(L); |
| 563 | return status; |
| 564 | } |
| 565 | |
| 566 | |
| 567 | LUA_API int lua_yieldk (lua_State *L, int nresults, int ctx, lua_CFunction k) { |
no test coverage detected