diff options
| author | Li Jin <dragon-fly@qq.com> | 2022-04-25 13:19:26 +0800 |
|---|---|---|
| committer | Li Jin <dragon-fly@qq.com> | 2022-04-25 13:19:45 +0800 |
| commit | 10afeaf30bfe03774c12908235520eebf0c192ee (patch) | |
| tree | ca266b04aaea63ea0710a51708d6ef806008b34e /spec/outputs | |
| parent | 249e1de1d32dda2b60b9116c5a4e538475de0192 (diff) | |
| download | yuescript-10afeaf30bfe03774c12908235520eebf0c192ee.tar.gz yuescript-10afeaf30bfe03774c12908235520eebf0c192ee.tar.bz2 yuescript-10afeaf30bfe03774c12908235520eebf0c192ee.zip | |
add spread syntax support for table block. fix a gcc compiler issue. update doc.
Diffstat (limited to 'spec/outputs')
| -rw-r--r-- | spec/outputs/return.lua | 24 | ||||
| -rw-r--r-- | spec/outputs/tables.lua | 61 |
2 files changed, 85 insertions, 0 deletions
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 | |||
| 86 | end | 86 | end |
| 87 | end | 87 | end |
| 88 | end | 88 | end |
| 89 | do | ||
| 90 | return { | ||
| 91 | value = value, | ||
| 92 | itemA = 123, | ||
| 93 | itemB = "abc" | ||
| 94 | } | ||
| 95 | end | ||
| 96 | do | ||
| 97 | local _tab_0 = { | ||
| 98 | 1, | ||
| 99 | 2 | ||
| 100 | } | ||
| 101 | local _idx_0 = 1 | ||
| 102 | for _key_0, _value_0 in pairs(three) do | ||
| 103 | if _idx_0 == _key_0 then | ||
| 104 | _tab_0[#_tab_0 + 1] = _value_0 | ||
| 105 | _idx_0 = _idx_0 + 1 | ||
| 106 | else | ||
| 107 | _tab_0[_key_0] = _value_0 | ||
| 108 | end | ||
| 109 | end | ||
| 110 | _tab_0[#_tab_0 + 1] = 4 | ||
| 111 | return _tab_0 | ||
| 112 | end | ||
| 89 | _ = function() | 113 | _ = function() |
| 90 | local _base_0 = a | 114 | local _base_0 = a |
| 91 | local _fn_0 = _base_0.b | 115 | 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 | |||
| 527 | _tab_0["else"] = false | 527 | _tab_0["else"] = false |
| 528 | specializedB = _tab_0 | 528 | specializedB = _tab_0 |
| 529 | end | 529 | end |
| 530 | local parts = { | ||
| 531 | "shoulders", | ||
| 532 | "knees" | ||
| 533 | } | ||
| 534 | local lyrics | ||
| 535 | do | ||
| 536 | local _tab_0 = { | ||
| 537 | "head" | ||
| 538 | } | ||
| 539 | local _idx_0 = 1 | ||
| 540 | for _key_0, _value_0 in pairs(parts) do | ||
| 541 | if _idx_0 == _key_0 then | ||
| 542 | _tab_0[#_tab_0 + 1] = _value_0 | ||
| 543 | _idx_0 = _idx_0 + 1 | ||
| 544 | else | ||
| 545 | _tab_0[_key_0] = _value_0 | ||
| 546 | end | ||
| 547 | end | ||
| 548 | _tab_0[#_tab_0 + 1] = "and" | ||
| 549 | _tab_0[#_tab_0 + 1] = "toes" | ||
| 550 | lyrics = _tab_0 | ||
| 551 | end | ||
| 552 | local tbBlock = { | ||
| 553 | sub = (function(...) | ||
| 554 | local _tab_0 = { | ||
| 555 | value = value | ||
| 556 | } | ||
| 557 | local _idx_0 = 1 | ||
| 558 | for _key_0, _value_0 in pairs(items) do | ||
| 559 | if _idx_0 == _key_0 then | ||
| 560 | _tab_0[#_tab_0 + 1] = _value_0 | ||
| 561 | _idx_0 = _idx_0 + 1 | ||
| 562 | else | ||
| 563 | _tab_0[_key_0] = _value_0 | ||
| 564 | end | ||
| 565 | end | ||
| 566 | for _index_0 = 1, select('#', ...) do | ||
| 567 | _tab_0[#_tab_0 + 1] = select(_index_0, ...) | ||
| 568 | end | ||
| 569 | return _tab_0 | ||
| 570 | end)(...) | ||
| 571 | } | ||
| 572 | func((function(...) | ||
| 573 | local _tab_0 = { } | ||
| 574 | local _idx_0 = 1 | ||
| 575 | for _key_0, _value_0 in pairs(items) do | ||
| 576 | if _idx_0 == _key_0 then | ||
| 577 | _tab_0[#_tab_0 + 1] = _value_0 | ||
| 578 | _idx_0 = _idx_0 + 1 | ||
| 579 | else | ||
| 580 | _tab_0[_key_0] = _value_0 | ||
| 581 | end | ||
| 582 | end | ||
| 583 | _tab_0.value = value | ||
| 584 | _tab_0[#_tab_0 + 1] = ... | ||
| 585 | _tab_0.k = v | ||
| 586 | for _index_0 = 1, select('#', ...) do | ||
| 587 | _tab_0[#_tab_0 + 1] = select(_index_0, ...) | ||
| 588 | end | ||
| 589 | return _tab_0 | ||
| 590 | end)(...)) | ||
| 530 | return nil | 591 | return nil |
