MCPcopy Create free account
hub / github.com/EmmyLua/EmmyLuaDebugger / resume

Function resume

third-party/lua-5.4.6/src/ldo.c:792–820  ·  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

790** coroutine.
791*/
792static void resume (lua_State *L, void *ud) {
793 int n = *(cast(int*, ud)); /* number of arguments */
794 StkId firstArg = L->top.p - n; /* first argument */
795 CallInfo *ci = L->ci;
796 if (L->status == LUA_OK) /* starting a coroutine? */
797 ccall(L, firstArg - 1, LUA_MULTRET, 0); /* just call its body */
798 else { /* resuming from previous yield */
799 lua_assert(L->status == LUA_YIELD);
800 L->status = LUA_OK; /* mark that it is running (again) */
801 if (isLua(ci)) { /* yielded inside a hook? */
802 /* undo increment made by 'luaG_traceexec': instruction was not
803 executed yet */
804 lua_assert(ci->callstatus & CIST_HOOKYIELD);
805 ci->u.l.savedpc--;
806 L->top.p = firstArg; /* discard arguments */
807 luaV_execute(L, ci); /* just continue running Lua code */
808 }
809 else { /* 'common' yield */
810 if (ci->u.c.k != NULL) { /* does it have a continuation function? */
811 lua_unlock(L);
812 n = (*ci->u.c.k)(L, LUA_YIELD, ci->u.c.ctx); /* call continuation */
813 lua_lock(L);
814 api_checknelems(L, n);
815 }
816 luaD_poscall(L, ci, n); /* finish 'luaD_call' */
817 }
818 unroll(L, NULL); /* run continuation */
819 }
820}
821
822
823/*

Callers

nothing calls this directly

Calls 4

ccallFunction · 0.70
luaV_executeFunction · 0.70
luaD_poscallFunction · 0.70
unrollFunction · 0.70

Tested by

no test coverage detected