MCPcopy Create free account
hub / github.com/CppCXY/EmmyLuaCodeStyle / lua_resume

Function lua_resume

3rd/lua-5.4.3/src/ldo.c:773–802  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

771
772
773LUA_API int lua_resume (lua_State *L, lua_State *from, int nargs,
774 int *nresults) {
775 int status;
776 lua_lock(L);
777 if (L->status == LUA_OK) { /* may be starting a coroutine */
778 if (L->ci != &L->base_ci) /* not in base level? */
779 return resume_error(L, "cannot resume non-suspended coroutine", nargs);
780 else if (L->top - (L->ci->func + 1) == nargs) /* no function? */
781 return resume_error(L, "cannot resume dead coroutine", nargs);
782 }
783 else if (L->status != LUA_YIELD) /* ended with errors? */
784 return resume_error(L, "cannot resume dead coroutine", nargs);
785 L->nCcalls = (from) ? getCcalls(from) : 0;
786 luai_userstateresume(L, nargs);
787 api_checknelems(L, (L->status == LUA_OK) ? nargs + 1 : nargs);
788 status = luaD_rawrunprotected(L, resume, &nargs);
789 /* continue running after recoverable errors */
790 status = precover(L, status);
791 if (l_likely(!errorstatus(status)))
792 lua_assert(status == L->status); /* normal end or yield */
793 else { /* unrecoverable error */
794 L->status = cast_byte(status); /* mark thread as 'dead' */
795 luaD_seterrorobj(L, status, L->top); /* push error message */
796 L->ci->top = L->top;
797 }
798 *nresults = (status == LUA_YIELD) ? L->ci->u2.nyield
799 : cast_int(L->top - (L->ci->func + 1));
800 lua_unlock(L);
801 return status;
802}
803
804
805LUA_API int lua_isyieldable (lua_State *L) {

Callers 1

auxresumeFunction · 0.85

Calls 4

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

Tested by

no test coverage detected