MCPcopy Create free account
hub / github.com/ArduPilot/ardupilot / lua_resume

Function lua_resume

libraries/AP_Scripting/lua/src/ldo.c:657–693  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 1

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