diff options
Diffstat (limited to 'src/lane.cpp')
-rw-r--r-- | src/lane.cpp | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/src/lane.cpp b/src/lane.cpp index 4b6500a..7650d6b 100644 --- a/src/lane.cpp +++ b/src/lane.cpp | |||
@@ -254,7 +254,6 @@ static int thread_index_number(lua_State* L_) | |||
254 | if (!lua_isnil(L_, -1)) { // an error was stored // L_: lane n {uv} <error> | 254 | if (!lua_isnil(L_, -1)) { // an error was stored // L_: lane n {uv} <error> |
255 | lua_getmetatable(L_, 1); // L_: lane n {uv} <error> {mt} | 255 | lua_getmetatable(L_, 1); // L_: lane n {uv} <error> {mt} |
256 | lua_replace(L_, -3); // L_: lane n {mt} <error> | 256 | lua_replace(L_, -3); // L_: lane n {mt} <error> |
257 | #if LUA_VERSION_NUM == 501 | ||
258 | // Note: Lua 5.1 interpreter is not prepared to show | 257 | // Note: Lua 5.1 interpreter is not prepared to show |
259 | // non-string errors, so we use 'tostring()' here | 258 | // non-string errors, so we use 'tostring()' here |
260 | // to get meaningful output. --AKa 22-Jan-2009 | 259 | // to get meaningful output. --AKa 22-Jan-2009 |
@@ -266,13 +265,14 @@ static int thread_index_number(lua_State* L_) | |||
266 | // Level 3 should show the line where 'h[x]' was read | 265 | // Level 3 should show the line where 'h[x]' was read |
267 | // but this only seems to work for string messages | 266 | // but this only seems to work for string messages |
268 | // (Lua 5.1.4). No idea, why. --AKa 22-Jan-2009 | 267 | // (Lua 5.1.4). No idea, why. --AKa 22-Jan-2009 |
269 | if (!lua_isstring(L_, -1)) { | 268 | if constexpr (LUA_VERSION_NUM == 501) { |
270 | kCachedTostring.pushKey(L_); // L_: lane n {mt} <error> kCachedTostring | 269 | if (!lua_isstring(L_, -1)) { |
271 | lua_rawget(L_, -3); // L_: lane n {mt} <error> tostring() | 270 | kCachedTostring.pushKey(L_); // L_: lane n {mt} <error> kCachedTostring |
272 | lua_insert(L_, -2); // L_: lane n {mt} tostring() <error> | 271 | lua_rawget(L_, -3); // L_: lane n {mt} <error> tostring() |
273 | lua_call(L_, 1, 1); // tostring(errstring) // L_: lane n {mt} "error" | 272 | lua_insert(L_, -2); // L_: lane n {mt} tostring() <error> |
273 | lua_call(L_, 1, 1); // tostring(errstring) // L_: lane n {mt} "error" | ||
274 | } | ||
274 | } | 275 | } |
275 | #endif // LUA_VERSION_NUM == 501 | ||
276 | kCachedError.pushKey(L_); // L_: lane n {mt} "error" kCachedError | 276 | kCachedError.pushKey(L_); // L_: lane n {mt} "error" kCachedError |
277 | lua_rawget(L_, -3); // L_: lane n {mt} "error" error() | 277 | lua_rawget(L_, -3); // L_: lane n {mt} "error" error() |
278 | lua_replace(L_, -3); // L_: lane n error() "error" | 278 | lua_replace(L_, -3); // L_: lane n error() "error" |
@@ -784,20 +784,14 @@ Lane::Lane(Universe* U_, lua_State* L_, ErrorTraceLevel errorTraceLevel_) | |||
784 | { | 784 | { |
785 | assert(errorTraceLevel == ErrorTraceLevel::Minimal || errorTraceLevel == ErrorTraceLevel::Basic || errorTraceLevel == ErrorTraceLevel::Extended); | 785 | assert(errorTraceLevel == ErrorTraceLevel::Minimal || errorTraceLevel == ErrorTraceLevel::Basic || errorTraceLevel == ErrorTraceLevel::Extended); |
786 | kExtendedStackTraceRegKey.setValue(L_, [yes = errorTraceLevel == ErrorTraceLevel::Extended ? 1 : 0](lua_State* L_) { lua_pushboolean(L_, yes); }); | 786 | kExtendedStackTraceRegKey.setValue(L_, [yes = errorTraceLevel == ErrorTraceLevel::Extended ? 1 : 0](lua_State* L_) { lua_pushboolean(L_, yes); }); |
787 | #if HAVE_LANE_TRACKING() | ||
788 | U->tracker.tracking_add(this); | 787 | U->tracker.tracking_add(this); |
789 | #endif // HAVE_LANE_TRACKING() | ||
790 | } | 788 | } |
791 | 789 | ||
792 | // ################################################################################################# | 790 | // ################################################################################################# |
793 | 791 | ||
794 | Lane::~Lane() | 792 | Lane::~Lane() |
795 | { | 793 | { |
796 | // Clean up after a (finished) thread | ||
797 | // | ||
798 | #if HAVE_LANE_TRACKING() | ||
799 | std::ignore = U->tracker.tracking_remove(this); | 794 | std::ignore = U->tracker.tracking_remove(this); |
800 | #endif // HAVE_LANE_TRACKING() | ||
801 | } | 795 | } |
802 | 796 | ||
803 | // ################################################################################################# | 797 | // ################################################################################################# |