From d1878f2b8eb1644205c5e0b641fd092e8b222766 Mon Sep 17 00:00:00 2001 From: Li Jin Date: Fri, 31 Jan 2025 23:17:45 +0800 Subject: Aligned Lua inserter macro behavior with common Yue macro. --- src/yuescript/yue_compiler.cpp | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/yuescript/yue_compiler.cpp b/src/yuescript/yue_compiler.cpp index 446414d..e7fe0c0 100644 --- a/src/yuescript/yue_compiler.cpp +++ b/src/yuescript/yue_compiler.cpp @@ -24,7 +24,6 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI extern "C" { #include "lauxlib.h" -#include "lparser.h" #include "lua.h" #include "lualib.h" } // extern "C" @@ -76,7 +75,7 @@ static std::unordered_set Metamethods = { "close"s // Lua 5.4 }; -const std::string_view version = "0.26.3"sv; +const std::string_view version = "0.27.0"sv; const std::string_view extension = "yue"sv; class CompileError : public std::logic_error { @@ -6567,17 +6566,10 @@ private: if (luaL_loadbuffer(L, codes.c_str(), codes.size(), macroChunk.c_str()) != 0) { std::string err = lua_tostring(L, -1); throw CompileError("lua macro is not expanding to valid block\n"s + err, x); - } else { - Proto* f = ((LClosure*)lua_topointer(L, -1))->p; - for (int i = 0; i < f->sizelocvars; i++) { - localVars.push_back(getstr(f->locvars[i].varname)); - } } if (!codes.empty()) { - if (_config.reserveLineNumber) { - codes.insert(0, nll(chainValue).substr(1)); - } - codes.append(nlr(chainValue)); + codes.insert(0, indent() + "do"s + nll(chainValue)); + codes.append(_newLine + indent() + "end"s + nlr(chainValue)); } return {nullptr, nullptr, std::move(codes), std::move(localVars)}; } else { -- cgit v1.2.3-55-g6feb