| 719 | } |
| 720 | |
| 721 | int 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 | |
| 755 | void LuaEngine::propagateErrorWithTraceback(lua_State* from, lua_State* to) { |
| 756 | if (const char* error = lua_tostring(from, -1)) { |
nothing calls this directly
no test coverage detected