diff options
Diffstat (limited to 'spec/outputs/codes_from_doc.lua')
-rw-r--r-- | spec/outputs/codes_from_doc.lua | 934 |
1 files changed, 914 insertions, 20 deletions
diff --git a/spec/outputs/codes_from_doc.lua b/spec/outputs/codes_from_doc.lua index 27f8de5..055e79b 100644 --- a/spec/outputs/codes_from_doc.lua +++ b/spec/outputs/codes_from_doc.lua | |||
@@ -20,6 +20,38 @@ local inventory = { | |||
20 | } | 20 | } |
21 | } | 21 | } |
22 | } | 22 | } |
23 | local map | ||
24 | map = function(arr, action) | ||
25 | local _accum_0 = { } | ||
26 | local _len_0 = 1 | ||
27 | for _index_0 = 1, #arr do | ||
28 | local item = arr[_index_0] | ||
29 | _accum_0[_len_0] = action(item) | ||
30 | _len_0 = _len_0 + 1 | ||
31 | end | ||
32 | return _accum_0 | ||
33 | end | ||
34 | local filter | ||
35 | filter = function(arr, cond) | ||
36 | local _accum_0 = { } | ||
37 | local _len_0 = 1 | ||
38 | for _index_0 = 1, #arr do | ||
39 | local item = arr[_index_0] | ||
40 | if cond(item) then | ||
41 | _accum_0[_len_0] = item | ||
42 | _len_0 = _len_0 + 1 | ||
43 | end | ||
44 | end | ||
45 | return _accum_0 | ||
46 | end | ||
47 | local reduce | ||
48 | reduce = function(arr, init, action) | ||
49 | for _index_0 = 1, #arr do | ||
50 | local item = arr[_index_0] | ||
51 | init = action(init, item) | ||
52 | end | ||
53 | return init | ||
54 | end | ||
23 | print(reduce(filter(map({ | 55 | print(reduce(filter(map({ |
24 | 1, | 56 | 1, |
25 | 2, | 57 | 2, |
@@ -77,6 +109,12 @@ end | |||
77 | print("yuescript") | 109 | print("yuescript") |
78 | print(3) | 110 | print(3) |
79 | print("Valid enum type:", "Static") | 111 | print("Valid enum type:", "Static") |
112 | do | ||
113 | print(123, "hello") | ||
114 | end | ||
115 | do | ||
116 | print(123, "hello") | ||
117 | end | ||
80 | if tb ~= nil then | 118 | if tb ~= nil then |
81 | tb:func() | 119 | tb:func() |
82 | end | 120 | end |
@@ -177,6 +215,16 @@ for _key_0, _value_0 in pairs(b) do | |||
177 | end | 215 | end |
178 | end | 216 | end |
179 | merge = _tab_0 | 217 | merge = _tab_0 |
218 | local last | ||
219 | do | ||
220 | local _item_0 = data.items | ||
221 | last = _item_0[#_item_0] | ||
222 | end | ||
223 | local second_last | ||
224 | do | ||
225 | local _item_0 = data.items | ||
226 | second_last = _item_0[#_item_0 - 1] | ||
227 | end | ||
180 | local mt = { } | 228 | local mt = { } |
181 | local add | 229 | local add |
182 | add = function(self, right) | 230 | add = function(self, right) |
@@ -307,6 +355,14 @@ func({ | |||
307 | 2, | 355 | 2, |
308 | 3 | 356 | 3 |
309 | }) | 357 | }) |
358 | local f | ||
359 | f = function() | ||
360 | return { | ||
361 | 1, | ||
362 | 2, | ||
363 | 3 | ||
364 | } | ||
365 | end | ||
310 | local tb = { | 366 | local tb = { |
311 | name = "abc", | 367 | name = "abc", |
312 | values = { | 368 | values = { |
@@ -547,6 +603,59 @@ end | |||
547 | local two, four | 603 | local two, four |
548 | local _obj_0 = items | 604 | local _obj_0 = items |
549 | two, four = _obj_0[2], _obj_0[4] | 605 | two, four = _obj_0[2], _obj_0[4] |
606 | local orders = { | ||
607 | "first", | ||
608 | "second", | ||
609 | "third", | ||
610 | "fourth", | ||
611 | "last" | ||
612 | } | ||
613 | local first, bulk, last = orders[1], (function() | ||
614 | local _accum_0 = { } | ||
615 | local _len_0 = 1 | ||
616 | local _max_0 = #orders + -2 + 1 | ||
617 | for _index_0 = 2, _max_0 do | ||
618 | local _item_0 = orders[_index_0] | ||
619 | _accum_0[_len_0] = _item_0 | ||
620 | _len_0 = _len_0 + 1 | ||
621 | end | ||
622 | return _accum_0 | ||
623 | end)(), orders[#orders] | ||
624 | print(first) | ||
625 | print(bulk) | ||
626 | print(last) | ||
627 | local first, rest | ||
628 | do | ||
629 | local _obj_0 = orders | ||
630 | first, rest = _obj_0[1], (function() | ||
631 | local _accum_0 = { } | ||
632 | local _len_0 = 1 | ||
633 | local _max_0 = #_obj_0 | ||
634 | for _index_0 = 2, _max_0 do | ||
635 | local _item_0 = _obj_0[_index_0] | ||
636 | _accum_0[_len_0] = _item_0 | ||
637 | _len_0 = _len_0 + 1 | ||
638 | end | ||
639 | return _accum_0 | ||
640 | end)() | ||
641 | end | ||
642 | local start, last | ||
643 | do | ||
644 | local _obj_0 = orders | ||
645 | start, last = (function() | ||
646 | local _accum_0 = { } | ||
647 | local _len_0 = 1 | ||
648 | local _max_0 = #_obj_0 + -2 + 1 | ||
649 | for _index_0 = 1, _max_0 do | ||
650 | local _item_0 = _obj_0[_index_0] | ||
651 | _accum_0[_len_0] = _item_0 | ||
652 | _len_0 = _len_0 + 1 | ||
653 | end | ||
654 | return _accum_0 | ||
655 | end)(), _obj_0[#_obj_0] | ||
656 | end | ||
657 | local _obj_0 = orders | ||
658 | first, last = _obj_0[1], _obj_0[#_obj_0] | ||
550 | local tuples = { | 659 | local tuples = { |
551 | { | 660 | { |
552 | "hello", | 661 | "hello", |
@@ -648,6 +757,56 @@ end) | |||
648 | if success then | 757 | if success then |
649 | print(result) | 758 | print(result) |
650 | end | 759 | end |
760 | local a, b, c | ||
761 | do | ||
762 | local _ok_0, _ret_0, _ret_1, _ret_2 = pcall(function() | ||
763 | return func() | ||
764 | end) | ||
765 | if _ok_0 then | ||
766 | a, b, c = _ret_0, _ret_1, _ret_2 | ||
767 | end | ||
768 | end | ||
769 | do | ||
770 | local _exp_0 = ((function() | ||
771 | return (function(_arg_0, ...) | ||
772 | local _ok_0 = _arg_0 | ||
773 | if _ok_0 then | ||
774 | return ... | ||
775 | end | ||
776 | end)(pcall(function() | ||
777 | return func() | ||
778 | end)) | ||
779 | end)()) | ||
780 | if _exp_0 ~= nil then | ||
781 | a = _exp_0 | ||
782 | else | ||
783 | a = "default" | ||
784 | end | ||
785 | end | ||
786 | f((function() | ||
787 | return (function(_arg_0, ...) | ||
788 | local _ok_0 = _arg_0 | ||
789 | if _ok_0 then | ||
790 | return ... | ||
791 | end | ||
792 | end)(pcall(function() | ||
793 | return func() | ||
794 | end)) | ||
795 | end)()) | ||
796 | f((function() | ||
797 | return (function(_arg_0, ...) | ||
798 | local _ok_0 = _arg_0 | ||
799 | if _ok_0 then | ||
800 | return ... | ||
801 | end | ||
802 | end)(xpcall(function() | ||
803 | print(123) | ||
804 | return func() | ||
805 | end, function(e) | ||
806 | print(e) | ||
807 | return e | ||
808 | end)) | ||
809 | end)()) | ||
651 | local a <const> = 123 | 810 | local a <const> = 123 |
652 | local _ <close> = setmetatable({ }, { | 811 | local _ <close> = setmetatable({ }, { |
653 | __close = function() | 812 | __close = function() |
@@ -657,10 +816,19 @@ local _ <close> = setmetatable({ }, { | |||
657 | local a, b, c, d | 816 | local a, b, c, d |
658 | local _obj_0 = tb | 817 | local _obj_0 = tb |
659 | a, b, c, d = _obj_0.a, _obj_0.b, _obj_0[1], _obj_0[2] | 818 | a, b, c, d = _obj_0.a, _obj_0.b, _obj_0[1], _obj_0[2] |
819 | Constant = 123 | ||
660 | local some_string = "Here is a string\n that has a line break in it." | 820 | local some_string = "Here is a string\n that has a line break in it." |
661 | print("I am " .. tostring(math.random() * 100) .. "% sure.") | 821 | print("I am " .. tostring(math.random() * 100) .. "% sure.") |
662 | local integer = 1000000 | 822 | local integer = 1000000 |
663 | local hex = 0xEFBBBF | 823 | local hex = 0xEFBBBF |
824 | local binary = 19 | ||
825 | local str = "key: value\nlist:\n - item1\n - " .. tostring(expr) | ||
826 | local fn | ||
827 | fn = function() | ||
828 | local str = "foo:\n bar: baz" | ||
829 | return str | ||
830 | end | ||
831 | local str = "path: \"C:\\Program Files\\App\"\nnote: 'He said: \"" .. tostring(Hello) .. "!\"'" | ||
664 | local my_function | 832 | local my_function |
665 | my_function = function() end | 833 | my_function = function() end |
666 | my_function() | 834 | my_function() |
@@ -755,6 +923,36 @@ if func(1, 2, 3, "hello", "world") then | |||
755 | print("hello") | 923 | print("hello") |
756 | print("I am inside if") | 924 | print("I am inside if") |
757 | end | 925 | end |
926 | local f1 | ||
927 | f1 = function(_arg_0) | ||
928 | local a, b, c | ||
929 | a, b, c = _arg_0.a, _arg_0.b, _arg_0.c | ||
930 | return print(a, b, c) | ||
931 | end | ||
932 | f1({ | ||
933 | a = 1, | ||
934 | b = "2", | ||
935 | c = { } | ||
936 | }) | ||
937 | local f2 | ||
938 | f2 = function(_arg_0, c) | ||
939 | local a1, b | ||
940 | a1, b = _arg_0.a, _arg_0.b | ||
941 | if a1 == nil then | ||
942 | a1 = 123 | ||
943 | end | ||
944 | if b == nil then | ||
945 | b = 'abc' | ||
946 | end | ||
947 | if c == nil then | ||
948 | c = { } | ||
949 | end | ||
950 | return print(a1, b, c) | ||
951 | end | ||
952 | local arg1 = { | ||
953 | a = 0 | ||
954 | } | ||
955 | f2(arg1, arg2) | ||
758 | f(function() | 956 | f(function() |
759 | return print("hello") | 957 | return print("hello") |
760 | end) | 958 | end) |
@@ -860,11 +1058,10 @@ for i, item in ipairs(items) do | |||
860 | _len_0 = _len_0 + 1 | 1058 | _len_0 = _len_0 + 1 |
861 | end | 1059 | end |
862 | doubled = _accum_0 | 1060 | doubled = _accum_0 |
863 | local iter = ipairs(items) | ||
864 | local slice | 1061 | local slice |
865 | local _accum_0 = { } | 1062 | local _accum_0 = { } |
866 | local _len_0 = 1 | 1063 | local _len_0 = 1 |
867 | for i, item in iter do | 1064 | for i, item in ipairs(items) do |
868 | if i > 1 and i < 3 then | 1065 | if i > 1 and i < 3 then |
869 | _accum_0[_len_0] = item | 1066 | _accum_0[_len_0] = item |
870 | _len_0 = _len_0 + 1 | 1067 | _len_0 = _len_0 + 1 |
@@ -971,8 +1168,7 @@ local slice | |||
971 | local _accum_0 = { } | 1168 | local _accum_0 = { } |
972 | local _len_0 = 1 | 1169 | local _len_0 = 1 |
973 | local _list_0 = items | 1170 | local _list_0 = items |
974 | local _max_0 = 5 | 1171 | for _index_0 = 1, 5 do |
975 | for _index_0 = 1, _max_0 < 0 and #_list_0 + _max_0 or _max_0 do | ||
976 | local item = _list_0[_index_0] | 1172 | local item = _list_0[_index_0] |
977 | _accum_0[_len_0] = item | 1173 | _accum_0[_len_0] = item |
978 | _len_0 = _len_0 + 1 | 1174 | _len_0 = _len_0 + 1 |
@@ -982,7 +1178,8 @@ local slice | |||
982 | local _accum_0 = { } | 1178 | local _accum_0 = { } |
983 | local _len_0 = 1 | 1179 | local _len_0 = 1 |
984 | local _list_0 = items | 1180 | local _list_0 = items |
985 | for _index_0 = 2, #_list_0 do | 1181 | local _max_0 = #_list_0 |
1182 | for _index_0 = 2, _max_0 do | ||
986 | local item = _list_0[_index_0] | 1183 | local item = _list_0[_index_0] |
987 | _accum_0[_len_0] = item | 1184 | _accum_0[_len_0] = item |
988 | _len_0 = _len_0 + 1 | 1185 | _len_0 = _len_0 + 1 |
@@ -992,12 +1189,46 @@ local slice | |||
992 | local _accum_0 = { } | 1189 | local _accum_0 = { } |
993 | local _len_0 = 1 | 1190 | local _len_0 = 1 |
994 | local _list_0 = items | 1191 | local _list_0 = items |
995 | for _index_0 = 1, #_list_0, 2 do | 1192 | local _max_0 = #_list_0 |
1193 | for _index_0 = 1, _max_0, 2 do | ||
996 | local item = _list_0[_index_0] | 1194 | local item = _list_0[_index_0] |
997 | _accum_0[_len_0] = item | 1195 | _accum_0[_len_0] = item |
998 | _len_0 = _len_0 + 1 | 1196 | _len_0 = _len_0 + 1 |
999 | end | 1197 | end |
1000 | slice = _accum_0 | 1198 | slice = _accum_0 |
1199 | local slice | ||
1200 | local _accum_0 = { } | ||
1201 | local _len_0 = 1 | ||
1202 | local _list_0 = items | ||
1203 | local _min_0 = #_list_0 + -4 + 1 | ||
1204 | local _max_0 = #_list_0 + -1 + 1 | ||
1205 | for _index_0 = _min_0, _max_0 do | ||
1206 | local item = _list_0[_index_0] | ||
1207 | _accum_0[_len_0] = item | ||
1208 | _len_0 = _len_0 + 1 | ||
1209 | end | ||
1210 | slice = _accum_0 | ||
1211 | local reverse_slice | ||
1212 | local _accum_0 = { } | ||
1213 | local _len_0 = 1 | ||
1214 | local _list_0 = items | ||
1215 | local _min_0 = #_list_0 + -1 + 1 | ||
1216 | for _index_0 = _min_0, 1, -1 do | ||
1217 | local item = _list_0[_index_0] | ||
1218 | _accum_0[_len_0] = item | ||
1219 | _len_0 = _len_0 + 1 | ||
1220 | end | ||
1221 | reverse_slice = _accum_0 | ||
1222 | local sub_list | ||
1223 | local _accum_0 = { } | ||
1224 | local _len_0 = 1 | ||
1225 | local _list_0 = items | ||
1226 | for _index_0 = 2, 4 do | ||
1227 | local _item_0 = _list_0[_index_0] | ||
1228 | _accum_0[_len_0] = _item_0 | ||
1229 | _len_0 = _len_0 + 1 | ||
1230 | end | ||
1231 | sub_list = _accum_0 | ||
1001 | for i = 10, 20 do | 1232 | for i = 10, 20 do |
1002 | print(i) | 1233 | print(i) |
1003 | end | 1234 | end |
@@ -1008,8 +1239,7 @@ for key, value in pairs(object) do | |||
1008 | print(key, value) | 1239 | print(key, value) |
1009 | end | 1240 | end |
1010 | local _list_0 = items | 1241 | local _list_0 = items |
1011 | local _max_0 = 4 | 1242 | for _index_0 = 2, 4 do |
1012 | for _index_0 = 2, _max_0 < 0 and #_list_0 + _max_0 or _max_0 do | ||
1013 | local item = _list_0[_index_0] | 1243 | local item = _list_0[_index_0] |
1014 | print(item) | 1244 | print(item) |
1015 | end | 1245 | end |
@@ -1027,12 +1257,24 @@ local _len_0 = 1 | |||
1027 | for i = 1, 20 do | 1257 | for i = 1, 20 do |
1028 | if i % 2 == 0 then | 1258 | if i % 2 == 0 then |
1029 | _accum_0[_len_0] = i * 2 | 1259 | _accum_0[_len_0] = i * 2 |
1260 | _len_0 = _len_0 + 1 | ||
1030 | else | 1261 | else |
1031 | _accum_0[_len_0] = i | 1262 | _accum_0[_len_0] = i |
1263 | _len_0 = _len_0 + 1 | ||
1032 | end | 1264 | end |
1033 | _len_0 = _len_0 + 1 | ||
1034 | end | 1265 | end |
1035 | doubled_evens = _accum_0 | 1266 | doubled_evens = _accum_0 |
1267 | local first_large | ||
1268 | local _accum_0 | ||
1269 | local _list_0 = numbers | ||
1270 | for _index_0 = 1, #_list_0 do | ||
1271 | local n = _list_0[_index_0] | ||
1272 | if n > 10 then | ||
1273 | _accum_0 = n | ||
1274 | break | ||
1275 | end | ||
1276 | end | ||
1277 | first_large = _accum_0 | ||
1036 | local func_a | 1278 | local func_a |
1037 | func_a = function() | 1279 | func_a = function() |
1038 | for i = 1, 10 do | 1280 | for i = 1, 10 do |
@@ -1181,7 +1423,7 @@ if "Robert" == name then | |||
1181 | elseif "Dan" == name or "Daniel" == name then | 1423 | elseif "Dan" == name or "Daniel" == name then |
1182 | print("Your name, it's Dan") | 1424 | print("Your name, it's Dan") |
1183 | else | 1425 | else |
1184 | print("I don't know about your name") | 1426 | print("I don't know about you with name " .. tostring(name)) |
1185 | end | 1427 | end |
1186 | local b = 1 | 1428 | local b = 1 |
1187 | local next_number | 1429 | local next_number |
@@ -1281,6 +1523,192 @@ if _tab_0 then | |||
1281 | end | 1523 | end |
1282 | print("Vec2 " .. tostring(x) .. ", " .. tostring(y)) | 1524 | print("Vec2 " .. tostring(x) .. ", " .. tostring(y)) |
1283 | end | 1525 | end |
1526 | local _exp_0 = tb | ||
1527 | local _type_0 = type(_exp_0) | ||
1528 | local _tab_0 = "table" == _type_0 or "userdata" == _type_0 | ||
1529 | local _match_0 = false | ||
1530 | if _tab_0 then | ||
1531 | if 1 == _exp_0[1] and 2 == _exp_0[2] and 3 == _exp_0[3] then | ||
1532 | _match_0 = true | ||
1533 | print("1, 2, 3") | ||
1534 | end | ||
1535 | end | ||
1536 | if not _match_0 then | ||
1537 | local _match_1 = false | ||
1538 | if _tab_0 then | ||
1539 | local b = _exp_0[2] | ||
1540 | if 1 == _exp_0[1] and b ~= nil and 3 == _exp_0[3] then | ||
1541 | _match_1 = true | ||
1542 | print("1, " .. tostring(b) .. ", 3") | ||
1543 | end | ||
1544 | end | ||
1545 | if not _match_1 then | ||
1546 | if _tab_0 then | ||
1547 | local b = _exp_0[3] | ||
1548 | if b == nil then | ||
1549 | b = 3 | ||
1550 | end | ||
1551 | if 1 == _exp_0[1] and 2 == _exp_0[2] then | ||
1552 | print("1, 2, " .. tostring(b)) | ||
1553 | end | ||
1554 | end | ||
1555 | end | ||
1556 | end | ||
1557 | local _exp_0 = tb | ||
1558 | local _type_0 = type(_exp_0) | ||
1559 | local _tab_0 = "table" == _type_0 or "userdata" == _type_0 | ||
1560 | local _match_0 = false | ||
1561 | if _tab_0 then | ||
1562 | local result = _exp_0.result | ||
1563 | if true == _exp_0.success and result ~= nil then | ||
1564 | _match_0 = true | ||
1565 | print("success", result) | ||
1566 | end | ||
1567 | end | ||
1568 | if not _match_0 then | ||
1569 | local _match_1 = false | ||
1570 | if _tab_0 then | ||
1571 | if false == _exp_0.success then | ||
1572 | _match_1 = true | ||
1573 | print("failed", result) | ||
1574 | end | ||
1575 | end | ||
1576 | if not _match_1 then | ||
1577 | print("invalid") | ||
1578 | end | ||
1579 | end | ||
1580 | local _exp_0 = tb | ||
1581 | local _type_0 = type(_exp_0) | ||
1582 | local _tab_0 = "table" == _type_0 or "userdata" == _type_0 | ||
1583 | local _match_0 = false | ||
1584 | if _tab_0 then | ||
1585 | local content | ||
1586 | do | ||
1587 | local _obj_0 = _exp_0.data | ||
1588 | local _type_1 = type(_obj_0) | ||
1589 | if "table" == _type_1 or "userdata" == _type_1 then | ||
1590 | content = _obj_0.content | ||
1591 | end | ||
1592 | end | ||
1593 | local _val_0 | ||
1594 | do | ||
1595 | local _obj_0 = _exp_0.data | ||
1596 | if _obj_0 ~= nil then | ||
1597 | _val_0 = _obj_0.type | ||
1598 | end | ||
1599 | end | ||
1600 | if "success" == _val_0 and content ~= nil then | ||
1601 | _match_0 = true | ||
1602 | print("success", content) | ||
1603 | end | ||
1604 | end | ||
1605 | if not _match_0 then | ||
1606 | local _match_1 = false | ||
1607 | if _tab_0 then | ||
1608 | local content | ||
1609 | do | ||
1610 | local _obj_0 = _exp_0.data | ||
1611 | local _type_1 = type(_obj_0) | ||
1612 | if "table" == _type_1 or "userdata" == _type_1 then | ||
1613 | content = _obj_0.content | ||
1614 | end | ||
1615 | end | ||
1616 | local _val_0 | ||
1617 | do | ||
1618 | local _obj_0 = _exp_0.data | ||
1619 | if _obj_0 ~= nil then | ||
1620 | _val_0 = _obj_0.type | ||
1621 | end | ||
1622 | end | ||
1623 | if "error" == _val_0 and content ~= nil then | ||
1624 | _match_1 = true | ||
1625 | print("failed", content) | ||
1626 | end | ||
1627 | end | ||
1628 | if not _match_1 then | ||
1629 | print("invalid") | ||
1630 | end | ||
1631 | end | ||
1632 | local _exp_0 = tb | ||
1633 | local _type_0 = type(_exp_0) | ||
1634 | local _tab_0 = "table" == _type_0 or "userdata" == _type_0 | ||
1635 | if _tab_0 then | ||
1636 | local fourth = _exp_0[4] | ||
1637 | local _val_0 | ||
1638 | do | ||
1639 | local _obj_0 = _exp_0[1] | ||
1640 | if _obj_0 ~= nil then | ||
1641 | _val_0 = _obj_0.a | ||
1642 | end | ||
1643 | end | ||
1644 | local _val_1 | ||
1645 | do | ||
1646 | local _obj_0 = _exp_0[1] | ||
1647 | if _obj_0 ~= nil then | ||
1648 | _val_1 = _obj_0.b | ||
1649 | end | ||
1650 | end | ||
1651 | local _val_2 | ||
1652 | do | ||
1653 | local _obj_0 = _exp_0[2] | ||
1654 | if _obj_0 ~= nil then | ||
1655 | _val_2 = _obj_0.a | ||
1656 | end | ||
1657 | end | ||
1658 | local _val_3 | ||
1659 | do | ||
1660 | local _obj_0 = _exp_0[2] | ||
1661 | if _obj_0 ~= nil then | ||
1662 | _val_3 = _obj_0.b | ||
1663 | end | ||
1664 | end | ||
1665 | local _val_4 | ||
1666 | do | ||
1667 | local _obj_0 = _exp_0[3] | ||
1668 | if _obj_0 ~= nil then | ||
1669 | _val_4 = _obj_0.a | ||
1670 | end | ||
1671 | end | ||
1672 | local _val_5 | ||
1673 | do | ||
1674 | local _obj_0 = _exp_0[3] | ||
1675 | if _obj_0 ~= nil then | ||
1676 | _val_5 = _obj_0.b | ||
1677 | end | ||
1678 | end | ||
1679 | if 1 == _val_0 and 2 == _val_1 and 3 == _val_2 and 4 == _val_3 and 5 == _val_4 and 6 == _val_5 and fourth ~= nil then | ||
1680 | print("matched", fourth) | ||
1681 | end | ||
1682 | end | ||
1683 | local segments = { | ||
1684 | "admin", | ||
1685 | "users", | ||
1686 | "logs", | ||
1687 | "view" | ||
1688 | } | ||
1689 | local _type_0 = type(segments) | ||
1690 | local _tab_0 = "table" == _type_0 or "userdata" == _type_0 | ||
1691 | if _tab_0 then | ||
1692 | local groups | ||
1693 | do | ||
1694 | local _accum_0 = { } | ||
1695 | local _len_0 = 1 | ||
1696 | local _max_0 = #segments + -3 + 1 | ||
1697 | for _index_0 = 1, _max_0 do | ||
1698 | local _item_0 = segments[_index_0] | ||
1699 | _accum_0[_len_0] = _item_0 | ||
1700 | _len_0 = _len_0 + 1 | ||
1701 | end | ||
1702 | groups = _accum_0 | ||
1703 | end | ||
1704 | local resource = segments[#segments - 1] | ||
1705 | local action = segments[#segments] | ||
1706 | if resource ~= nil and action ~= nil then | ||
1707 | print("Group:", groups) | ||
1708 | print("Resource:", resource) | ||
1709 | print("Action:", action) | ||
1710 | end | ||
1711 | end | ||
1284 | local Inventory | 1712 | local Inventory |
1285 | local _class_0 | 1713 | local _class_0 |
1286 | local _base_0 = { | 1714 | local _base_0 = { |
@@ -1937,6 +2365,10 @@ do | |||
1937 | _with_1["key-name"] = value | 2365 | _with_1["key-name"] = value |
1938 | end | 2366 | end |
1939 | _with_0[#_with_0 + 1] = "abc" | 2367 | _with_0[#_with_0 + 1] = "abc" |
2368 | local _with_0 = obj | ||
2369 | if _with_0 ~= nil then | ||
2370 | print(obj.name) | ||
2371 | end | ||
1940 | do | 2372 | do |
1941 | local var = "hello" | 2373 | local var = "hello" |
1942 | print(var) | 2374 | print(var) |
@@ -2027,6 +2459,38 @@ local inventory = { | |||
2027 | } | 2459 | } |
2028 | } | 2460 | } |
2029 | } | 2461 | } |
2462 | local map | ||
2463 | map = function(arr, action) | ||
2464 | local _accum_0 = { } | ||
2465 | local _len_0 = 1 | ||
2466 | for _index_0 = 1, #arr do | ||
2467 | local item = arr[_index_0] | ||
2468 | _accum_0[_len_0] = action(item) | ||
2469 | _len_0 = _len_0 + 1 | ||
2470 | end | ||
2471 | return _accum_0 | ||
2472 | end | ||
2473 | local filter | ||
2474 | filter = function(arr, cond) | ||
2475 | local _accum_0 = { } | ||
2476 | local _len_0 = 1 | ||
2477 | for _index_0 = 1, #arr do | ||
2478 | local item = arr[_index_0] | ||
2479 | if cond(item) then | ||
2480 | _accum_0[_len_0] = item | ||
2481 | _len_0 = _len_0 + 1 | ||
2482 | end | ||
2483 | end | ||
2484 | return _accum_0 | ||
2485 | end | ||
2486 | local reduce | ||
2487 | reduce = function(arr, init, action) | ||
2488 | for _index_0 = 1, #arr do | ||
2489 | local item = arr[_index_0] | ||
2490 | init = action(init, item) | ||
2491 | end | ||
2492 | return init | ||
2493 | end | ||
2030 | print(reduce(filter(map({ | 2494 | print(reduce(filter(map({ |
2031 | 1, | 2495 | 1, |
2032 | 2, | 2496 | 2, |
@@ -2084,6 +2548,12 @@ end | |||
2084 | print("yuescript") | 2548 | print("yuescript") |
2085 | print(3) | 2549 | print(3) |
2086 | print("Valid enum type:", "Static") | 2550 | print("Valid enum type:", "Static") |
2551 | do | ||
2552 | print(123, "hello") | ||
2553 | end | ||
2554 | do | ||
2555 | print(123, "hello") | ||
2556 | end | ||
2087 | if tb ~= nil then | 2557 | if tb ~= nil then |
2088 | tb:func() | 2558 | tb:func() |
2089 | end | 2559 | end |
@@ -2184,6 +2654,16 @@ for _key_0, _value_0 in pairs(b) do | |||
2184 | end | 2654 | end |
2185 | end | 2655 | end |
2186 | merge = _tab_0 | 2656 | merge = _tab_0 |
2657 | local last | ||
2658 | do | ||
2659 | local _item_0 = data.items | ||
2660 | last = _item_0[#_item_0] | ||
2661 | end | ||
2662 | local second_last | ||
2663 | do | ||
2664 | local _item_0 = data.items | ||
2665 | second_last = _item_0[#_item_0 - 1] | ||
2666 | end | ||
2187 | local mt = { } | 2667 | local mt = { } |
2188 | local add | 2668 | local add |
2189 | add = function(self, right) | 2669 | add = function(self, right) |
@@ -2314,6 +2794,14 @@ func({ | |||
2314 | 2, | 2794 | 2, |
2315 | 3 | 2795 | 3 |
2316 | }) | 2796 | }) |
2797 | local f | ||
2798 | f = function() | ||
2799 | return { | ||
2800 | 1, | ||
2801 | 2, | ||
2802 | 3 | ||
2803 | } | ||
2804 | end | ||
2317 | local tb = { | 2805 | local tb = { |
2318 | name = "abc", | 2806 | name = "abc", |
2319 | values = { | 2807 | values = { |
@@ -2554,6 +3042,59 @@ end | |||
2554 | local two, four | 3042 | local two, four |
2555 | local _obj_0 = items | 3043 | local _obj_0 = items |
2556 | two, four = _obj_0[2], _obj_0[4] | 3044 | two, four = _obj_0[2], _obj_0[4] |
3045 | local orders = { | ||
3046 | "first", | ||
3047 | "second", | ||
3048 | "third", | ||
3049 | "fourth", | ||
3050 | "last" | ||
3051 | } | ||
3052 | local first, bulk, last = orders[1], (function() | ||
3053 | local _accum_0 = { } | ||
3054 | local _len_0 = 1 | ||
3055 | local _max_0 = #orders + -2 + 1 | ||
3056 | for _index_0 = 2, _max_0 do | ||
3057 | local _item_0 = orders[_index_0] | ||
3058 | _accum_0[_len_0] = _item_0 | ||
3059 | _len_0 = _len_0 + 1 | ||
3060 | end | ||
3061 | return _accum_0 | ||
3062 | end)(), orders[#orders] | ||
3063 | print(first) | ||
3064 | print(bulk) | ||
3065 | print(last) | ||
3066 | local first, rest | ||
3067 | do | ||
3068 | local _obj_0 = orders | ||
3069 | first, rest = _obj_0[1], (function() | ||
3070 | local _accum_0 = { } | ||
3071 | local _len_0 = 1 | ||
3072 | local _max_0 = #_obj_0 | ||
3073 | for _index_0 = 2, _max_0 do | ||
3074 | local _item_0 = _obj_0[_index_0] | ||
3075 | _accum_0[_len_0] = _item_0 | ||
3076 | _len_0 = _len_0 + 1 | ||
3077 | end | ||
3078 | return _accum_0 | ||
3079 | end)() | ||
3080 | end | ||
3081 | local start, last | ||
3082 | do | ||
3083 | local _obj_0 = orders | ||
3084 | start, last = (function() | ||
3085 | local _accum_0 = { } | ||
3086 | local _len_0 = 1 | ||
3087 | local _max_0 = #_obj_0 + -2 + 1 | ||
3088 | for _index_0 = 1, _max_0 do | ||
3089 | local _item_0 = _obj_0[_index_0] | ||
3090 | _accum_0[_len_0] = _item_0 | ||
3091 | _len_0 = _len_0 + 1 | ||
3092 | end | ||
3093 | return _accum_0 | ||
3094 | end)(), _obj_0[#_obj_0] | ||
3095 | end | ||
3096 | local _obj_0 = orders | ||
3097 | first, last = _obj_0[1], _obj_0[#_obj_0] | ||
2557 | local tuples = { | 3098 | local tuples = { |
2558 | { | 3099 | { |
2559 | "hello", | 3100 | "hello", |
@@ -2655,6 +3196,56 @@ end) | |||
2655 | if success then | 3196 | if success then |
2656 | print(result) | 3197 | print(result) |
2657 | end | 3198 | end |
3199 | local a, b, c | ||
3200 | do | ||
3201 | local _ok_0, _ret_0, _ret_1, _ret_2 = pcall(function() | ||
3202 | return func() | ||
3203 | end) | ||
3204 | if _ok_0 then | ||
3205 | a, b, c = _ret_0, _ret_1, _ret_2 | ||
3206 | end | ||
3207 | end | ||
3208 | do | ||
3209 | local _exp_0 = ((function() | ||
3210 | return (function(_arg_0, ...) | ||
3211 | local _ok_0 = _arg_0 | ||
3212 | if _ok_0 then | ||
3213 | return ... | ||
3214 | end | ||
3215 | end)(pcall(function() | ||
3216 | return func() | ||
3217 | end)) | ||
3218 | end)()) | ||
3219 | if _exp_0 ~= nil then | ||
3220 | a = _exp_0 | ||
3221 | else | ||
3222 | a = "default" | ||
3223 | end | ||
3224 | end | ||
3225 | f((function() | ||
3226 | return (function(_arg_0, ...) | ||
3227 | local _ok_0 = _arg_0 | ||
3228 | if _ok_0 then | ||
3229 | return ... | ||
3230 | end | ||
3231 | end)(pcall(function() | ||
3232 | return func() | ||
3233 | end)) | ||
3234 | end)()) | ||
3235 | f((function() | ||
3236 | return (function(_arg_0, ...) | ||
3237 | local _ok_0 = _arg_0 | ||
3238 | if _ok_0 then | ||
3239 | return ... | ||
3240 | end | ||
3241 | end)(xpcall(function() | ||
3242 | print(123) | ||
3243 | return func() | ||
3244 | end, function(e) | ||
3245 | print(e) | ||
3246 | return e | ||
3247 | end)) | ||
3248 | end)()) | ||
2658 | local a <const> = 123 | 3249 | local a <const> = 123 |
2659 | local _ <close> = setmetatable({ }, { | 3250 | local _ <close> = setmetatable({ }, { |
2660 | __close = function() | 3251 | __close = function() |
@@ -2664,10 +3255,19 @@ local _ <close> = setmetatable({ }, { | |||
2664 | local a, b, c, d | 3255 | local a, b, c, d |
2665 | local _obj_0 = tb | 3256 | local _obj_0 = tb |
2666 | a, b, c, d = _obj_0.a, _obj_0.b, _obj_0[1], _obj_0[2] | 3257 | a, b, c, d = _obj_0.a, _obj_0.b, _obj_0[1], _obj_0[2] |
3258 | Constant = 123 | ||
2667 | local some_string = "Here is a string\n that has a line break in it." | 3259 | local some_string = "Here is a string\n that has a line break in it." |
2668 | print("I am " .. tostring(math.random() * 100) .. "% sure.") | 3260 | print("I am " .. tostring(math.random() * 100) .. "% sure.") |
2669 | local integer = 1000000 | 3261 | local integer = 1000000 |
2670 | local hex = 0xEFBBBF | 3262 | local hex = 0xEFBBBF |
3263 | local binary = 19 | ||
3264 | local str = "key: value\nlist:\n - item1\n - " .. tostring(expr) | ||
3265 | local fn | ||
3266 | fn = function() | ||
3267 | local str = "foo:\n bar: baz" | ||
3268 | return str | ||
3269 | end | ||
3270 | local str = "path: \"C:\\Program Files\\App\"\nnote: 'He said: \"" .. tostring(Hello) .. "!\"'" | ||
2671 | local my_function | 3271 | local my_function |
2672 | my_function = function() end | 3272 | my_function = function() end |
2673 | my_function() | 3273 | my_function() |
@@ -2762,6 +3362,66 @@ if func(1, 2, 3, "hello", "world") then | |||
2762 | print("hello") | 3362 | print("hello") |
2763 | print("I am inside if") | 3363 | print("I am inside if") |
2764 | end | 3364 | end |
3365 | local f1 | ||
3366 | f1 = function(_arg_0) | ||
3367 | local a, b, c | ||
3368 | a, b, c = _arg_0.a, _arg_0.b, _arg_0.c | ||
3369 | return print(a, b, c) | ||
3370 | end | ||
3371 | f1({ | ||
3372 | a = 1, | ||
3373 | b = "2", | ||
3374 | c = { } | ||
3375 | }) | ||
3376 | local f2 | ||
3377 | f2 = function(_arg_0, c) | ||
3378 | local a1, b | ||
3379 | a1, b = _arg_0.a, _arg_0.b | ||
3380 | if a1 == nil then | ||
3381 | a1 = 123 | ||
3382 | end | ||
3383 | if b == nil then | ||
3384 | b = 'abc' | ||
3385 | end | ||
3386 | if c == nil then | ||
3387 | c = { } | ||
3388 | end | ||
3389 | end | ||
3390 | print(a1, b, c) | ||
3391 | local arg1 = { | ||
3392 | a = 0 | ||
3393 | } | ||
3394 | f2(arg1, arg2) | ||
3395 | local findFirstEven | ||
3396 | findFirstEven = function(list) | ||
3397 | for _index_0 = 1, #list do | ||
3398 | local item = list[_index_0] | ||
3399 | if type(item) == "table" then | ||
3400 | for _index_1 = 1, #item do | ||
3401 | local sub = item[_index_1] | ||
3402 | if sub % 2 == 0 then | ||
3403 | return sub | ||
3404 | end | ||
3405 | end | ||
3406 | end | ||
3407 | end | ||
3408 | return nil | ||
3409 | end | ||
3410 | local findFirstEven | ||
3411 | findFirstEven = function(list) | ||
3412 | for _index_0 = 1, #list do | ||
3413 | local item = list[_index_0] | ||
3414 | if type(item) == "table" then | ||
3415 | for _index_1 = 1, #item do | ||
3416 | local sub = item[_index_1] | ||
3417 | if sub % 2 == 0 then | ||
3418 | return sub | ||
3419 | end | ||
3420 | end | ||
3421 | end | ||
3422 | end | ||
3423 | return nil | ||
3424 | end | ||
2765 | f(function() | 3425 | f(function() |
2766 | return print("hello") | 3426 | return print("hello") |
2767 | end) | 3427 | end) |
@@ -2867,11 +3527,10 @@ for i, item in ipairs(items) do | |||
2867 | _len_0 = _len_0 + 1 | 3527 | _len_0 = _len_0 + 1 |
2868 | end | 3528 | end |
2869 | doubled = _accum_0 | 3529 | doubled = _accum_0 |
2870 | local iter = ipairs(items) | ||
2871 | local slice | 3530 | local slice |
2872 | local _accum_0 = { } | 3531 | local _accum_0 = { } |
2873 | local _len_0 = 1 | 3532 | local _len_0 = 1 |
2874 | for i, item in iter do | 3533 | for i, item in ipairs(items) do |
2875 | if i > 1 and i < 3 then | 3534 | if i > 1 and i < 3 then |
2876 | _accum_0[_len_0] = item | 3535 | _accum_0[_len_0] = item |
2877 | _len_0 = _len_0 + 1 | 3536 | _len_0 = _len_0 + 1 |
@@ -2978,8 +3637,7 @@ local slice | |||
2978 | local _accum_0 = { } | 3637 | local _accum_0 = { } |
2979 | local _len_0 = 1 | 3638 | local _len_0 = 1 |
2980 | local _list_0 = items | 3639 | local _list_0 = items |
2981 | local _max_0 = 5 | 3640 | for _index_0 = 1, 5 do |
2982 | for _index_0 = 1, _max_0 < 0 and #_list_0 + _max_0 or _max_0 do | ||
2983 | local item = _list_0[_index_0] | 3641 | local item = _list_0[_index_0] |
2984 | _accum_0[_len_0] = item | 3642 | _accum_0[_len_0] = item |
2985 | _len_0 = _len_0 + 1 | 3643 | _len_0 = _len_0 + 1 |
@@ -2989,7 +3647,8 @@ local slice | |||
2989 | local _accum_0 = { } | 3647 | local _accum_0 = { } |
2990 | local _len_0 = 1 | 3648 | local _len_0 = 1 |
2991 | local _list_0 = items | 3649 | local _list_0 = items |
2992 | for _index_0 = 2, #_list_0 do | 3650 | local _max_0 = #_list_0 |
3651 | for _index_0 = 2, _max_0 do | ||
2993 | local item = _list_0[_index_0] | 3652 | local item = _list_0[_index_0] |
2994 | _accum_0[_len_0] = item | 3653 | _accum_0[_len_0] = item |
2995 | _len_0 = _len_0 + 1 | 3654 | _len_0 = _len_0 + 1 |
@@ -2999,12 +3658,46 @@ local slice | |||
2999 | local _accum_0 = { } | 3658 | local _accum_0 = { } |
3000 | local _len_0 = 1 | 3659 | local _len_0 = 1 |
3001 | local _list_0 = items | 3660 | local _list_0 = items |
3002 | for _index_0 = 1, #_list_0, 2 do | 3661 | local _max_0 = #_list_0 |
3662 | for _index_0 = 1, _max_0, 2 do | ||
3003 | local item = _list_0[_index_0] | 3663 | local item = _list_0[_index_0] |
3004 | _accum_0[_len_0] = item | 3664 | _accum_0[_len_0] = item |
3005 | _len_0 = _len_0 + 1 | 3665 | _len_0 = _len_0 + 1 |
3006 | end | 3666 | end |
3007 | slice = _accum_0 | 3667 | slice = _accum_0 |
3668 | local slice | ||
3669 | local _accum_0 = { } | ||
3670 | local _len_0 = 1 | ||
3671 | local _list_0 = items | ||
3672 | local _min_0 = #_list_0 + -4 + 1 | ||
3673 | local _max_0 = #_list_0 + -1 + 1 | ||
3674 | for _index_0 = _min_0, _max_0 do | ||
3675 | local item = _list_0[_index_0] | ||
3676 | _accum_0[_len_0] = item | ||
3677 | _len_0 = _len_0 + 1 | ||
3678 | end | ||
3679 | slice = _accum_0 | ||
3680 | local reverse_slice | ||
3681 | local _accum_0 = { } | ||
3682 | local _len_0 = 1 | ||
3683 | local _list_0 = items | ||
3684 | local _min_0 = #_list_0 + -1 + 1 | ||
3685 | for _index_0 = _min_0, 1, -1 do | ||
3686 | local item = _list_0[_index_0] | ||
3687 | _accum_0[_len_0] = item | ||
3688 | _len_0 = _len_0 + 1 | ||
3689 | end | ||
3690 | reverse_slice = _accum_0 | ||
3691 | local sub_list | ||
3692 | local _accum_0 = { } | ||
3693 | local _len_0 = 1 | ||
3694 | local _list_0 = items | ||
3695 | for _index_0 = 2, 4 do | ||
3696 | local _item_0 = _list_0[_index_0] | ||
3697 | _accum_0[_len_0] = _item_0 | ||
3698 | _len_0 = _len_0 + 1 | ||
3699 | end | ||
3700 | sub_list = _accum_0 | ||
3008 | for i = 10, 20 do | 3701 | for i = 10, 20 do |
3009 | print(i) | 3702 | print(i) |
3010 | end | 3703 | end |
@@ -3015,8 +3708,7 @@ for key, value in pairs(object) do | |||
3015 | print(key, value) | 3708 | print(key, value) |
3016 | end | 3709 | end |
3017 | local _list_0 = items | 3710 | local _list_0 = items |
3018 | local _max_0 = 4 | 3711 | for _index_0 = 2, 4 do |
3019 | for _index_0 = 2, _max_0 < 0 and #_list_0 + _max_0 or _max_0 do | ||
3020 | local item = _list_0[_index_0] | 3712 | local item = _list_0[_index_0] |
3021 | print(item) | 3713 | print(item) |
3022 | end | 3714 | end |
@@ -3034,12 +3726,24 @@ local _len_0 = 1 | |||
3034 | for i = 1, 20 do | 3726 | for i = 1, 20 do |
3035 | if i % 2 == 0 then | 3727 | if i % 2 == 0 then |
3036 | _accum_0[_len_0] = i * 2 | 3728 | _accum_0[_len_0] = i * 2 |
3729 | _len_0 = _len_0 + 1 | ||
3037 | else | 3730 | else |
3038 | _accum_0[_len_0] = i | 3731 | _accum_0[_len_0] = i |
3732 | _len_0 = _len_0 + 1 | ||
3039 | end | 3733 | end |
3040 | _len_0 = _len_0 + 1 | ||
3041 | end | 3734 | end |
3042 | doubled_evens = _accum_0 | 3735 | doubled_evens = _accum_0 |
3736 | local first_large | ||
3737 | local _accum_0 | ||
3738 | local _list_0 = numbers | ||
3739 | for _index_0 = 1, #_list_0 do | ||
3740 | local n = _list_0[_index_0] | ||
3741 | if n > 10 then | ||
3742 | _accum_0 = n | ||
3743 | break | ||
3744 | end | ||
3745 | end | ||
3746 | first_large = _accum_0 | ||
3043 | local func_a | 3747 | local func_a |
3044 | func_a = function() | 3748 | func_a = function() |
3045 | for i = 1, 10 do | 3749 | for i = 1, 10 do |
@@ -3188,7 +3892,7 @@ if "Robert" == name then | |||
3188 | elseif "Dan" == name or "Daniel" == name then | 3892 | elseif "Dan" == name or "Daniel" == name then |
3189 | print("Your name, it's Dan") | 3893 | print("Your name, it's Dan") |
3190 | else | 3894 | else |
3191 | print("I don't know about your name") | 3895 | print("I don't know about you with name " .. tostring(name)) |
3192 | end | 3896 | end |
3193 | local b = 1 | 3897 | local b = 1 |
3194 | local next_number | 3898 | local next_number |
@@ -3288,6 +3992,192 @@ if _tab_0 then | |||
3288 | end | 3992 | end |
3289 | print("Vec2 " .. tostring(x) .. ", " .. tostring(y)) | 3993 | print("Vec2 " .. tostring(x) .. ", " .. tostring(y)) |
3290 | end | 3994 | end |
3995 | local _exp_0 = tb | ||
3996 | local _type_0 = type(_exp_0) | ||
3997 | local _tab_0 = "table" == _type_0 or "userdata" == _type_0 | ||
3998 | local _match_0 = false | ||
3999 | if _tab_0 then | ||
4000 | if 1 == _exp_0[1] and 2 == _exp_0[2] and 3 == _exp_0[3] then | ||
4001 | _match_0 = true | ||
4002 | print("1, 2, 3") | ||
4003 | end | ||
4004 | end | ||
4005 | if not _match_0 then | ||
4006 | local _match_1 = false | ||
4007 | if _tab_0 then | ||
4008 | local b = _exp_0[2] | ||
4009 | if 1 == _exp_0[1] and b ~= nil and 3 == _exp_0[3] then | ||
4010 | _match_1 = true | ||
4011 | print("1, " .. tostring(b) .. ", 3") | ||
4012 | end | ||
4013 | end | ||
4014 | if not _match_1 then | ||
4015 | if _tab_0 then | ||
4016 | local b = _exp_0[3] | ||
4017 | if b == nil then | ||
4018 | b = 3 | ||
4019 | end | ||
4020 | if 1 == _exp_0[1] and 2 == _exp_0[2] then | ||
4021 | print("1, 2, " .. tostring(b)) | ||
4022 | end | ||
4023 | end | ||
4024 | end | ||
4025 | end | ||
4026 | local _exp_0 = tb | ||
4027 | local _type_0 = type(_exp_0) | ||
4028 | local _tab_0 = "table" == _type_0 or "userdata" == _type_0 | ||
4029 | local _match_0 = false | ||
4030 | if _tab_0 then | ||
4031 | local result = _exp_0.result | ||
4032 | if true == _exp_0.success and result ~= nil then | ||
4033 | _match_0 = true | ||
4034 | print("success", result) | ||
4035 | end | ||
4036 | end | ||
4037 | if not _match_0 then | ||
4038 | local _match_1 = false | ||
4039 | if _tab_0 then | ||
4040 | if false == _exp_0.success then | ||
4041 | _match_1 = true | ||
4042 | print("failed", result) | ||
4043 | end | ||
4044 | end | ||
4045 | if not _match_1 then | ||
4046 | print("invalid") | ||
4047 | end | ||
4048 | end | ||
4049 | local _exp_0 = tb | ||
4050 | local _type_0 = type(_exp_0) | ||
4051 | local _tab_0 = "table" == _type_0 or "userdata" == _type_0 | ||
4052 | local _match_0 = false | ||
4053 | if _tab_0 then | ||
4054 | local content | ||
4055 | do | ||
4056 | local _obj_0 = _exp_0.data | ||
4057 | local _type_1 = type(_obj_0) | ||
4058 | if "table" == _type_1 or "userdata" == _type_1 then | ||
4059 | content = _obj_0.content | ||
4060 | end | ||
4061 | end | ||
4062 | local _val_0 | ||
4063 | do | ||
4064 | local _obj_0 = _exp_0.data | ||
4065 | if _obj_0 ~= nil then | ||
4066 | _val_0 = _obj_0.type | ||
4067 | end | ||
4068 | end | ||
4069 | if "success" == _val_0 and content ~= nil then | ||
4070 | _match_0 = true | ||
4071 | print("success", content) | ||
4072 | end | ||
4073 | end | ||
4074 | if not _match_0 then | ||
4075 | local _match_1 = false | ||
4076 | if _tab_0 then | ||
4077 | local content | ||
4078 | do | ||
4079 | local _obj_0 = _exp_0.data | ||
4080 | local _type_1 = type(_obj_0) | ||
4081 | if "table" == _type_1 or "userdata" == _type_1 then | ||
4082 | content = _obj_0.content | ||
4083 | end | ||
4084 | end | ||
4085 | local _val_0 | ||
4086 | do | ||
4087 | local _obj_0 = _exp_0.data | ||
4088 | if _obj_0 ~= nil then | ||
4089 | _val_0 = _obj_0.type | ||
4090 | end | ||
4091 | end | ||
4092 | if "error" == _val_0 and content ~= nil then | ||
4093 | _match_1 = true | ||
4094 | print("failed", content) | ||
4095 | end | ||
4096 | end | ||
4097 | if not _match_1 then | ||
4098 | print("invalid") | ||
4099 | end | ||
4100 | end | ||
4101 | local _exp_0 = tb | ||
4102 | local _type_0 = type(_exp_0) | ||
4103 | local _tab_0 = "table" == _type_0 or "userdata" == _type_0 | ||
4104 | if _tab_0 then | ||
4105 | local fourth = _exp_0[4] | ||
4106 | local _val_0 | ||
4107 | do | ||
4108 | local _obj_0 = _exp_0[1] | ||
4109 | if _obj_0 ~= nil then | ||
4110 | _val_0 = _obj_0.a | ||
4111 | end | ||
4112 | end | ||
4113 | local _val_1 | ||
4114 | do | ||
4115 | local _obj_0 = _exp_0[1] | ||
4116 | if _obj_0 ~= nil then | ||
4117 | _val_1 = _obj_0.b | ||
4118 | end | ||
4119 | end | ||
4120 | local _val_2 | ||
4121 | do | ||
4122 | local _obj_0 = _exp_0[2] | ||
4123 | if _obj_0 ~= nil then | ||
4124 | _val_2 = _obj_0.a | ||
4125 | end | ||
4126 | end | ||
4127 | local _val_3 | ||
4128 | do | ||
4129 | local _obj_0 = _exp_0[2] | ||
4130 | if _obj_0 ~= nil then | ||
4131 | _val_3 = _obj_0.b | ||
4132 | end | ||
4133 | end | ||
4134 | local _val_4 | ||
4135 | do | ||
4136 | local _obj_0 = _exp_0[3] | ||
4137 | if _obj_0 ~= nil then | ||
4138 | _val_4 = _obj_0.a | ||
4139 | end | ||
4140 | end | ||
4141 | local _val_5 | ||
4142 | do | ||
4143 | local _obj_0 = _exp_0[3] | ||
4144 | if _obj_0 ~= nil then | ||
4145 | _val_5 = _obj_0.b | ||
4146 | end | ||
4147 | end | ||
4148 | if 1 == _val_0 and 2 == _val_1 and 3 == _val_2 and 4 == _val_3 and 5 == _val_4 and 6 == _val_5 and fourth ~= nil then | ||
4149 | print("matched", fourth) | ||
4150 | end | ||
4151 | end | ||
4152 | local segments = { | ||
4153 | "admin", | ||
4154 | "users", | ||
4155 | "logs", | ||
4156 | "view" | ||
4157 | } | ||
4158 | local _type_0 = type(segments) | ||
4159 | local _tab_0 = "table" == _type_0 or "userdata" == _type_0 | ||
4160 | if _tab_0 then | ||
4161 | local groups | ||
4162 | do | ||
4163 | local _accum_0 = { } | ||
4164 | local _len_0 = 1 | ||
4165 | local _max_0 = #segments + -3 + 1 | ||
4166 | for _index_0 = 1, _max_0 do | ||
4167 | local _item_0 = segments[_index_0] | ||
4168 | _accum_0[_len_0] = _item_0 | ||
4169 | _len_0 = _len_0 + 1 | ||
4170 | end | ||
4171 | groups = _accum_0 | ||
4172 | end | ||
4173 | local resource = segments[#segments - 1] | ||
4174 | local action = segments[#segments] | ||
4175 | if resource ~= nil and action ~= nil then | ||
4176 | print("Group:", groups) | ||
4177 | print("Resource:", resource) | ||
4178 | print("Action:", action) | ||
4179 | end | ||
4180 | end | ||
3291 | local Inventory | 4181 | local Inventory |
3292 | local _class_0 | 4182 | local _class_0 |
3293 | local _base_0 = { | 4183 | local _base_0 = { |
@@ -3944,6 +4834,10 @@ do | |||
3944 | _with_1["key-name"] = value | 4834 | _with_1["key-name"] = value |
3945 | end | 4835 | end |
3946 | _with_0[#_with_0 + 1] = "abc" | 4836 | _with_0[#_with_0 + 1] = "abc" |
4837 | local _with_0 = obj | ||
4838 | if _with_0 ~= nil then | ||
4839 | print(obj.name) | ||
4840 | end | ||
3947 | do | 4841 | do |
3948 | local var = "hello" | 4842 | local var = "hello" |
3949 | print(var) | 4843 | print(var) |