From 18ab2be6ddaf5beb86e429cce9a3e1b4b5703b42 Mon Sep 17 00:00:00 2001 From: Benoit Germain Date: Fri, 24 May 2024 08:59:08 +0200 Subject: Process upvalues equal to G_ in Lua51 as in other flavors --- src/lane.cpp | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) (limited to 'src/lane.cpp') 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_) if (!lua_isnil(L_, -1)) { // an error was stored // L_: lane n {uv} lua_getmetatable(L_, 1); // L_: lane n {uv} {mt} lua_replace(L_, -3); // L_: lane n {mt} -#if LUA_VERSION_NUM == 501 // Note: Lua 5.1 interpreter is not prepared to show // non-string errors, so we use 'tostring()' here // to get meaningful output. --AKa 22-Jan-2009 @@ -266,13 +265,14 @@ static int thread_index_number(lua_State* L_) // Level 3 should show the line where 'h[x]' was read // but this only seems to work for string messages // (Lua 5.1.4). No idea, why. --AKa 22-Jan-2009 - if (!lua_isstring(L_, -1)) { - kCachedTostring.pushKey(L_); // L_: lane n {mt} kCachedTostring - lua_rawget(L_, -3); // L_: lane n {mt} tostring() - lua_insert(L_, -2); // L_: lane n {mt} tostring() - lua_call(L_, 1, 1); // tostring(errstring) // L_: lane n {mt} "error" + if constexpr (LUA_VERSION_NUM == 501) { + if (!lua_isstring(L_, -1)) { + kCachedTostring.pushKey(L_); // L_: lane n {mt} kCachedTostring + lua_rawget(L_, -3); // L_: lane n {mt} tostring() + lua_insert(L_, -2); // L_: lane n {mt} tostring() + lua_call(L_, 1, 1); // tostring(errstring) // L_: lane n {mt} "error" + } } -#endif // LUA_VERSION_NUM == 501 kCachedError.pushKey(L_); // L_: lane n {mt} "error" kCachedError lua_rawget(L_, -3); // L_: lane n {mt} "error" error() lua_replace(L_, -3); // L_: lane n error() "error" @@ -784,20 +784,14 @@ Lane::Lane(Universe* U_, lua_State* L_, ErrorTraceLevel errorTraceLevel_) { assert(errorTraceLevel == ErrorTraceLevel::Minimal || errorTraceLevel == ErrorTraceLevel::Basic || errorTraceLevel == ErrorTraceLevel::Extended); kExtendedStackTraceRegKey.setValue(L_, [yes = errorTraceLevel == ErrorTraceLevel::Extended ? 1 : 0](lua_State* L_) { lua_pushboolean(L_, yes); }); -#if HAVE_LANE_TRACKING() U->tracker.tracking_add(this); -#endif // HAVE_LANE_TRACKING() } // ################################################################################################# Lane::~Lane() { - // Clean up after a (finished) thread - // -#if HAVE_LANE_TRACKING() std::ignore = U->tracker.tracking_remove(this); -#endif // HAVE_LANE_TRACKING() } // ################################################################################################# -- cgit v1.2.3-55-g6feb