diff options
Diffstat (limited to 'src/lane.cpp')
-rw-r--r-- | src/lane.cpp | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/lane.cpp b/src/lane.cpp index ea3edb0..de513c2 100644 --- a/src/lane.cpp +++ b/src/lane.cpp | |||
@@ -46,7 +46,7 @@ static LUAG_FUNC(get_debug_threadname) | |||
46 | { | 46 | { |
47 | Lane* const _lane{ ToLane(L_, 1) }; | 47 | Lane* const _lane{ ToLane(L_, 1) }; |
48 | luaL_argcheck(L_, lua_gettop(L_) == 1, 2, "too many arguments"); | 48 | luaL_argcheck(L_, lua_gettop(L_) == 1, 2, "too many arguments"); |
49 | std::ignore = luaG_pushstringview(L_, _lane->debugName); | 49 | std::ignore = luaG_pushstring(L_, _lane->debugName); |
50 | return 1; | 50 | return 1; |
51 | } | 51 | } |
52 | 52 | ||
@@ -80,7 +80,7 @@ static LUAG_FUNC(set_finalizer) | |||
80 | static LUAG_FUNC(set_debug_threadname) | 80 | static LUAG_FUNC(set_debug_threadname) |
81 | { | 81 | { |
82 | // C s_lane structure is a light userdata upvalue | 82 | // C s_lane structure is a light userdata upvalue |
83 | Lane* const _lane{ lua_tolightuserdata<Lane>(L_, lua_upvalueindex(1)) }; | 83 | Lane* const _lane{ luaG_tolightuserdata<Lane>(L_, lua_upvalueindex(1)) }; |
84 | LUA_ASSERT(L_, L_ == _lane->L); // this function is exported in a lane's state, therefore it is callable only from inside the Lane's state | 84 | LUA_ASSERT(L_, L_ == _lane->L); // this function is exported in a lane's state, therefore it is callable only from inside the Lane's state |
85 | lua_settop(L_, 1); | 85 | lua_settop(L_, 1); |
86 | STACK_CHECK_START_REL(L_, 0); | 86 | STACK_CHECK_START_REL(L_, 0); |
@@ -300,7 +300,7 @@ static int thread_index_string(lua_State* L_) | |||
300 | Lane* const _lane{ ToLane(L_, kSelf) }; | 300 | Lane* const _lane{ ToLane(L_, kSelf) }; |
301 | LUA_ASSERT(L_, lua_gettop(L_) == 2); // L_: lane "key" | 301 | LUA_ASSERT(L_, lua_gettop(L_) == 2); // L_: lane "key" |
302 | 302 | ||
303 | std::string_view const _keystr{ luaG_tostringview(L_, kKey) }; | 303 | std::string_view const _keystr{ luaG_tostring(L_, kKey) }; |
304 | lua_settop(L_, 2); // keep only our original arguments on the stack | 304 | lua_settop(L_, 2); // keep only our original arguments on the stack |
305 | if (_keystr == "status") { | 305 | if (_keystr == "status") { |
306 | std::ignore = _lane->pushThreadStatus(L_); // L_: lane "key" "<status>" | 306 | std::ignore = _lane->pushThreadStatus(L_); // L_: lane "key" "<status>" |
@@ -462,9 +462,9 @@ static constexpr RegistryUniqueKey kStackTraceRegKey{ 0x3F327747CACAA904ull }; | |||
462 | lua_pushstring(L_, _ar.what); // L_: some_error {} {} what | 462 | lua_pushstring(L_, _ar.what); // L_: some_error {} {} what |
463 | lua_setfield(L_, -2, "what"); // L_: some_error {} {} | 463 | lua_setfield(L_, -2, "what"); // L_: some_error {} {} |
464 | } else if (_ar.currentline > 0) { | 464 | } else if (_ar.currentline > 0) { |
465 | std::ignore = luaG_pushstringview(L_, "%s:%d", _ar.short_src, _ar.currentline); // L_: some_error {} "blah:blah" | 465 | std::ignore = luaG_pushstring(L_, "%s:%d", _ar.short_src, _ar.currentline); // L_: some_error {} "blah:blah" |
466 | } else { | 466 | } else { |
467 | std::ignore = luaG_pushstringview(L_, "%s:?", _ar.short_src); // L_: some_error {} "blah" | 467 | std::ignore = luaG_pushstring(L_, "%s:?", _ar.short_src); // L_: some_error {} "blah" |
468 | } | 468 | } |
469 | lua_rawseti(L_, -2, static_cast<lua_Integer>(_n)); // L_: some_error {} | 469 | lua_rawseti(L_, -2, static_cast<lua_Integer>(_n)); // L_: some_error {} |
470 | } | 470 | } |
@@ -551,7 +551,7 @@ static void push_stack_trace(lua_State* L_, Lane::ErrorTraceLevel errorTraceLeve | |||
551 | LUA_ASSERT(L_, lua_isfunction(L_, -1)); | 551 | LUA_ASSERT(L_, lua_isfunction(L_, -1)); |
552 | if (lua_rc_ != LuaError::OK) { // we have an error message and an optional stack trace at the bottom of the stack | 552 | if (lua_rc_ != LuaError::OK) { // we have an error message and an optional stack trace at the bottom of the stack |
553 | LUA_ASSERT(L_, _finalizers_index == 2 || _finalizers_index == 3); | 553 | LUA_ASSERT(L_, _finalizers_index == 2 || _finalizers_index == 3); |
554 | //std::string_view const _err_msg{ luaG_tostringview(L_, 1) }; | 554 | //std::string_view const _err_msg{ luaG_tostring(L_, 1) }; |
555 | lua_pushvalue(L_, 1); // L_: ... finalizers lane_error finalizer err_msg | 555 | lua_pushvalue(L_, 1); // L_: ... finalizers lane_error finalizer err_msg |
556 | // note we don't always have a stack trace for example when kCancelError, or when we got an error that doesn't call our handler, such as LUA_ERRMEM | 556 | // note we don't always have a stack trace for example when kCancelError, or when we got an error that doesn't call our handler, such as LUA_ERRMEM |
557 | if (_finalizers_index == 3) { | 557 | if (_finalizers_index == 3) { |
@@ -745,7 +745,7 @@ static void lane_main(Lane* lane_) | |||
745 | lua_rawget(L_, -2); // L_: ud uservalue gc_cb|nil | 745 | lua_rawget(L_, -2); // L_: ud uservalue gc_cb|nil |
746 | if (!lua_isnil(L_, -1)) { | 746 | if (!lua_isnil(L_, -1)) { |
747 | lua_remove(L_, -2); // L_: ud gc_cb|nil | 747 | lua_remove(L_, -2); // L_: ud gc_cb|nil |
748 | std::ignore = luaG_pushstringview(L_, _lane->debugName); // L_: ud gc_cb name | 748 | std::ignore = luaG_pushstring(L_, _lane->debugName); // L_: ud gc_cb name |
749 | _have_gc_cb = true; | 749 | _have_gc_cb = true; |
750 | } else { | 750 | } else { |
751 | lua_pop(L_, 2); // L_: ud | 751 | lua_pop(L_, 2); // L_: ud |
@@ -810,7 +810,7 @@ void Lane::changeDebugName(int const nameIdx_) | |||
810 | // store a hidden reference in the registry to make sure the string is kept around even if a lane decides to manually change the "decoda_name" global... | 810 | // store a hidden reference in the registry to make sure the string is kept around even if a lane decides to manually change the "decoda_name" global... |
811 | kLaneNameRegKey.setValue(L, [idx = _nameIdx](lua_State* L_) { lua_pushvalue(L_, idx); }); // L: ... "name" ... | 811 | kLaneNameRegKey.setValue(L, [idx = _nameIdx](lua_State* L_) { lua_pushvalue(L_, idx); }); // L: ... "name" ... |
812 | // keep a direct pointer on the string | 812 | // keep a direct pointer on the string |
813 | debugName = luaG_tostringview(L, _nameIdx); | 813 | debugName = luaG_tostring(L, _nameIdx); |
814 | if constexpr (HAVE_DECODA_SUPPORT()) { | 814 | if constexpr (HAVE_DECODA_SUPPORT()) { |
815 | // to see VM name in Decoda debugger Virtual Machine window | 815 | // to see VM name in Decoda debugger Virtual Machine window |
816 | lua_pushvalue(L, _nameIdx); // L: ... "name" ... "name" | 816 | lua_pushvalue(L, _nameIdx); // L: ... "name" ... "name" |
@@ -897,7 +897,7 @@ void Lane::PushMetatable(lua_State* L_) | |||
897 | std::string_view const _str{ threadStatusString() }; | 897 | std::string_view const _str{ threadStatusString() }; |
898 | LUA_ASSERT(L_, !_str.empty()); | 898 | LUA_ASSERT(L_, !_str.empty()); |
899 | 899 | ||
900 | return luaG_pushstringview(L_, _str); | 900 | return luaG_pushstring(L_, _str); |
901 | } | 901 | } |
902 | 902 | ||
903 | // ################################################################################################# | 903 | // ################################################################################################# |
@@ -907,7 +907,7 @@ void Lane::PushMetatable(lua_State* L_) | |||
907 | std::string_view const _str{ errorTraceLevelString() }; | 907 | std::string_view const _str{ errorTraceLevelString() }; |
908 | LUA_ASSERT(L_, !_str.empty()); | 908 | LUA_ASSERT(L_, !_str.empty()); |
909 | 909 | ||
910 | return luaG_pushstringview(L_, _str); | 910 | return luaG_pushstring(L_, _str); |
911 | } | 911 | } |
912 | 912 | ||
913 | // ################################################################################################# | 913 | // ################################################################################################# |
@@ -922,7 +922,7 @@ void Lane::securizeDebugName(lua_State* L_) | |||
922 | LUA_ASSERT(L_, lua_istable(L_, -1)); | 922 | LUA_ASSERT(L_, lua_istable(L_, -1)); |
923 | // we don't care about the actual key, so long as it's unique and can't collide with anything. | 923 | // we don't care about the actual key, so long as it's unique and can't collide with anything. |
924 | lua_newtable(L_); // L_: lane ... {uv} {} | 924 | lua_newtable(L_); // L_: lane ... {uv} {} |
925 | debugName = luaG_pushstringview(L_, debugName); // L_: lane ... {uv} {} name | 925 | debugName = luaG_pushstring(L_, debugName); // L_: lane ... {uv} {} name |
926 | lua_rawset(L_, -3); // L_: lane ... {uv} | 926 | lua_rawset(L_, -3); // L_: lane ... {uv} |
927 | lua_pop(L_, 1); // L_: lane | 927 | lua_pop(L_, 1); // L_: lane |
928 | STACK_CHECK(L_, 0); | 928 | STACK_CHECK(L_, 0); |