MCPcopy Create free account
hub / github.com/DFHack/dfhack / lua_resume

Function lua_resume

depends/lua/src/ldo.c:648–684  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

646
647
648LUA_API int lua_resume (lua_State *L, lua_State *from, int nargs) {
649 int status;
650 unsigned short oldnny = L->nny; /* save "number of non-yieldable" calls */
651 lua_lock(L);
652 if (L->status == LUA_OK) { /* may be starting a coroutine */
653 if (L->ci != &L->base_ci) /* not in base level? */
654 return resume_error(L, "cannot resume non-suspended coroutine", nargs);
655 }
656 else if (L->status != LUA_YIELD)
657 return resume_error(L, "cannot resume dead coroutine", nargs);
658 L->nCcalls = (from) ? from->nCcalls + 1 : 1;
659 if (L->nCcalls >= LUAI_MAXCCALLS)
660 return resume_error(L, "C stack overflow", nargs);
661 luai_userstateresume(L, nargs);
662 L->nny = 0; /* allow yields */
663 api_checknelems(L, (L->status == LUA_OK) ? nargs + 1 : nargs);
664 status = luaD_rawrunprotected(L, resume, &nargs);
665 if (status == -1) /* error calling 'lua_resume'? */
666 status = LUA_ERRRUN;
667 else { /* continue running after recoverable errors */
668 while (errorstatus(status) && recover(L, status)) {
669 /* unroll continuation */
670 status = luaD_rawrunprotected(L, unroll, &status);
671 }
672 if (errorstatus(status)) { /* unrecoverable error? */
673 L->status = cast_byte(status); /* mark thread as 'dead' */
674 seterrorobj(L, status, L->top); /* push error message */
675 L->ci->top = L->top;
676 }
677 else lua_assert(status == L->status); /* normal end or yield */
678 }
679 L->nny = oldnny; /* restore 'nny' */
680 L->nCcalls--;
681 lua_assert(L->nCcalls == ((from) ? from->nCcalls : 0));
682 lua_unlock(L);
683 return status;
684}
685
686
687LUA_API int lua_isyieldable (lua_State *L) {

Callers 2

resume_helperFunction · 0.85
auxresumeFunction · 0.85

Calls 4

resume_errorFunction · 0.85
luaD_rawrunprotectedFunction · 0.85
recoverFunction · 0.85
seterrorobjFunction · 0.85

Tested by

no test coverage detected