MCPcopy Create free account
hub / github.com/ObEngine/ObEngine / resume

Function resume

extlibs/lua/src/ldo.c:637–660  ·  view source on GitHub ↗

** 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. */

Source from the content-addressed store, hash-verified

635** coroutine.
636*/
637static 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
662LUA_API int lua_resume (lua_State *L, lua_State *from, int nargs,
663 int *nresults) {

Callers

nothing calls this directly

Calls 4

luaD_callFunction · 0.85
luaV_executeFunction · 0.85
luaD_poscallFunction · 0.85
unrollFunction · 0.85

Tested by

no test coverage detected