** Do the work for 'lua_resume' in protected mode. Most of the work ** depends on the status of the coroutine: initial state, suspended ** inside a hook, or regularly suspended (optionally with a continuation ** function), plus erroneous cases: non-suspended coroutine or dead ** coroutine. */
| 635 | ** coroutine. |
| 636 | */ |
| 637 | static void resume (lua_State *L, void *ud) { |
| 638 | int n = *(cast(int*, ud)); /* number of arguments */ |
| 639 | StkId firstArg = L->top - n; /* first argument */ |
| 640 | CallInfo *ci = L->ci; |
| 641 | if (L->status == LUA_OK) { /* starting a coroutine? */ |
| 642 | luaD_call(L, firstArg - 1, LUA_MULTRET); |
| 643 | } |
| 644 | else { /* resuming from previous yield */ |
| 645 | lua_assert(L->status == LUA_YIELD); |
| 646 | L->status = LUA_OK; /* mark that it is running (again) */ |
| 647 | if (isLua(ci)) /* yielded inside a hook? */ |
| 648 | luaV_execute(L, ci); /* just continue running Lua code */ |
| 649 | else { /* 'common' yield */ |
| 650 | if (ci->u.c.k != NULL) { /* does it have a continuation function? */ |
| 651 | lua_unlock(L); |
| 652 | n = (*ci->u.c.k)(L, LUA_YIELD, ci->u.c.ctx); /* call continuation */ |
| 653 | lua_lock(L); |
| 654 | api_checknelems(L, n); |
| 655 | } |
| 656 | luaD_poscall(L, ci, n); /* finish 'luaD_call' */ |
| 657 | } |
| 658 | unroll(L, NULL); /* run continuation */ |
| 659 | } |
| 660 | } |
| 661 | |
| 662 | LUA_API int lua_resume (lua_State *L, lua_State *from, int nargs, |
| 663 | int *nresults) { |
nothing calls this directly
no test coverage detected