MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / coresumeWithTraceback

Method coresumeWithTraceback

source/core/StarLua.cpp:721–753  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

719}
720
721int LuaEngine::coresumeWithTraceback(lua_State* state) {
722 lua_State* co = lua_tothread(state, 1);
723 if (!co) {
724 lua_checkstack(state, 2);
725 lua_pushboolean(state, 0);
726 lua_pushliteral(state, "bad argument #1 to 'resume' (thread expected)");
727 return 2;
728 }
729
730 int args = lua_gettop(state) - 1;
731 lua_checkstack(co, args);
732 if (lua_status(co) == LUA_OK && lua_gettop(co) == 0) {
733 lua_checkstack(state, 2);
734 lua_pushboolean(state, 0);
735 lua_pushliteral(state, "cannot resume dead coroutine");
736 return 2;
737 }
738
739 lua_xmove(state, co, args);
740 int status = lua_resume(co, state, args);
741 if (status == LUA_OK || status == LUA_YIELD) {
742 int res = lua_gettop(co);
743 lua_checkstack(state, res + 1);
744 lua_pushboolean(state, 1);
745 lua_xmove(co, state, res);
746 return res + 1;
747 } else {
748 lua_checkstack(state, 2);
749 lua_pushboolean(state, 0);
750 propagateErrorWithTraceback(co, state);
751 return 2;
752 }
753}
754
755void LuaEngine::propagateErrorWithTraceback(lua_State* from, lua_State* to) {
756 if (const char* error = lua_tostring(from, -1)) {

Callers

nothing calls this directly

Calls 7

lua_tothreadFunction · 0.85
lua_checkstackFunction · 0.85
lua_pushbooleanFunction · 0.85
lua_gettopFunction · 0.85
lua_statusFunction · 0.85
lua_xmoveFunction · 0.85
lua_resumeFunction · 0.85

Tested by

no test coverage detected