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