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. --- spec/outputs/ambiguous.lua | 4 +++- spec/outputs/codes_from_doc.lua | 18 ++++++++++++++---- spec/outputs/codes_from_doc_zh.lua | 14 ++++++++++++-- spec/outputs/macro.lua | 18 ++++++++++++++++++ spec/outputs/unicode/ambiguous.lua | 4 +++- spec/outputs/unicode/macro.lua | 14 ++++++++++++++ 6 files changed, 64 insertions(+), 8 deletions(-) (limited to 'spec') diff --git a/spec/outputs/ambiguous.lua b/spec/outputs/ambiguous.lua index 3c82a03..fc43d63 100644 --- a/spec/outputs/ambiguous.lua +++ b/spec/outputs/ambiguous.lua @@ -39,9 +39,11 @@ end do print() async_fn(function() - print(); + print() + do --[[a comment to insert]] (haha)() + end return nil end) end diff --git a/spec/outputs/codes_from_doc.lua b/spec/outputs/codes_from_doc.lua index 5c262d3..74db469 100644 --- a/spec/outputs/codes_from_doc.lua +++ b/spec/outputs/codes_from_doc.lua @@ -59,16 +59,21 @@ do end local funcA funcA = function() - return "fail to assign to the Yue defined variable" + return "fail to assign to the Yue macro defined variable" end +do local function funcB() end +end +local funcB funcB = function() - return "assign to the Lua defined variable" + return "fail to assign to the Lua macro defined variable" end +do -- raw Lua codes insertion if cond then print("output") end +end print("yuescript") print(3) print("Valid enum type:", "Static") @@ -2065,16 +2070,21 @@ do end local funcA funcA = function() - return "fail to assign to the Yue defined variable" + return "fail to assign to the Yue macro defined variable" end +do local function funcB() end +end +local funcB funcB = function() - return "assign to the Lua defined variable" + return "fail to assign to the Lua macro defined variable" end +do -- raw Lua codes insertion if cond then print("output") end +end print("yuescript") print(3) print("Valid enum type:", "Static") diff --git a/spec/outputs/codes_from_doc_zh.lua b/spec/outputs/codes_from_doc_zh.lua index c6d5388..1a10555 100644 --- a/spec/outputs/codes_from_doc_zh.lua +++ b/spec/outputs/codes_from_doc_zh.lua @@ -61,14 +61,19 @@ local funcA funcA = function() return "无法访问宏生成月之脚本里定义的变量" end +do local function funcB() end +end +local funcB funcB = function() - return "访问宏生成Lua代码里定义的变量" + return "无法访问宏生成 Lua 代码里定义的变量" end +do -- 插入原始Lua代码 if cond then print("输出") end +end print("yuescript") print(3) print("有效的枚举类型:", "Static") @@ -2061,14 +2066,19 @@ local funcA funcA = function() return "无法访问宏生成月之脚本里定义的变量" end +do local function funcB() end +end +local funcB funcB = function() - return "访问宏生成Lua代码里定义的变量" + return "无法访问宏生成 Lua 代码里定义的变量" end +do -- 插入原始Lua代码 if cond then print("输出") end +end print("yuescript") print(3) print("有效的枚举类型:", "Static") diff --git a/spec/outputs/macro.lua b/spec/outputs/macro.lua index 7163077..aa74ed9 100644 --- a/spec/outputs/macro.lua +++ b/spec/outputs/macro.lua @@ -5,7 +5,9 @@ do end print(456) do + do -- TODO: "todo in a do block" + end end end do @@ -201,13 +203,17 @@ do print(a) end local x = 0 +do local function f(a) return a + 1 end x = x + f(3) +end +do function tb:func() print(123) end +end print(x) local sel sel = function(a, b, c) @@ -217,6 +223,7 @@ sel = function(a, b, c) return c end end +do local function sel(a, b, c) if a then return b @@ -224,10 +231,15 @@ local function sel(a, b, c) return c end end +end +do local function dummy() end +end +do -- a comment here +end local _ = require('underscore') local a = ((((_({ 1, @@ -279,9 +291,11 @@ do _6:Destroy() end end +do origin.transform.root.gameObject:Parents():Descendants():SelectEnable():SelectVisible():TagEqual("fx"):Where(function(x) return x.name:EndsWith("(Clone)") end):Destroy() +end print((setmetatable({ 'abc', a = 123, @@ -313,7 +327,9 @@ print((setmetatable({ })) print("current line: " .. tostring(323)) do + do -- TODO + end end do print(1) @@ -336,7 +352,9 @@ do end local f1 f1 = function() + do tb:func(123) + end return end end diff --git a/spec/outputs/unicode/ambiguous.lua b/spec/outputs/unicode/ambiguous.lua index ac90016..704b311 100644 --- a/spec/outputs/unicode/ambiguous.lua +++ b/spec/outputs/unicode/ambiguous.lua @@ -39,9 +39,11 @@ end do _u6253_u5370() _u5f02_u6b65_u51fd_u6570(function() - _u6253_u5370(); + _u6253_u5370() + do --[[a comment to insert]] (haha)() + end return nil end) end diff --git a/spec/outputs/unicode/macro.lua b/spec/outputs/unicode/macro.lua index 069f429..e2195e4 100644 --- a/spec/outputs/unicode/macro.lua +++ b/spec/outputs/unicode/macro.lua @@ -179,13 +179,17 @@ do _u6253_u5370(_u53d8_u91cfa) end local _u53d8_u91cfx = 0 +do local function f(a) return a + 1 end x = x + f(3) +end +do function tb:func() print(123) end +end _u6253_u5370(_u53d8_u91cfx) local sel sel = function(_u53c2_u6570a, _u53c2_u6570b, _u53c2_u6570c) @@ -195,6 +199,7 @@ sel = function(_u53c2_u6570a, _u53c2_u6570b, _u53c2_u6570c) return _u53c2_u6570c end end +do local function sel(a, b, c) if a then return b @@ -202,10 +207,15 @@ local function sel(a, b, c) return c end end +end +do local function dummy() end +end +do -- 这有个注释 +end local _ = require('下划线') local _call_0 = (_({ 1, @@ -275,11 +285,13 @@ do _6["摧毁"](_6) end end +do local _call_0 = _u539f_u70b9["变换"]["根节点"]["游戏对象"] _call_0["父节点"](_call_0):_u540e_u4ee3():_u9009_u62e9_u542f_u7528():_u9009_u62e9_u53ef_u89c1():_u6807_u7b7e_u7b49_u4e8e("fx"):_u5176_u4e2d(function(x) local _call_0 = x["名称"] return _call_0["结尾为"](_call_0, "(克隆)") end):_u6467_u6bc1() +end _u6253_u5370((setmetatable({ 'abc', ["字段a"] = 123, @@ -311,7 +323,9 @@ _u6253_u5370((setmetatable({ })) _u6253_u5370("当前代码行数: " .. tostring(268)) do + do -- 待实现 + end end do _u6253_u5370(1) -- cgit v1.2.3-55-g6feb