aboutsummaryrefslogtreecommitdiff
path: root/src/MoonP/moon_compiler.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/MoonP/moon_compiler.cpp')
-rw-r--r--src/MoonP/moon_compiler.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/MoonP/moon_compiler.cpp b/src/MoonP/moon_compiler.cpp
index a3ed4de..1283422 100644
--- a/src/MoonP/moon_compiler.cpp
+++ b/src/MoonP/moon_compiler.cpp
@@ -49,7 +49,7 @@ inline std::string s(std::string_view sv) {
49} 49}
50 50
51const std::string_view version() { 51const std::string_view version() {
52 return "0.4.1"sv; 52 return "0.4.3"sv;
53} 53}
54 54
55// name of table stored in lua registry 55// name of table stored in lua registry
@@ -134,12 +134,13 @@ public:
134 if (_useModule) { 134 if (_useModule) {
135 _useModule = false; 135 _useModule = false;
136 if (!_sameModule) { 136 if (!_sameModule) {
137 int top = lua_gettop(L);
138 DEFER(lua_settop(L, top));
137 lua_pushliteral(L, MOONP_MODULE); // MOONP_MODULE 139 lua_pushliteral(L, MOONP_MODULE); // MOONP_MODULE
138 lua_rawget(L, LUA_REGISTRYINDEX); // reg[MOONP_MODULE], tb 140 lua_rawget(L, LUA_REGISTRYINDEX); // reg[MOONP_MODULE], tb
139 int idx = static_cast<int>(lua_objlen(L, -1)); 141 int idx = static_cast<int>(lua_objlen(L, -1));
140 lua_pushnil(L); // tb nil 142 lua_pushnil(L); // tb nil
141 lua_rawseti(L, -2, idx); // tb[idx] = nil, tb 143 lua_rawseti(L, -2, idx); // tb[idx] = nil, tb
142 lua_pop(L, 1); // empty
143 } 144 }
144 } 145 }
145 } 146 }
@@ -2982,7 +2983,7 @@ private:
2982 break; 2983 break;
2983 case id<Exp_t>(): 2984 case id<Exp_t>():
2984 transformExp(static_cast<Exp_t*>(item), temp, ExpUsage::Closure); 2985 transformExp(static_cast<Exp_t*>(item), temp, ExpUsage::Closure);
2985 temp.back() = s("["sv) + temp.back() + s("]"sv); 2986 temp.back() = s(temp.back().front() == '[' ? "[ "sv : "["sv) + temp.back() + s("]"sv);
2986 break; 2987 break;
2987 case id<InvokeArgs_t>(): transformInvokeArgs(static_cast<InvokeArgs_t*>(item), temp); break; 2988 case id<InvokeArgs_t>(): transformInvokeArgs(static_cast<InvokeArgs_t*>(item), temp); break;
2988 default: assert(false); break; 2989 default: assert(false); break;
@@ -3822,6 +3823,9 @@ private:
3822 case id<SingleString_t>(): transformSingleString(static_cast<SingleString_t*>(key), temp); 3823 case id<SingleString_t>(): transformSingleString(static_cast<SingleString_t*>(key), temp);
3823 temp.back() = s("["sv) + temp.back() + s("]"sv); 3824 temp.back() = s("["sv) + temp.back() + s("]"sv);
3824 break; 3825 break;
3826 case id<LuaString_t>(): transformLuaString(static_cast<LuaString_t*>(key), temp);
3827 temp.back() = s("[ "sv) + temp.back() + s("]"sv);
3828 break;
3825 default: assert(false); break; 3829 default: assert(false); break;
3826 } 3830 }
3827 auto value = pair->value.get(); 3831 auto value = pair->value.get();