MCPcopy Create free account
hub / github.com/SakuraEngine/SakuraEngine / lua_resume

Function lua_resume

xrepo/packages/l/lua/port/lua/src/ldo.c:804–836  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

802
803
804LUA_API int lua_resume (lua_State *L, lua_State *from, int nargs,
805 int *nresults) {
806 int status;
807 lua_lock(L);
808 if (L->status == LUA_OK) { /* may be starting a coroutine */
809 if (L->ci != &L->base_ci) /* not in base level? */
810 return resume_error(L, "cannot resume non-suspended coroutine", nargs);
811 else if (L->top - (L->ci->func + 1) == nargs) /* no function? */
812 return resume_error(L, "cannot resume dead coroutine", nargs);
813 }
814 else if (L->status != LUA_YIELD) /* ended with errors? */
815 return resume_error(L, "cannot resume dead coroutine", nargs);
816 L->nCcalls = (from) ? getCcalls(from) : 0;
817 if (getCcalls(L) >= LUAI_MAXCCALLS)
818 return resume_error(L, "C stack overflow", nargs);
819 L->nCcalls++;
820 luai_userstateresume(L, nargs);
821 api_checknelems(L, (L->status == LUA_OK) ? nargs + 1 : nargs);
822 status = luaD_rawrunprotected(L, resume, &nargs);
823 /* continue running after recoverable errors */
824 status = precover(L, status);
825 if (l_likely(!errorstatus(status)))
826 lua_assert(status == L->status); /* normal end or yield */
827 else { /* unrecoverable error */
828 L->status = cast_byte(status); /* mark thread as 'dead' */
829 luaD_seterrorobj(L, status, L->top); /* push error message */
830 L->ci->top = L->top;
831 }
832 *nresults = (status == LUA_YIELD) ? L->ci->u2.nyield
833 : cast_int(L->top - (L->ci->func + 1));
834 lua_unlock(L);
835 return status;
836}
837
838
839LUA_API int lua_isyieldable (lua_State *L) {

Callers 1

auxresumeFunction · 0.70

Calls 4

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

Tested by

no test coverage detected