| 423 | |
| 424 | |
| 425 | LUA_API int lua_resume (lua_State *L, int nargs) { |
| 426 | int status; |
| 427 | lua_lock(L); |
| 428 | if (L->status != LUA_YIELD && (L->status != 0 || L->ci != L->base_ci)) |
| 429 | return resume_error(L, "cannot resume non-suspended coroutine"); |
| 430 | if (L->nCcalls >= LUAI_MAXCCALLS) |
| 431 | return resume_error(L, "C stack overflow"); |
| 432 | luai_userstateresume(L, nargs); |
| 433 | lua_assert(L->errfunc == 0); |
| 434 | L->baseCcalls = ++L->nCcalls; |
| 435 | status = luaD_rawrunprotected(L, resume, L->top - nargs); |
| 436 | if (status != 0) { /* error? */ |
| 437 | L->status = cast_byte(status); /* mark thread as `dead' */ |
| 438 | luaD_seterrorobj(L, status, L->top); |
| 439 | L->ci->top = L->top; |
| 440 | } |
| 441 | else { |
| 442 | lua_assert(L->nCcalls == L->baseCcalls); |
| 443 | status = L->status; |
| 444 | } |
| 445 | --L->nCcalls; |
| 446 | lua_unlock(L); |
| 447 | return status; |
| 448 | } |
| 449 | |
| 450 | |
| 451 | LUA_API int lua_yield (lua_State *L, int nresults) { |
no test coverage detected