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

Function lua_resume

third-party/lua-5.4.6/src/ldo.c:842–874  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

840
841
842LUA_API int lua_resume (lua_State *L, lua_State *from, int nargs,
843 int *nresults) {
844 int status;
845 lua_lock(L);
846 if (L->status == LUA_OK) { /* may be starting a coroutine */
847 if (L->ci != &L->base_ci) /* not in base level? */
848 return resume_error(L, "cannot resume non-suspended coroutine", nargs);
849 else if (L->top.p - (L->ci->func.p + 1) == nargs) /* no function? */
850 return resume_error(L, "cannot resume dead coroutine", nargs);
851 }
852 else if (L->status != LUA_YIELD) /* ended with errors? */
853 return resume_error(L, "cannot resume dead coroutine", nargs);
854 L->nCcalls = (from) ? getCcalls(from) : 0;
855 if (getCcalls(L) >= LUAI_MAXCCALLS)
856 return resume_error(L, "C stack overflow", nargs);
857 L->nCcalls++;
858 luai_userstateresume(L, nargs);
859 api_checknelems(L, (L->status == LUA_OK) ? nargs + 1 : nargs);
860 status = luaD_rawrunprotected(L, resume, &nargs);
861 /* continue running after recoverable errors */
862 status = precover(L, status);
863 if (l_likely(!errorstatus(status)))
864 lua_assert(status == L->status); /* normal end or yield */
865 else { /* unrecoverable error */
866 L->status = cast_byte(status); /* mark thread as 'dead' */
867 luaD_seterrorobj(L, status, L->top.p); /* push error message */
868 L->ci->top.p = L->top.p;
869 }
870 *nresults = (status == LUA_YIELD) ? L->ci->u2.nyield
871 : cast_int(L->top.p - (L->ci->func.p + 1));
872 lua_unlock(L);
873 return status;
874}
875
876
877LUA_API int lua_isyieldable (lua_State *L) {

Callers 1

auxresumeFunction · 0.70

Calls 4

resume_errorFunction · 0.70
luaD_rawrunprotectedFunction · 0.70
precoverFunction · 0.70
luaD_seterrorobjFunction · 0.70

Tested by

no test coverage detected