From 10afeaf30bfe03774c12908235520eebf0c192ee Mon Sep 17 00:00:00 2001 From: Li Jin Date: Mon, 25 Apr 2022 13:19:26 +0800 Subject: add spread syntax support for table block. fix a gcc compiler issue. update doc. --- spec/inputs/return.yue | 13 +++++++++++ spec/inputs/tables.yue | 23 +++++++++++++++++++ spec/outputs/return.lua | 24 +++++++++++++++++++ spec/outputs/tables.lua | 61 +++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 121 insertions(+) (limited to 'spec') diff --git a/spec/inputs/return.yue b/spec/inputs/return.yue index f170ffd..96fa0cd 100644 --- a/spec/inputs/return.yue +++ b/spec/inputs/return.yue @@ -49,6 +49,19 @@ do else b +do + return + :value + itemA: 123 + itemB: "abc" + +do + return + * 1 + * 2 + * ...three + * 4 + _ = -> a\b do a\b diff --git a/spec/inputs/tables.yue b/spec/inputs/tables.yue index 3a245a7..e1b9e1d 100644 --- a/spec/inputs/tables.yue +++ b/spec/inputs/tables.yue @@ -281,5 +281,28 @@ specializedB = { else: false } +parts = + * "shoulders" + * "knees" + +lyrics = + * "head" + * ...parts + * "and" + * "toes" + +tbBlock = + sub: + :value + * ...items + * ... + +func + * ...items + :value + * ... + k: v + * ... + nil diff --git a/spec/outputs/return.lua b/spec/outputs/return.lua index 0735b23..775ae11 100644 --- a/spec/outputs/return.lua +++ b/spec/outputs/return.lua @@ -86,6 +86,30 @@ do end end end +do + return { + value = value, + itemA = 123, + itemB = "abc" + } +end +do + local _tab_0 = { + 1, + 2 + } + local _idx_0 = 1 + for _key_0, _value_0 in pairs(three) do + if _idx_0 == _key_0 then + _tab_0[#_tab_0 + 1] = _value_0 + _idx_0 = _idx_0 + 1 + else + _tab_0[_key_0] = _value_0 + end + end + _tab_0[#_tab_0 + 1] = 4 + return _tab_0 +end _ = function() local _base_0 = a local _fn_0 = _base_0.b diff --git a/spec/outputs/tables.lua b/spec/outputs/tables.lua index 165706d..1d28a43 100644 --- a/spec/outputs/tables.lua +++ b/spec/outputs/tables.lua @@ -527,4 +527,65 @@ do _tab_0["else"] = false specializedB = _tab_0 end +local parts = { + "shoulders", + "knees" +} +local lyrics +do + local _tab_0 = { + "head" + } + local _idx_0 = 1 + for _key_0, _value_0 in pairs(parts) do + if _idx_0 == _key_0 then + _tab_0[#_tab_0 + 1] = _value_0 + _idx_0 = _idx_0 + 1 + else + _tab_0[_key_0] = _value_0 + end + end + _tab_0[#_tab_0 + 1] = "and" + _tab_0[#_tab_0 + 1] = "toes" + lyrics = _tab_0 +end +local tbBlock = { + sub = (function(...) + local _tab_0 = { + value = value + } + local _idx_0 = 1 + for _key_0, _value_0 in pairs(items) do + if _idx_0 == _key_0 then + _tab_0[#_tab_0 + 1] = _value_0 + _idx_0 = _idx_0 + 1 + else + _tab_0[_key_0] = _value_0 + end + end + for _index_0 = 1, select('#', ...) do + _tab_0[#_tab_0 + 1] = select(_index_0, ...) + end + return _tab_0 + end)(...) +} +func((function(...) + local _tab_0 = { } + local _idx_0 = 1 + for _key_0, _value_0 in pairs(items) do + if _idx_0 == _key_0 then + _tab_0[#_tab_0 + 1] = _value_0 + _idx_0 = _idx_0 + 1 + else + _tab_0[_key_0] = _value_0 + end + end + _tab_0.value = value + _tab_0[#_tab_0 + 1] = ... + _tab_0.k = v + for _index_0 = 1, select('#', ...) do + _tab_0[#_tab_0 + 1] = select(_index_0, ...) + end + return _tab_0 +end)(...)) return nil -- cgit v1.2.3-55-g6feb