diff options
Diffstat (limited to '')
-rw-r--r-- | src/intercopycontext.cpp | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/src/intercopycontext.cpp b/src/intercopycontext.cpp index 6684f3f..67e4e03 100644 --- a/src/intercopycontext.cpp +++ b/src/intercopycontext.cpp | |||
@@ -29,6 +29,7 @@ THE SOFTWARE. | |||
29 | #include "debugspew.h" | 29 | #include "debugspew.h" |
30 | #include "deep.h" | 30 | #include "deep.h" |
31 | #include "keeper.h" | 31 | #include "keeper.h" |
32 | #include "linda.h" | ||
32 | #include "universe.h" | 33 | #include "universe.h" |
33 | 34 | ||
34 | // ################################################################################################# | 35 | // ################################################################################################# |
@@ -263,10 +264,10 @@ void InterCopyContext::copy_func() const | |||
263 | for (_n = 0; (_c.name = lua_getupvalue(L1, L1_i, 1 + _n)) != nullptr; ++_n) { // L1: ... _G up[n] | 264 | for (_n = 0; (_c.name = lua_getupvalue(L1, L1_i, 1 + _n)) != nullptr; ++_n) { // L1: ... _G up[n] |
264 | DEBUGSPEW_CODE(DebugSpew(U) << "UPNAME[" << _n << "]: " << _c.name << " -> "); | 265 | DEBUGSPEW_CODE(DebugSpew(U) << "UPNAME[" << _n << "]: " << _c.name << " -> "); |
265 | if (lua_rawequal(L1, -1, -2)) { // is the upvalue equal to the global table? | 266 | if (lua_rawequal(L1, -1, -2)) { // is the upvalue equal to the global table? |
266 | DEBUGSPEW_CODE(DebugSpew(U) << "pushing destination global scope" << std::endl); | 267 | DEBUGSPEW_CODE(DebugSpew(nullptr) << "pushing destination global scope" << std::endl); |
267 | lua_pushglobaltable(L2); // L2: ... {cache} ... function <upvalues> | 268 | lua_pushglobaltable(L2); // L2: ... {cache} ... function <upvalues> |
268 | } else { | 269 | } else { |
269 | DEBUGSPEW_CODE(DebugSpew(U) << "copying value" << std::endl); | 270 | DEBUGSPEW_CODE(DebugSpew(nullptr) << "copying value" << std::endl); |
270 | _c.L1_i = SourceIndex{ lua_gettop(L1) }; | 271 | _c.L1_i = SourceIndex{ lua_gettop(L1) }; |
271 | if (!_c.inter_copy_one()) { // L2: ... {cache} ... function <upvalues> | 272 | if (!_c.inter_copy_one()) { // L2: ... {cache} ... function <upvalues> |
272 | raise_luaL_error(getErrL(), "Cannot copy upvalue type '%s'", luaL_typename(L1, -1)); | 273 | raise_luaL_error(getErrL(), "Cannot copy upvalue type '%s'", luaL_typename(L1, -1)); |
@@ -874,13 +875,28 @@ void InterCopyContext::inter_copy_keyvaluepair() const | |||
874 | [[nodiscard]] bool InterCopyContext::inter_copy_lightuserdata() const | 875 | [[nodiscard]] bool InterCopyContext::inter_copy_lightuserdata() const |
875 | { | 876 | { |
876 | void* const _p{ lua_touserdata(L1, L1_i) }; | 877 | void* const _p{ lua_touserdata(L1, L1_i) }; |
877 | // TODO: recognize and print known UniqueKey names here | 878 | // recognize and print known UniqueKey names here |
878 | DEBUGSPEW_CODE(DebugSpew(nullptr) << _p << std::endl); | 879 | if constexpr (USE_DEBUG_SPEW()) { |
880 | bool _found{ false }; | ||
881 | static constexpr std::array<std::reference_wrapper<UniqueKey const>, 3> kKeysToCheck{ kLindaBatched, kCancelError, kNilSentinel }; | ||
882 | for (UniqueKey const& _key : kKeysToCheck) { | ||
883 | if (_key.equals(L1, L1_i)) { | ||
884 | DEBUGSPEW_CODE(DebugSpew(nullptr) << _key.debugName); | ||
885 | _found = true; | ||
886 | break; | ||
887 | } | ||
888 | } | ||
889 | if (!_found) { | ||
890 | DEBUGSPEW_CODE(DebugSpew(nullptr) << _p); | ||
891 | } | ||
892 | } | ||
879 | // when copying a nil sentinel in a non-keeper, write a nil in the destination | 893 | // when copying a nil sentinel in a non-keeper, write a nil in the destination |
880 | if (mode != LookupMode::ToKeeper && kNilSentinel.equals(L1, L1_i)) { | 894 | if (mode != LookupMode::ToKeeper && kNilSentinel.equals(L1, L1_i)) { |
895 | DEBUGSPEW_CODE(DebugSpew(nullptr) << " as nil" << std::endl); | ||
881 | lua_pushnil(L2); | 896 | lua_pushnil(L2); |
882 | } else { | 897 | } else { |
883 | lua_pushlightuserdata(L2, _p); | 898 | lua_pushlightuserdata(L2, _p); |
899 | DEBUGSPEW_CODE(DebugSpew(nullptr) << std::endl); | ||
884 | } | 900 | } |
885 | return true; | 901 | return true; |
886 | } | 902 | } |