aboutsummaryrefslogtreecommitdiff
path: root/spec/outputs/codes_from_doc.lua
diff options
context:
space:
mode:
authorLi Jin <dragon-fly@qq.com>2026-02-06 10:30:49 +0800
committerLi Jin <dragon-fly@qq.com>2026-02-06 10:30:49 +0800
commitaa3ecc7badfb39cb9167fb95c9a678257c1d9954 (patch)
treea309d9af64ae060e2086c8bcdcf943693c8dcbba /spec/outputs/codes_from_doc.lua
parent03902475c542c3ec4f1884c4217f8a4ef61f3ca8 (diff)
downloadyuescript-aa3ecc7badfb39cb9167fb95c9a678257c1d9954.tar.gz
yuescript-aa3ecc7badfb39cb9167fb95c9a678257c1d9954.tar.bz2
yuescript-aa3ecc7badfb39cb9167fb95c9a678257c1d9954.zip
Fixed docs.
Diffstat (limited to 'spec/outputs/codes_from_doc.lua')
-rw-r--r--spec/outputs/codes_from_doc.lua5148
1 files changed, 0 insertions, 5148 deletions
diff --git a/spec/outputs/codes_from_doc.lua b/spec/outputs/codes_from_doc.lua
deleted file mode 100644
index d74ac16..0000000
--- a/spec/outputs/codes_from_doc.lua
+++ /dev/null
@@ -1,5148 +0,0 @@
1local _module_0 = { }
2local p, to_lua
3do
4 local _obj_0 = require("yue")
5 p, to_lua = _obj_0.p, _obj_0.to_lua
6end
7local inventory = {
8 equipment = {
9 "sword",
10 "shield"
11 },
12 items = {
13 {
14 name = "potion",
15 count = 10
16 },
17 {
18 name = "bread",
19 count = 3
20 }
21 }
22}
23local map
24map = 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
33end
34local filter
35filter = 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
46end
47local reduce
48reduce = 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
54end
55print(reduce(filter(map({
56 1,
57 2,
58 3
59}, function(x)
60 return x * 2
61end), function(x)
62 return x > 4
63end), 0, function(a, b)
64 return a + b
65end))
66local apple = setmetatable({
67 size = 15,
68}, {
69 __index = {
70 color = 0x00ffff
71 }
72})
73if (getmetatable(apple) ~= nil) then
74 p(apple.size, apple.color, getmetatable(apple).__index)
75end
76local _u1f31b = "ζœˆδΉ‹θ„šζœ¬"
77_module_0["πŸŒ›"] = _u1f31b
78return _module_0
79local _module_0 = { }
80local p, to_lua
81do
82 local _obj_0 = require("yue")
83 p, to_lua = _obj_0.p, _obj_0.to_lua
84end
85local inventory = {
86 equipment = {
87 "sword",
88 "shield"
89 },
90 items = {
91 {
92 name = "potion",
93 count = 10
94 },
95 {
96 name = "bread",
97 count = 3
98 }
99 }
100}
101local map
102map = function(arr, action)
103 local _accum_0 = { }
104 local _len_0 = 1
105 for _index_0 = 1, #arr do
106 local item = arr[_index_0]
107 _accum_0[_len_0] = action(item)
108 _len_0 = _len_0 + 1
109 end
110 return _accum_0
111end
112local filter
113filter = function(arr, cond)
114 local _accum_0 = { }
115 local _len_0 = 1
116 for _index_0 = 1, #arr do
117 local item = arr[_index_0]
118 if cond(item) then
119 _accum_0[_len_0] = item
120 _len_0 = _len_0 + 1
121 end
122 end
123 return _accum_0
124end
125local reduce
126reduce = function(arr, init, action)
127 for _index_0 = 1, #arr do
128 local item = arr[_index_0]
129 init = action(init, item)
130 end
131 return init
132end
133print(reduce(filter(map({
134 1,
135 2,
136 3
137}, function(x)
138 return x * 2
139end), function(x)
140 return x > 4
141end), 0, function(a, b)
142 return a + b
143end))
144local apple = setmetatable({
145 size = 15,
146}, {
147 __index = {
148 color = 0x00ffff
149 }
150})
151if (getmetatable(apple) ~= nil) then
152 p(apple.size, apple.color, getmetatable(apple).__index)
153end
154local _u1f31b = "ζœˆδΉ‹θ„šζœ¬"
155_module_0["πŸŒ›"] = _u1f31b
156return _module_0
157local area = 6.2831853071796 * 5
158print('hello world')
159do
160 assert(item ~= nil)
161end
162local value = item
163if (f1() and f2() and f3()) then
164 print("OK")
165end
166do
167 local funcA
168 funcA = function() end
169end
170local funcA
171funcA = function()
172 return "fail to assign to the Yue macro defined variable"
173end
174do
175local function funcB() end
176end
177local funcB
178funcB = function()
179 return "fail to assign to the Lua macro defined variable"
180end
181do
182-- raw Lua codes insertion
183if cond then
184 print("output")
185end
186end
187print("yuescript")
188print(2)
189print("Valid enum type:", "Static")
190do
191 print(123, "hello")
192end
193do
194 print(123, "hello")
195end
196local area = 6.2831853071796 * 5
197print('hello world')
198do
199 assert(item ~= nil)
200end
201local value = item
202if (f1() and f2() and f3()) then
203 print("OK")
204end
205do
206 local funcA
207 funcA = function() end
208end
209local funcA
210funcA = function()
211 return "fail to assign to the Yue macro defined variable"
212end
213do
214local function funcB() end
215end
216local funcB
217funcB = function()
218 return "fail to assign to the Lua macro defined variable"
219end
220do
221-- raw Lua codes insertion
222if cond then
223 print("output")
224end
225end
226print("yuescript")
227print(2)
228print("Valid enum type:", "Static")
229do
230 print(123, "hello")
231end
232do
233 print(123, "hello")
234end
235if tb ~= nil then
236 tb:func()
237end
238if tb ~= nil then
239 tb:func()
240end
241print(1 < 2 and 2 <= 2 and 2 < 3 and 3 == 3 and 3 > 2 and 2 >= 1 and 1 == 1 and 1 < 3 and 3 ~= 5)
242local a = 5
243print(1 <= a and a <= 10)
244local v
245v = function(x)
246 print(x)
247 return x
248end
249print((function()
250 local _cond_0 = v(2)
251 if not (v(1) < _cond_0) then
252 return false
253 else
254 return _cond_0 <= v(3)
255 end
256end)())
257print((function()
258 local _cond_0 = v(2)
259 if not (v(1) > _cond_0) then
260 return false
261 else
262 return _cond_0 <= v(3)
263 end
264end)())
265local tab = { }
266tab[#tab + 1] = "Value"
267local tbA = {
268 1,
269 2,
270 3
271}
272local tbB = {
273 4,
274 5,
275 6
276}
277local _len_0 = #tbA + 1
278for _index_0 = 1, #tbB do
279 local _elm_0 = tbB[_index_0]
280 tbA[_len_0], _len_0 = _elm_0, _len_0 + 1
281end
282local parts = {
283 "shoulders",
284 "knees"
285}
286local lyrics
287do
288 local _tab_0 = {
289 "head"
290 }
291 local _idx_0 = 1
292 for _key_0, _value_0 in pairs(parts) do
293 if _idx_0 == _key_0 then
294 _tab_0[#_tab_0 + 1] = _value_0
295 _idx_0 = _idx_0 + 1
296 else
297 _tab_0[_key_0] = _value_0
298 end
299 end
300 _tab_0[#_tab_0 + 1] = "and"
301 _tab_0[#_tab_0 + 1] = "toes"
302 lyrics = _tab_0
303end
304local copy
305do
306 local _tab_0 = { }
307 local _idx_0 = 1
308 for _key_0, _value_0 in pairs(other) do
309 if _idx_0 == _key_0 then
310 _tab_0[#_tab_0 + 1] = _value_0
311 _idx_0 = _idx_0 + 1
312 else
313 _tab_0[_key_0] = _value_0
314 end
315 end
316 copy = _tab_0
317end
318local a = {
319 1,
320 2,
321 3,
322 x = 1
323}
324local b = {
325 4,
326 5,
327 y = 1
328}
329local merge
330local _tab_0 = { }
331local _idx_0 = 1
332for _key_0, _value_0 in pairs(a) do
333 if _idx_0 == _key_0 then
334 _tab_0[#_tab_0 + 1] = _value_0
335 _idx_0 = _idx_0 + 1
336 else
337 _tab_0[_key_0] = _value_0
338 end
339end
340local _idx_1 = 1
341for _key_0, _value_0 in pairs(b) do
342 if _idx_1 == _key_0 then
343 _tab_0[#_tab_0 + 1] = _value_0
344 _idx_1 = _idx_1 + 1
345 else
346 _tab_0[_key_0] = _value_0
347 end
348end
349merge = _tab_0
350local last
351do
352 local _item_0 = data.items
353 last = _item_0[#_item_0]
354end
355local second_last
356do
357 local _item_0 = data.items
358 second_last = _item_0[#_item_0 - 1]
359end
360local _obj_0 = data.items
361_obj_0[#_obj_0] = 1
362local mt = { }
363local add
364add = function(self, right)
365 return setmetatable({
366 value = self.value + right.value
367 }, mt)
368end
369mt.__add = add
370local a = setmetatable({
371 value = 1
372}, mt)
373local b = setmetatable({
374 value = 2
375}, {
376 __add = add
377})
378local c = setmetatable({
379 value = 3
380}, {
381 __add = mt.__add
382})
383local d = a + b + c
384print(d.value)
385local _ <close> = setmetatable({ }, {
386 __close = function()
387 return print("out of scope")
388 end
389})
390local tb = setmetatable({ }, {
391 ["value"] = 123
392})
393getmetatable(tb).__index = getmetatable(tb)
394print(tb.value)
395setmetatable(tb, {
396 __index = {
397 item = "hello"
398 }
399})
400print(tb.item)
401local item, new, close, getter
402do
403 local _obj_0 = tb
404 item, new = _obj_0[1], _obj_0.new
405 do
406 local _obj_1 = getmetatable(_obj_0)
407 close, getter = _obj_1.__close, _obj_1.__index
408 end
409end
410print(item, new, close, getter)
411do
412 local _obj_0 = func
413 if _obj_0 ~= nil then
414 _obj_0()
415 end
416end
417print((function()
418 local _obj_0 = abc
419 if _obj_0 ~= nil then
420 local _obj_1 = _obj_0["hello world"]
421 if _obj_1 ~= nil then
422 return _obj_1.xyz
423 end
424 return nil
425 end
426 return nil
427end)())
428local x
429do
430 local _obj_0 = tab
431 if _obj_0 ~= nil then
432 x = _obj_0.value
433 end
434end
435local len = (function()
436 local _obj_0 = utf8
437 if _obj_0 ~= nil then
438 return _obj_0.len
439 end
440 return nil
441end)() or (function()
442 local _obj_0 = string
443 if _obj_0 ~= nil then
444 return _obj_0.len
445 end
446 return nil
447end)() or function(o)
448 return #o
449end
450if print and (x ~= nil) then
451 print(x)
452end
453local _with_0 = io.open("test.txt", "w")
454if _with_0 ~= nil then
455 _with_0:write("hello")
456 _with_0:close()
457end
458print("hello")
459print(1, 2)
460print(1, 2, 3)
461print(render(emit(parse(extract(readFile("example.txt"), language, { }), language))))
462local a, b, c, d
463if b ~= nil then
464 a = b
465else
466 if c ~= nil then
467 a = c
468 else
469 a = d
470 end
471end
472func((function()
473 if a ~= nil then
474 return a
475 else
476 return { }
477 end
478end)())
479if a == nil then
480 a = false
481end
482local list = {
483 1,
484 2,
485 3
486}
487func({
488 1,
489 2,
490 3
491})
492local f
493f = function()
494 return {
495 1,
496 2,
497 3
498 }
499end
500local tb = {
501 name = "abc",
502 values = {
503 "a",
504 "b",
505 "c"
506 },
507 objects = {
508 {
509 name = "a",
510 value = 1,
511 func = function(self)
512 return self.value + 1
513 end,
514 tb = {
515 fieldA = 1
516 }
517 },
518 {
519 name = "b",
520 value = 2,
521 func = function(self)
522 return self.value + 2
523 end,
524 tb = { }
525 }
526 }
527}
528if tb ~= nil then
529 tb:func()
530end
531if tb ~= nil then
532 tb:func()
533end
534print(1 < 2 and 2 <= 2 and 2 < 3 and 3 == 3 and 3 > 2 and 2 >= 1 and 1 == 1 and 1 < 3 and 3 ~= 5)
535local a = 5
536print(1 <= a and a <= 10)
537local v
538v = function(x)
539 print(x)
540 return x
541end
542print((function()
543 local _cond_0 = v(2)
544 if not (v(1) < _cond_0) then
545 return false
546 else
547 return _cond_0 <= v(3)
548 end
549end)())
550print((function()
551 local _cond_0 = v(2)
552 if not (v(1) > _cond_0) then
553 return false
554 else
555 return _cond_0 <= v(3)
556 end
557end)())
558local tab = { }
559tab[#tab + 1] = "Value"
560local tbA = {
561 1,
562 2,
563 3
564}
565local tbB = {
566 4,
567 5,
568 6
569}
570local _len_0 = #tbA + 1
571for _index_0 = 1, #tbB do
572 local _elm_0 = tbB[_index_0]
573 tbA[_len_0], _len_0 = _elm_0, _len_0 + 1
574end
575local parts = {
576 "shoulders",
577 "knees"
578}
579local lyrics
580do
581 local _tab_0 = {
582 "head"
583 }
584 local _idx_0 = 1
585 for _key_0, _value_0 in pairs(parts) do
586 if _idx_0 == _key_0 then
587 _tab_0[#_tab_0 + 1] = _value_0
588 _idx_0 = _idx_0 + 1
589 else
590 _tab_0[_key_0] = _value_0
591 end
592 end
593 _tab_0[#_tab_0 + 1] = "and"
594 _tab_0[#_tab_0 + 1] = "toes"
595 lyrics = _tab_0
596end
597local copy
598do
599 local _tab_0 = { }
600 local _idx_0 = 1
601 for _key_0, _value_0 in pairs(other) do
602 if _idx_0 == _key_0 then
603 _tab_0[#_tab_0 + 1] = _value_0
604 _idx_0 = _idx_0 + 1
605 else
606 _tab_0[_key_0] = _value_0
607 end
608 end
609 copy = _tab_0
610end
611local a = {
612 1,
613 2,
614 3,
615 x = 1
616}
617local b = {
618 4,
619 5,
620 y = 1
621}
622local merge
623local _tab_0 = { }
624local _idx_0 = 1
625for _key_0, _value_0 in pairs(a) do
626 if _idx_0 == _key_0 then
627 _tab_0[#_tab_0 + 1] = _value_0
628 _idx_0 = _idx_0 + 1
629 else
630 _tab_0[_key_0] = _value_0
631 end
632end
633local _idx_1 = 1
634for _key_0, _value_0 in pairs(b) do
635 if _idx_1 == _key_0 then
636 _tab_0[#_tab_0 + 1] = _value_0
637 _idx_1 = _idx_1 + 1
638 else
639 _tab_0[_key_0] = _value_0
640 end
641end
642merge = _tab_0
643local last
644do
645 local _item_0 = data.items
646 last = _item_0[#_item_0]
647end
648local second_last
649do
650 local _item_0 = data.items
651 second_last = _item_0[#_item_0 - 1]
652end
653local _obj_0 = data.items
654_obj_0[#_obj_0] = 1
655local mt = { }
656local add
657add = function(self, right)
658 return setmetatable({
659 value = self.value + right.value
660 }, mt)
661end
662mt.__add = add
663local a = setmetatable({
664 value = 1
665}, mt)
666local b = setmetatable({
667 value = 2
668}, {
669 __add = add
670})
671local c = setmetatable({
672 value = 3
673}, {
674 __add = mt.__add
675})
676local d = a + b + c
677print(d.value)
678local _ <close> = setmetatable({ }, {
679 __close = function()
680 return print("out of scope")
681 end
682})
683local tb = setmetatable({ }, {
684 ["value"] = 123
685})
686getmetatable(tb).__index = getmetatable(tb)
687print(tb.value)
688setmetatable(tb, {
689 __index = {
690 item = "hello"
691 }
692})
693print(tb.item)
694local item, new, close, getter
695do
696 local _obj_0 = tb
697 item, new = _obj_0[1], _obj_0.new
698 do
699 local _obj_1 = getmetatable(_obj_0)
700 close, getter = _obj_1.__close, _obj_1.__index
701 end
702end
703print(item, new, close, getter)
704do
705 local _obj_0 = func
706 if _obj_0 ~= nil then
707 _obj_0()
708 end
709end
710print((function()
711 local _obj_0 = abc
712 if _obj_0 ~= nil then
713 local _obj_1 = _obj_0["hello world"]
714 if _obj_1 ~= nil then
715 return _obj_1.xyz
716 end
717 return nil
718 end
719 return nil
720end)())
721local x
722do
723 local _obj_0 = tab
724 if _obj_0 ~= nil then
725 x = _obj_0.value
726 end
727end
728local len = (function()
729 local _obj_0 = utf8
730 if _obj_0 ~= nil then
731 return _obj_0.len
732 end
733 return nil
734end)() or (function()
735 local _obj_0 = string
736 if _obj_0 ~= nil then
737 return _obj_0.len
738 end
739 return nil
740end)() or function(o)
741 return #o
742end
743if print and (x ~= nil) then
744 print(x)
745end
746local _with_0 = io.open("test.txt", "w")
747if _with_0 ~= nil then
748 _with_0:write("hello")
749 _with_0:close()
750end
751print("hello")
752print(1, 2)
753print(1, 2, 3)
754print(render(emit(parse(extract(readFile("example.txt"), language, { }), language))))
755local a, b, c, d
756if b ~= nil then
757 a = b
758else
759 if c ~= nil then
760 a = c
761 else
762 a = d
763 end
764end
765func((function()
766 if a ~= nil then
767 return a
768 else
769 return { }
770 end
771end)())
772if a == nil then
773 a = false
774end
775local list = {
776 1,
777 2,
778 3
779}
780func({
781 1,
782 2,
783 3
784})
785local f
786f = function()
787 return {
788 1,
789 2,
790 3
791 }
792end
793local tb = {
794 name = "abc",
795 values = {
796 "a",
797 "b",
798 "c"
799 },
800 objects = {
801 {
802 name = "a",
803 value = 1,
804 func = function(self)
805 return self.value + 1
806 end,
807 tb = {
808 fieldA = 1
809 }
810 },
811 {
812 name = "b",
813 value = 2,
814 func = function(self)
815 return self.value + 2
816 end,
817 tb = { }
818 }
819 }
820}
821do
822 local insert, concat = table.insert, table.concat
823 local C, Ct, Cmt
824 do
825 local _obj_0 = require("lpeg")
826 C, Ct, Cmt = _obj_0.C, _obj_0.Ct, _obj_0.Cmt
827 end
828 local x, y, z
829 do
830 local _obj_0 = require('mymodule')
831 x, y, z = _obj_0.x, _obj_0.y, _obj_0.z
832 end
833 local a, b, c
834 local _obj_0 = require('module')
835 a, b, c = _obj_0.a, _obj_0.b, _obj_0.c
836end
837do
838 local module = require('module')
839 local module_x = require('module_x')
840 local d_a_s_h_e_s = require("d-a-s-h-e-s")
841 local part = require("module.part")
842end
843do
844 local PlayerModule = require("player")
845 local C, Ct, Cmt
846 do
847 local _obj_0 = require("lpeg")
848 C, Ct, Cmt = _obj_0.C, _obj_0.Ct, _obj_0.Cmt
849 end
850 local one, two, ch
851 local _obj_0 = require("export")
852 one, two, ch = _obj_0[1], _obj_0[2], _obj_0.Something.umm[1]
853end
854do
855 local tostring <const> = tostring
856 local concat <const> = table.concat
857 print(concat({
858 "a",
859 tostring(1)
860 }))
861end
862do
863 local print <const> = print
864 local math <const> = math
865 print("hello")
866 math.random(3)
867end
868do
869 local print <const> = print
870 print(FLAG)
871 FLAG = 123
872end
873local _module_0 = { }
874local a, b, c = 1, 2, 3
875_module_0["a"], _module_0["b"], _module_0["c"] = a, b, c
876local cool = "cat"
877_module_0["cool"] = cool
878local What
879if this then
880 What = "abc"
881else
882 What = "def"
883end
884_module_0["What"] = What
885local y
886y = function()
887 local hallo = 3434
888end
889_module_0["y"] = y
890local Something
891local _class_0
892local _base_0 = {
893 umm = "cool"
894}
895if _base_0.__index == nil then
896 _base_0.__index = _base_0
897end
898_class_0 = setmetatable({
899 __init = function() end,
900 __base = _base_0,
901 __name = "Something"
902}, {
903 __index = _base_0,
904 __call = function(cls, ...)
905 local _self_0 = setmetatable({ }, _base_0)
906 cls.__init(_self_0, ...)
907 return _self_0
908 end
909})
910_base_0.__class = _class_0
911Something = _class_0
912_module_0["Something"] = Something
913return _module_0
914local _module_0 = { }
915local loadstring, tolua
916do
917 local _obj_0 = yue
918 loadstring, tolua = _obj_0.loadstring, _obj_0.to_lua
919end
920_module_0["loadstring"], _module_0["tolua"] = loadstring, tolua
921local fieldA = tb.itemA.fieldA
922if fieldA == nil then
923 fieldA = 'default'
924end
925_module_0["fieldA"] = fieldA
926return _module_0
927local _module_0 = setmetatable({ }, { })
928_module_0.itemA = tb
929getmetatable(_module_0).__index = items
930_module_0["a-b-c"] = 123
931return _module_0
932local _module_0 = { }
933local d, e, f = 3, 2, 1
934_module_0[#_module_0 + 1] = d
935_module_0[#_module_0 + 1] = e
936_module_0[#_module_0 + 1] = f
937if this then
938 _module_0[#_module_0 + 1] = 123
939else
940 _module_0[#_module_0 + 1] = 456
941end
942local _with_0 = tmp
943local j = 2000
944_module_0[#_module_0 + 1] = _with_0
945return _module_0
946local _module_0 = nil
947_module_0 = function()
948 print("hello")
949 return 123
950end
951return _module_0
952do
953 local insert, concat = table.insert, table.concat
954 local C, Ct, Cmt
955 do
956 local _obj_0 = require("lpeg")
957 C, Ct, Cmt = _obj_0.C, _obj_0.Ct, _obj_0.Cmt
958 end
959 local x, y, z
960 do
961 local _obj_0 = require('mymodule')
962 x, y, z = _obj_0.x, _obj_0.y, _obj_0.z
963 end
964 local a, b, c
965 local _obj_0 = require('module')
966 a, b, c = _obj_0.a, _obj_0.b, _obj_0.c
967end
968do
969 local module = require('module')
970 local module_x = require('module_x')
971 local d_a_s_h_e_s = require("d-a-s-h-e-s")
972 local part = require("module.part")
973end
974do
975 local PlayerModule = require("player")
976 local C, Ct, Cmt
977 do
978 local _obj_0 = require("lpeg")
979 C, Ct, Cmt = _obj_0.C, _obj_0.Ct, _obj_0.Cmt
980 end
981 local one, two, ch
982 local _obj_0 = require("export")
983 one, two, ch = _obj_0[1], _obj_0[2], _obj_0.Something.umm[1]
984end
985do
986 local tostring <const> = tostring
987 local concat <const> = table.concat
988 print(concat({
989 "a",
990 tostring(1)
991 }))
992end
993do
994 local print <const> = print
995 local math <const> = math
996 print("hello")
997 math.random(3)
998end
999do
1000 local print <const> = print
1001 print(FLAG)
1002 FLAG = 123
1003end
1004local _module_0 = { }
1005local a, b, c = 1, 2, 3
1006_module_0["a"], _module_0["b"], _module_0["c"] = a, b, c
1007local cool = "cat"
1008_module_0["cool"] = cool
1009local What
1010if this then
1011 What = "abc"
1012else
1013 What = "def"
1014end
1015_module_0["What"] = What
1016local y
1017y = function()
1018 local hallo = 3434
1019end
1020_module_0["y"] = y
1021local Something
1022local _class_0
1023local _base_0 = {
1024 umm = "cool"
1025}
1026if _base_0.__index == nil then
1027 _base_0.__index = _base_0
1028end
1029_class_0 = setmetatable({
1030 __init = function() end,
1031 __base = _base_0,
1032 __name = "Something"
1033}, {
1034 __index = _base_0,
1035 __call = function(cls, ...)
1036 local _self_0 = setmetatable({ }, _base_0)
1037 cls.__init(_self_0, ...)
1038 return _self_0
1039 end
1040})
1041_base_0.__class = _class_0
1042Something = _class_0
1043_module_0["Something"] = Something
1044return _module_0
1045local _module_0 = { }
1046local loadstring, tolua
1047do
1048 local _obj_0 = yue
1049 loadstring, tolua = _obj_0.loadstring, _obj_0.to_lua
1050end
1051_module_0["loadstring"], _module_0["tolua"] = loadstring, tolua
1052local fieldA = tb.itemA.fieldA
1053if fieldA == nil then
1054 fieldA = 'default'
1055end
1056_module_0["fieldA"] = fieldA
1057return _module_0
1058local _module_0 = setmetatable({ }, { })
1059_module_0.itemA = tb
1060getmetatable(_module_0).__index = items
1061_module_0["a-b-c"] = 123
1062return _module_0
1063local _module_0 = { }
1064local d, e, f = 3, 2, 1
1065_module_0[#_module_0 + 1] = d
1066_module_0[#_module_0 + 1] = e
1067_module_0[#_module_0 + 1] = f
1068if this then
1069 _module_0[#_module_0 + 1] = 123
1070else
1071 _module_0[#_module_0 + 1] = 456
1072end
1073local _with_0 = tmp
1074local j = 2000
1075_module_0[#_module_0 + 1] = _with_0
1076return _module_0
1077local _module_0 = nil
1078_module_0 = function()
1079 print("hello")
1080 return 123
1081end
1082return _module_0
1083local hello = "world"
1084local a, b, c = 1, 2, 3
1085hello = 123
1086local x = 1
1087x = x + 1
1088x = x - 1
1089x = x * 10
1090x = x / 10
1091x = x % 10
1092local s = s .. "world"
1093local arg = arg or "default value"
1094local a = 0
1095local b = 0
1096local c = 0
1097local d = 0
1098local e = 0
1099local x = f()
1100local y = x
1101local z = x
1102do
1103 local a = 1
1104 local x, y, z
1105 print("forward declare all variables as locals")
1106 x = function()
1107 return 1 + y + z
1108 end
1109 y, z = 2, 3
1110 instance = Item:new()
1111end
1112do
1113 local X = 1
1114 local B
1115 print("only forward declare upper case variables")
1116 local a = 1
1117 B = 2
1118end
1119do
1120 a = 1
1121 print("declare all variables as globals")
1122 x = function()
1123 return 1 + y + z
1124 end
1125 y, z = 2, 3
1126end
1127do
1128 X = 1
1129 print("only declare upper case variables as globals")
1130 local a = 1
1131 B = 2
1132 local Temp = "a local value"
1133end
1134local hello = "world"
1135local a, b, c = 1, 2, 3
1136hello = 123
1137local x = 1
1138x = x + 1
1139x = x - 1
1140x = x * 10
1141x = x / 10
1142x = x % 10
1143local s = s .. "world"
1144local arg = arg or "default value"
1145local a = 0
1146local b = 0
1147local c = 0
1148local d = 0
1149local e = 0
1150local x = f()
1151local y = x
1152local z = x
1153do
1154 local a = 1
1155 local x, y, z
1156 print("forward declare all variables as locals")
1157 x = function()
1158 return 1 + y + z
1159 end
1160 y, z = 2, 3
1161 instance = Item:new()
1162end
1163do
1164 local X = 1
1165 local B
1166 print("only forward declare upper case variables")
1167 local a = 1
1168 B = 2
1169end
1170do
1171 a = 1
1172 print("declare all variables as globals")
1173 x = function()
1174 return 1 + y + z
1175 end
1176 y, z = 2, 3
1177end
1178do
1179 X = 1
1180 print("only declare upper case variables as globals")
1181 local a = 1
1182 B = 2
1183 local Temp = "a local value"
1184end
1185local thing = {
1186 1,
1187 2
1188}
1189local a, b = thing[1], thing[2]
1190print(a, b)
1191local obj = {
1192 hello = "world",
1193 day = "tuesday",
1194 length = 20
1195}
1196local hello, the_day = obj.hello, obj.day
1197print(hello, the_day)
1198local day = obj.day
1199local obj2 = {
1200 numbers = {
1201 1,
1202 2,
1203 3,
1204 4
1205 },
1206 properties = {
1207 color = "green",
1208 height = 13.5
1209 }
1210}
1211local first, second, color = obj2.numbers[1], obj2.numbers[2], obj2.properties.color
1212print(first, second, color)
1213local first, second, color
1214local _obj_0 = obj2
1215first, second, color = _obj_0.numbers[1], _obj_0.numbers[2], _obj_0.properties.color
1216local concat, insert
1217local _obj_0 = table
1218concat, insert = _obj_0.concat, _obj_0.insert
1219local mix, max, rand
1220local _obj_0 = math
1221mix, max, rand = _obj_0.mix, _obj_0.max, _obj_0.random
1222local name, job
1223local _obj_0 = person
1224name, job = _obj_0.name, _obj_0.job
1225if name == nil then
1226 name = "nameless"
1227end
1228if job == nil then
1229 job = "jobless"
1230end
1231local two, four
1232local _obj_0 = items
1233two, four = _obj_0[2], _obj_0[4]
1234local orders = {
1235 "first",
1236 "second",
1237 "third",
1238 "fourth",
1239 "last"
1240}
1241local first, bulk, last = orders[1], (function()
1242 local _accum_0 = { }
1243 local _len_0 = 1
1244 local _max_0 = #orders + -2 + 1
1245 for _index_0 = 2, _max_0 do
1246 local _item_0 = orders[_index_0]
1247 _accum_0[_len_0] = _item_0
1248 _len_0 = _len_0 + 1
1249 end
1250 return _accum_0
1251end)(), orders[#orders]
1252print(first)
1253print(bulk)
1254print(last)
1255local first, rest
1256do
1257 local _obj_0 = orders
1258 first, rest = _obj_0[1], (function()
1259 local _accum_0 = { }
1260 local _len_0 = 1
1261 local _max_0 = #_obj_0
1262 for _index_0 = 2, _max_0 do
1263 local _item_0 = _obj_0[_index_0]
1264 _accum_0[_len_0] = _item_0
1265 _len_0 = _len_0 + 1
1266 end
1267 return _accum_0
1268 end)()
1269end
1270local start, last
1271do
1272 local _obj_0 = orders
1273 start, last = (function()
1274 local _accum_0 = { }
1275 local _len_0 = 1
1276 local _max_0 = #_obj_0 + -2 + 1
1277 for _index_0 = 1, _max_0 do
1278 local _item_0 = _obj_0[_index_0]
1279 _accum_0[_len_0] = _item_0
1280 _len_0 = _len_0 + 1
1281 end
1282 return _accum_0
1283 end)(), _obj_0[#_obj_0]
1284end
1285local _obj_0 = orders
1286first, last = _obj_0[1], _obj_0[#_obj_0]
1287local tuples = {
1288 {
1289 "hello",
1290 "world"
1291 },
1292 {
1293 "egg",
1294 "head"
1295 }
1296}
1297for _index_0 = 1, #tuples do
1298 local _des_0 = tuples[_index_0]
1299 local left, right = _des_0[1], _des_0[2]
1300 print(left, right)
1301end
1302local thing = {
1303 1,
1304 2
1305}
1306local a, b = thing[1], thing[2]
1307print(a, b)
1308local obj = {
1309 hello = "world",
1310 day = "tuesday",
1311 length = 20
1312}
1313local hello, the_day = obj.hello, obj.day
1314print(hello, the_day)
1315local day = obj.day
1316local obj2 = {
1317 numbers = {
1318 1,
1319 2,
1320 3,
1321 4
1322 },
1323 properties = {
1324 color = "green",
1325 height = 13.5
1326 }
1327}
1328local first, second, color = obj2.numbers[1], obj2.numbers[2], obj2.properties.color
1329print(first, second, color)
1330local first, second, color
1331local _obj_0 = obj2
1332first, second, color = _obj_0.numbers[1], _obj_0.numbers[2], _obj_0.properties.color
1333local concat, insert
1334local _obj_0 = table
1335concat, insert = _obj_0.concat, _obj_0.insert
1336local mix, max, rand
1337local _obj_0 = math
1338mix, max, rand = _obj_0.mix, _obj_0.max, _obj_0.random
1339local name, job
1340local _obj_0 = person
1341name, job = _obj_0.name, _obj_0.job
1342if name == nil then
1343 name = "nameless"
1344end
1345if job == nil then
1346 job = "jobless"
1347end
1348local two, four
1349local _obj_0 = items
1350two, four = _obj_0[2], _obj_0[4]
1351local orders = {
1352 "first",
1353 "second",
1354 "third",
1355 "fourth",
1356 "last"
1357}
1358local first, bulk, last = orders[1], (function()
1359 local _accum_0 = { }
1360 local _len_0 = 1
1361 local _max_0 = #orders + -2 + 1
1362 for _index_0 = 2, _max_0 do
1363 local _item_0 = orders[_index_0]
1364 _accum_0[_len_0] = _item_0
1365 _len_0 = _len_0 + 1
1366 end
1367 return _accum_0
1368end)(), orders[#orders]
1369print(first)
1370print(bulk)
1371print(last)
1372local first, rest
1373do
1374 local _obj_0 = orders
1375 first, rest = _obj_0[1], (function()
1376 local _accum_0 = { }
1377 local _len_0 = 1
1378 local _max_0 = #_obj_0
1379 for _index_0 = 2, _max_0 do
1380 local _item_0 = _obj_0[_index_0]
1381 _accum_0[_len_0] = _item_0
1382 _len_0 = _len_0 + 1
1383 end
1384 return _accum_0
1385 end)()
1386end
1387local start, last
1388do
1389 local _obj_0 = orders
1390 start, last = (function()
1391 local _accum_0 = { }
1392 local _len_0 = 1
1393 local _max_0 = #_obj_0 + -2 + 1
1394 for _index_0 = 1, _max_0 do
1395 local _item_0 = _obj_0[_index_0]
1396 _accum_0[_len_0] = _item_0
1397 _len_0 = _len_0 + 1
1398 end
1399 return _accum_0
1400 end)(), _obj_0[#_obj_0]
1401end
1402local _obj_0 = orders
1403first, last = _obj_0[1], _obj_0[#_obj_0]
1404local tuples = {
1405 {
1406 "hello",
1407 "world"
1408 },
1409 {
1410 "egg",
1411 "head"
1412 }
1413}
1414for _index_0 = 1, #tuples do
1415 local _des_0 = tuples[_index_0]
1416 local left, right = _des_0[1], _des_0[2]
1417 print(left, right)
1418end
1419local user = database.find_user("moon")
1420if user then
1421 print(user.name)
1422end
1423local hello = os.getenv("hello")
1424if hello then
1425 print("You have hello", hello)
1426else
1427 local world = os.getenv("world")
1428 if world then
1429 print("you have world", world)
1430 else
1431 print("nothing :(")
1432 end
1433end
1434do
1435 local success, result = pcall(function()
1436 return "get result without problems"
1437 end)
1438 if success then
1439 print(result)
1440 end
1441end
1442print("OK")
1443repeat
1444 local byte = stream:read_one()
1445 if byte then
1446 print(byte)
1447 else
1448 break
1449 end
1450until false
1451local user = database.find_user("moon")
1452if user then
1453 print(user.name)
1454end
1455local hello = os.getenv("hello")
1456if hello then
1457 print("You have hello", hello)
1458else
1459 local world = os.getenv("world")
1460 if world then
1461 print("you have world", world)
1462 else
1463 print("nothing :(")
1464 end
1465end
1466do
1467 local success, result = pcall(function()
1468 return "get result without problems"
1469 end)
1470 if success then
1471 print(result)
1472 end
1473end
1474print("OK")
1475repeat
1476 local byte = stream:read_one()
1477 if byte then
1478 print(byte)
1479 else
1480 break
1481 end
1482until false
1483local list = {
1484 1,
1485 2,
1486 3,
1487 4,
1488 5
1489}
1490local fn
1491fn = function(ok)
1492 return ok, table.unpack(list)
1493end
1494(function(_arg_0, ...)
1495 local ok = _arg_0
1496 local count = select('#', ...)
1497 local first = select(1, ...)
1498 return print(ok, count, first)
1499end)(fn(true))
1500local list = {
1501 1,
1502 2,
1503 3,
1504 4,
1505 5
1506}
1507local fn
1508fn = function(ok)
1509 return ok, table.unpack(list)
1510end
1511(function(_arg_0, ...)
1512 local ok = _arg_0
1513 local count = select('#', ...)
1514 local first = select(1, ...)
1515 return print(ok, count, first)
1516end)(fn(true))
1517local a = 1
1518local b = 2
1519print(a + b)
1520Rx.Observable.fromRange(1, 8):filter(function(x)
1521 return x % 2 == 0
1522end):concat(Rx.Observable.of('who do we appreciate')):map(function(value)
1523 return value .. '!'
1524end):subscribe(print)
1525local a = 1
1526local b = 2
1527print(a + b)
1528Rx.Observable.fromRange(1, 8):filter(function(x)
1529 return x % 2 == 0
1530end):concat(Rx.Observable.of('who do we appreciate')):map(function(value)
1531 return value .. '!'
1532end):subscribe(print)
1533local str = strA .. strB .. strC
1534func(3000, "192.168.1.1")
1535local str = strA .. strB .. strC
1536func(3000, "192.168.1.1")
1537xpcall(function()
1538 return func(1, 2, 3)
1539end, function(err)
1540 return print(yue.traceback(err))
1541end)
1542local success, result = xpcall(function()
1543 return func(1, 2, 3)
1544end, function(err)
1545 return yue.traceback(err)
1546end)
1547xpcall(function()
1548 return func(1, 2, 3)
1549end, function(err)
1550 return print(yue.traceback(err))
1551end)
1552success, result = pcall(function()
1553 return func(1, 2, 3)
1554end)
1555pcall(function()
1556 print("trying")
1557 return func(1, 2, 3)
1558end)
1559success, result = xpcall(function()
1560 return func(1, 2, 3)
1561end, function(err)
1562 return print(yue.traceback(err))
1563end)
1564if success then
1565 print(result)
1566end
1567local a, b, c
1568do
1569 local _ok_0, _ret_0, _ret_1, _ret_2 = pcall(function()
1570 return func()
1571 end)
1572 if _ok_0 then
1573 a, b, c = _ret_0, _ret_1, _ret_2
1574 end
1575end
1576do
1577 local _exp_0 = ((function()
1578 return (function(_arg_0, ...)
1579 local _ok_0 = _arg_0
1580 if _ok_0 then
1581 return ...
1582 end
1583 end)(pcall(function()
1584 return func()
1585 end))
1586 end)())
1587 if _exp_0 ~= nil then
1588 a = _exp_0
1589 else
1590 a = "default"
1591 end
1592end
1593f((function()
1594 return (function(_arg_0, ...)
1595 local _ok_0 = _arg_0
1596 if _ok_0 then
1597 return ...
1598 end
1599 end)(pcall(function()
1600 return func()
1601 end))
1602end)())
1603f((function()
1604 return (function(_arg_0, ...)
1605 local _ok_0 = _arg_0
1606 if _ok_0 then
1607 return ...
1608 end
1609 end)(xpcall(function()
1610 print(123)
1611 return func()
1612 end, function(e)
1613 print(e)
1614 return e
1615 end))
1616end)())
1617xpcall(function()
1618 return func(1, 2, 3)
1619end, function(err)
1620 return print(yue.traceback(err))
1621end)
1622local success, result = xpcall(function()
1623 return func(1, 2, 3)
1624end, function(err)
1625 return yue.traceback(err)
1626end)
1627xpcall(function()
1628 return func(1, 2, 3)
1629end, function(err)
1630 return print(yue.traceback(err))
1631end)
1632success, result = pcall(function()
1633 return func(1, 2, 3)
1634end)
1635pcall(function()
1636 print("trying")
1637 return func(1, 2, 3)
1638end)
1639success, result = xpcall(function()
1640 return func(1, 2, 3)
1641end, function(err)
1642 return print(yue.traceback(err))
1643end)
1644if success then
1645 print(result)
1646end
1647local a, b, c
1648do
1649 local _ok_0, _ret_0, _ret_1, _ret_2 = pcall(function()
1650 return func()
1651 end)
1652 if _ok_0 then
1653 a, b, c = _ret_0, _ret_1, _ret_2
1654 end
1655end
1656do
1657 local _exp_0 = ((function()
1658 return (function(_arg_0, ...)
1659 local _ok_0 = _arg_0
1660 if _ok_0 then
1661 return ...
1662 end
1663 end)(pcall(function()
1664 return func()
1665 end))
1666 end)())
1667 if _exp_0 ~= nil then
1668 a = _exp_0
1669 else
1670 a = "default"
1671 end
1672end
1673f((function()
1674 return (function(_arg_0, ...)
1675 local _ok_0 = _arg_0
1676 if _ok_0 then
1677 return ...
1678 end
1679 end)(pcall(function()
1680 return func()
1681 end))
1682end)())
1683f((function()
1684 return (function(_arg_0, ...)
1685 local _ok_0 = _arg_0
1686 if _ok_0 then
1687 return ...
1688 end
1689 end)(xpcall(function()
1690 print(123)
1691 return func()
1692 end, function(e)
1693 print(e)
1694 return e
1695 end))
1696end)())
1697local a <const> = 123
1698local _ <close> = setmetatable({ }, {
1699 __close = function()
1700 return print("Out of scope.")
1701 end
1702})
1703local a, b, c, d
1704local _obj_0 = tb
1705a, b, c, d = _obj_0.a, _obj_0.b, _obj_0[1], _obj_0[2]
1706Constant = 123
1707local a <const> = 123
1708local _ <close> = setmetatable({ }, {
1709 __close = function()
1710 return print("Out of scope.")
1711 end
1712})
1713local a, b, c, d
1714local _obj_0 = tb
1715a, b, c, d = _obj_0.a, _obj_0.b, _obj_0[1], _obj_0[2]
1716Constant = 123
1717local some_string = "Here is a string\n that has a line break in it."
1718print("I am " .. tostring(math.random() * 100) .. "% sure.")
1719local integer = 1000000
1720local hex = 0xEFBBBF
1721local binary = 19
1722local str = "key: value\nlist:\n - item1\n - " .. tostring(expr)
1723local fn
1724fn = function()
1725 local str = "foo:\n bar: baz"
1726 return str
1727end
1728local str = "path: \"C:\\Program Files\\App\"\nnote: 'He said: \"" .. tostring(Hello) .. "!\"'"
1729local some_string = "Here is a string\n that has a line break in it."
1730print("I am " .. tostring(math.random() * 100) .. "% sure.")
1731local integer = 1000000
1732local hex = 0xEFBBBF
1733local binary = 19
1734local str = "key: value\nlist:\n - item1\n - " .. tostring(expr)
1735local fn
1736fn = function()
1737 local str = "foo:\n bar: baz"
1738 return str
1739end
1740local str = "path: \"C:\\Program Files\\App\"\nnote: 'He said: \"" .. tostring(Hello) .. "!\"'"
1741local my_function
1742my_function = function() end
1743my_function()
1744local func_a
1745func_a = function()
1746 return print("hello world")
1747end
1748local func_b
1749func_b = function()
1750 local value = 100
1751 return print("The value:", value)
1752end
1753func_a()
1754func_b()
1755local sum
1756sum = function(x, y)
1757 return print("sum", x + y)
1758end
1759sum(10, 20)
1760print(sum(10, 20))
1761a(b(c("a", "b", "c")))
1762print("x:", sum(10, 20), "y:", sum(30, 40))
1763local sum
1764sum = function(x, y)
1765 return x + y
1766end
1767print("The sum is ", sum(10, 20))
1768local sum
1769sum = function(x, y)
1770 return x + y
1771end
1772local mystery
1773mystery = function(x, y)
1774 return x + y, x - y
1775end
1776local a, b = mystery(10, 20)
1777local func
1778func = function(self, num)
1779 return self.value + num
1780end
1781local my_function
1782my_function = function(name, height)
1783 if name == nil then
1784 name = "something"
1785 end
1786 if height == nil then
1787 height = 100
1788 end
1789 print("Hello I am", name)
1790 return print("My height is", height)
1791end
1792local some_args
1793some_args = function(x, y)
1794 if x == nil then
1795 x = 100
1796 end
1797 if y == nil then
1798 y = x + 1000
1799 end
1800 return print(x + y)
1801end
1802local a = x - 10
1803local b = x - 10
1804local c = x(-y)
1805local d = x - z
1806local x = func("hello") + 100
1807local y = func("hello" + 100)
1808my_func(5, 4, 3, 8, 9, 10)
1809cool_func(1, 2, 3, 4, 5, 6, 7, 8)
1810my_func(5, 6, 7, 6, another_func(6, 7, 8, 9, 1, 2), 5, 4)
1811local x = {
1812 1,
1813 2,
1814 3,
1815 4,
1816 a_func(4, 5, 5, 6),
1817 8,
1818 9,
1819 10
1820}
1821local y = {
1822 my_func(1, 2, 3, 4, 5),
1823 5,
1824 6,
1825 7
1826}
1827if func(1, 2, 3, "hello", "world") then
1828 print("hello")
1829 print("I am inside if")
1830end
1831if func(1, 2, 3, "hello", "world") then
1832 print("hello")
1833 print("I am inside if")
1834end
1835local f1
1836f1 = function(_arg_0)
1837 local a, b, c
1838 a, b, c = _arg_0.a, _arg_0.b, _arg_0.c
1839 return print(a, b, c)
1840end
1841f1({
1842 a = 1,
1843 b = "2",
1844 c = { }
1845})
1846local f2
1847f2 = function(_arg_0, c)
1848 local a1, b
1849 a1, b = _arg_0.a, _arg_0.b
1850 if a1 == nil then
1851 a1 = 123
1852 end
1853 if b == nil then
1854 b = 'abc'
1855 end
1856 if c == nil then
1857 c = { }
1858 end
1859 return print(a1, b, c)
1860end
1861local arg1 = {
1862 a = 0
1863}
1864f2(arg1, arg2)
1865local findFirstEven
1866findFirstEven = function(list)
1867 for _index_0 = 1, #list do
1868 local item = list[_index_0]
1869 if type(item) == "table" then
1870 for _index_1 = 1, #item do
1871 local sub = item[_index_1]
1872 if sub % 2 == 0 then
1873 return sub
1874 end
1875 end
1876 end
1877 end
1878 return nil
1879end
1880local findFirstEven
1881findFirstEven = function(list)
1882 for _index_0 = 1, #list do
1883 local item = list[_index_0]
1884 if type(item) == "table" then
1885 for _index_1 = 1, #item do
1886 local sub = item[_index_1]
1887 if sub % 2 == 0 then
1888 return sub
1889 end
1890 end
1891 end
1892 end
1893 return nil
1894end
1895local f
1896f = function(...)
1897 local t = {
1898 n = select("#", ...),
1899 ...
1900 }
1901 print("argument count:", t.n)
1902 print("table length:", #t)
1903 for i = 1, t.n do
1904 print(t[i])
1905 end
1906end
1907f(1, 2, 3)
1908f("a", "b", "c", "d")
1909f()
1910local process
1911process = function(...)
1912 local args = {
1913 n = select("#", ...),
1914 ...
1915 }
1916 local sum = 0
1917 for i = 1, args.n do
1918 if args[i] ~= nil and type(args[i]) == "number" then
1919 sum = sum + args[i]
1920 end
1921 end
1922 return sum
1923end
1924process(1, nil, 3, nil, 5)
1925local my_function
1926my_function = function() end
1927my_function()
1928local func_a
1929func_a = function()
1930 return print("hello world")
1931end
1932local func_b
1933func_b = function()
1934 local value = 100
1935 return print("The value:", value)
1936end
1937func_a()
1938func_b()
1939local sum
1940sum = function(x, y)
1941 return print("sum", x + y)
1942end
1943sum(10, 20)
1944print(sum(10, 20))
1945a(b(c("a", "b", "c")))
1946print("x:", sum(10, 20), "y:", sum(30, 40))
1947local sum
1948sum = function(x, y)
1949 return x + y
1950end
1951print("The sum is ", sum(10, 20))
1952local sum
1953sum = function(x, y)
1954 return x + y
1955end
1956local mystery
1957mystery = function(x, y)
1958 return x + y, x - y
1959end
1960local a, b = mystery(10, 20)
1961local func
1962func = function(self, num)
1963 return self.value + num
1964end
1965local my_function
1966my_function = function(name, height)
1967 if name == nil then
1968 name = "something"
1969 end
1970 if height == nil then
1971 height = 100
1972 end
1973 print("Hello I am", name)
1974 return print("My height is", height)
1975end
1976local some_args
1977some_args = function(x, y)
1978 if x == nil then
1979 x = 100
1980 end
1981 if y == nil then
1982 y = x + 1000
1983 end
1984 return print(x + y)
1985end
1986local a = x - 10
1987local b = x - 10
1988local c = x(-y)
1989local d = x - z
1990local x = func("hello") + 100
1991local y = func("hello" + 100)
1992my_func(5, 4, 3, 8, 9, 10)
1993cool_func(1, 2, 3, 4, 5, 6, 7, 8)
1994my_func(5, 6, 7, 6, another_func(6, 7, 8, 9, 1, 2), 5, 4)
1995local x = {
1996 1,
1997 2,
1998 3,
1999 4,
2000 a_func(4, 5, 5, 6),
2001 8,
2002 9,
2003 10
2004}
2005local y = {
2006 my_func(1, 2, 3, 4, 5),
2007 5,
2008 6,
2009 7
2010}
2011if func(1, 2, 3, "hello", "world") then
2012 print("hello")
2013 print("I am inside if")
2014end
2015if func(1, 2, 3, "hello", "world") then
2016 print("hello")
2017 print("I am inside if")
2018end
2019local f1
2020f1 = function(_arg_0)
2021 local a, b, c
2022 a, b, c = _arg_0.a, _arg_0.b, _arg_0.c
2023 return print(a, b, c)
2024end
2025f1({
2026 a = 1,
2027 b = "2",
2028 c = { }
2029})
2030local f2
2031f2 = function(_arg_0, c)
2032 local a1, b
2033 a1, b = _arg_0.a, _arg_0.b
2034 if a1 == nil then
2035 a1 = 123
2036 end
2037 if b == nil then
2038 b = 'abc'
2039 end
2040 if c == nil then
2041 c = { }
2042 end
2043end
2044print(a1, b, c)
2045local arg1 = {
2046 a = 0
2047}
2048f2(arg1, arg2)
2049local findFirstEven
2050findFirstEven = function(list)
2051 for _index_0 = 1, #list do
2052 local item = list[_index_0]
2053 if type(item) == "table" then
2054 for _index_1 = 1, #item do
2055 local sub = item[_index_1]
2056 if sub % 2 == 0 then
2057 return sub
2058 end
2059 end
2060 end
2061 end
2062 return nil
2063end
2064local findFirstEven
2065findFirstEven = function(list)
2066 for _index_0 = 1, #list do
2067 local item = list[_index_0]
2068 if type(item) == "table" then
2069 for _index_1 = 1, #item do
2070 local sub = item[_index_1]
2071 if sub % 2 == 0 then
2072 return sub
2073 end
2074 end
2075 end
2076 end
2077 return nil
2078end
2079local f
2080f = function(...)
2081 local t = {
2082 n = select("#", ...),
2083 ...
2084 }
2085 print("argument count:", t.n)
2086 print("table length:", #t)
2087 for i = 1, t.n do
2088 print(t[i])
2089 end
2090end
2091f(1, 2, 3)
2092f("a", "b", "c", "d")
2093f()
2094local process
2095process = function(...)
2096 local args = {
2097 n = select("#", ...),
2098 ...
2099 }
2100 local sum = 0
2101 for i = 1, args.n do
2102 if args[i] ~= nil and type(args[i]) == "number" then
2103 sum = sum + args[i]
2104 end
2105 end
2106 return sum
2107end
2108process(1, nil, 3, nil, 5)
2109f(function(x)
2110 return print("hello" .. x)
2111end)
2112f(function(self)
2113 return print(self.value)
2114end)
2115map(function(x)
2116 return x * 2
2117end, {
2118 1,
2119 2,
2120 3
2121})
2122local result, msg
2123do
2124 result, msg = readAsync("filename.txt", function(data)
2125 print(data)
2126 return processAsync(data, function(info)
2127 return check(info)
2128 end)
2129 end)
2130end
2131print(result, msg)
2132f(function(x)
2133 return print("hello" .. x)
2134end)
2135f(function(self)
2136 return print(self.value)
2137end)
2138map(function(x)
2139 return x * 2
2140end, {
2141 1,
2142 2,
2143 3
2144})
2145local result, msg
2146do
2147 result, msg = readAsync("filename.txt", function(data)
2148 print(data)
2149 return processAsync(data, function(info)
2150 return check(info)
2151 end)
2152 end)
2153end
2154print(result, msg)
2155local some_values = {
2156 1,
2157 2,
2158 3,
2159 4
2160}
2161local some_values = {
2162 name = "Bill",
2163 age = 200,
2164 ["favorite food"] = "rice"
2165}
2166local profile = {
2167 height = "4 feet",
2168 shoe_size = 13,
2169 favorite_foods = {
2170 "ice cream",
2171 "donuts"
2172 }
2173}
2174local values = {
2175 1,
2176 2,
2177 3,
2178 4,
2179 5,
2180 6,
2181 7,
2182 8,
2183 name = "superman",
2184 occupation = "crime fighting"
2185}
2186my_function({
2187 dance = "Tango",
2188 partner = "none"
2189})
2190local y = {
2191 type = "dog",
2192 legs = 4,
2193 tails = 1
2194}
2195local tbl = {
2196 ["do"] = "something",
2197 ["end"] = "hunger"
2198}
2199local hair = "golden"
2200local height = 200
2201local person = {
2202 hair = hair,
2203 height = height,
2204 shoe_size = 40
2205}
2206print_table({
2207 hair = hair,
2208 height = height
2209})
2210local t = {
2211 [1 + 2] = "hello",
2212 ["hello world"] = true
2213}
2214local some_values = {
2215 1,
2216 2,
2217 3,
2218 4
2219}
2220local list_with_one_element = {
2221 1
2222}
2223local some_values = {
2224 1,
2225 2,
2226 3,
2227 4
2228}
2229local some_values = {
2230 name = "Bill",
2231 age = 200,
2232 ["favorite food"] = "rice"
2233}
2234local profile = {
2235 height = "4 feet",
2236 shoe_size = 13,
2237 favorite_foods = {
2238 "ice cream",
2239 "donuts"
2240 }
2241}
2242local values = {
2243 1,
2244 2,
2245 3,
2246 4,
2247 5,
2248 6,
2249 7,
2250 8,
2251 name = "superman",
2252 occupation = "crime fighting"
2253}
2254my_function({
2255 dance = "Tango",
2256 partner = "none"
2257})
2258local y = {
2259 type = "dog",
2260 legs = 4,
2261 tails = 1
2262}
2263local tbl = {
2264 ["do"] = "something",
2265 ["end"] = "hunger"
2266}
2267local hair = "golden"
2268local height = 200
2269local person = {
2270 hair = hair,
2271 height = height,
2272 shoe_size = 40
2273}
2274print_table({
2275 hair = hair,
2276 height = height
2277})
2278local t = {
2279 [1 + 2] = "hello",
2280 ["hello world"] = true
2281}
2282local some_values = {
2283 1,
2284 2,
2285 3,
2286 4
2287}
2288local list_with_one_element = {
2289 1
2290}
2291local items = {
2292 1,
2293 2,
2294 3,
2295 4
2296}
2297local doubled
2298local _accum_0 = { }
2299local _len_0 = 1
2300for i, item in ipairs(items) do
2301 _accum_0[_len_0] = item * 2
2302 _len_0 = _len_0 + 1
2303end
2304doubled = _accum_0
2305local slice
2306local _accum_0 = { }
2307local _len_0 = 1
2308for i, item in ipairs(items) do
2309 if i > 1 and i < 3 then
2310 _accum_0[_len_0] = item
2311 _len_0 = _len_0 + 1
2312 end
2313end
2314slice = _accum_0
2315local doubled
2316local _accum_0 = { }
2317local _len_0 = 1
2318local _list_0 = items
2319for _index_0 = 1, #_list_0 do
2320 local item = _list_0[_index_0]
2321 _accum_0[_len_0] = item * 2
2322 _len_0 = _len_0 + 1
2323end
2324doubled = _accum_0
2325local data = {
2326 a = {
2327 1,
2328 2,
2329 3
2330 },
2331 b = {
2332 4,
2333 5,
2334 6
2335 }
2336}
2337local flat
2338local _accum_0 = { }
2339for k, v in pairs(data) do
2340 local _len_0 = #_accum_0 + 1
2341 for _index_0 = 1, #v do
2342 local _elm_0 = v[_index_0]
2343 _accum_0[_len_0], _len_0 = _elm_0, _len_0 + 1
2344 end
2345end
2346flat = _accum_0
2347local x_coords = {
2348 4,
2349 5,
2350 6,
2351 7
2352}
2353local y_coords = {
2354 9,
2355 2,
2356 3
2357}
2358local points
2359local _accum_0 = { }
2360local _len_0 = 1
2361for _index_0 = 1, #x_coords do
2362 local x = x_coords[_index_0]
2363 for _index_1 = 1, #y_coords do
2364 local y = y_coords[_index_1]
2365 _accum_0[_len_0] = {
2366 x,
2367 y
2368 }
2369 _len_0 = _len_0 + 1
2370 end
2371end
2372points = _accum_0
2373local evens
2374local _accum_0 = { }
2375local _len_0 = 1
2376for i = 1, 100 do
2377 if i % 2 == 0 then
2378 _accum_0[_len_0] = i
2379 _len_0 = _len_0 + 1
2380 end
2381end
2382evens = _accum_0
2383local thing = {
2384 color = "red",
2385 name = "fast",
2386 width = 123
2387}
2388local thing_copy
2389local _tbl_0 = { }
2390for k, v in pairs(thing) do
2391 _tbl_0[k] = v
2392end
2393thing_copy = _tbl_0
2394local no_color
2395local _tbl_0 = { }
2396for k, v in pairs(thing) do
2397 if k ~= "color" then
2398 _tbl_0[k] = v
2399 end
2400end
2401no_color = _tbl_0
2402local numbers = {
2403 1,
2404 2,
2405 3,
2406 4
2407}
2408local sqrts
2409local _tbl_0 = { }
2410for _index_0 = 1, #numbers do
2411 local i = numbers[_index_0]
2412 _tbl_0[i] = math.sqrt(i)
2413end
2414sqrts = _tbl_0
2415local tuples = {
2416 {
2417 "hello",
2418 "world"
2419 },
2420 {
2421 "foo",
2422 "bar"
2423 }
2424}
2425local tbl
2426local _tbl_0 = { }
2427for _index_0 = 1, #tuples do
2428 local tuple = tuples[_index_0]
2429 local _key_0, _val_0 = unpack(tuple)
2430 _tbl_0[_key_0] = _val_0
2431end
2432tbl = _tbl_0
2433local slice
2434local _accum_0 = { }
2435local _len_0 = 1
2436local _list_0 = items
2437for _index_0 = 1, 5 do
2438 local item = _list_0[_index_0]
2439 _accum_0[_len_0] = item
2440 _len_0 = _len_0 + 1
2441end
2442slice = _accum_0
2443local slice
2444local _accum_0 = { }
2445local _len_0 = 1
2446local _list_0 = items
2447local _max_0 = #_list_0
2448for _index_0 = 2, _max_0 do
2449 local item = _list_0[_index_0]
2450 _accum_0[_len_0] = item
2451 _len_0 = _len_0 + 1
2452end
2453slice = _accum_0
2454local slice
2455local _accum_0 = { }
2456local _len_0 = 1
2457local _list_0 = items
2458local _max_0 = #_list_0
2459for _index_0 = 1, _max_0, 2 do
2460 local item = _list_0[_index_0]
2461 _accum_0[_len_0] = item
2462 _len_0 = _len_0 + 1
2463end
2464slice = _accum_0
2465local slice
2466local _accum_0 = { }
2467local _len_0 = 1
2468local _list_0 = items
2469local _min_0 = #_list_0 + -4 + 1
2470local _max_0 = #_list_0 + -1 + 1
2471for _index_0 = _min_0, _max_0 do
2472 local item = _list_0[_index_0]
2473 _accum_0[_len_0] = item
2474 _len_0 = _len_0 + 1
2475end
2476slice = _accum_0
2477local reverse_slice
2478local _accum_0 = { }
2479local _len_0 = 1
2480local _list_0 = items
2481local _min_0 = #_list_0 + -1 + 1
2482for _index_0 = _min_0, 1, -1 do
2483 local item = _list_0[_index_0]
2484 _accum_0[_len_0] = item
2485 _len_0 = _len_0 + 1
2486end
2487reverse_slice = _accum_0
2488local sub_list
2489do
2490 local _accum_0 = { }
2491 local _len_0 = 1
2492 local _list_0 = items
2493 for _index_0 = 2, 4 do
2494 local _item_0 = _list_0[_index_0]
2495 _accum_0[_len_0] = _item_0
2496 _len_0 = _len_0 + 1
2497 end
2498 sub_list = _accum_0
2499end
2500local last_four_items
2501local _accum_0 = { }
2502local _len_0 = 1
2503local _list_0 = items
2504local _min_0 = #_list_0 + -4 + 1
2505local _max_0 = #_list_0 + -1 + 1
2506for _index_0 = _min_0, _max_0 do
2507 local _item_0 = _list_0[_index_0]
2508 _accum_0[_len_0] = _item_0
2509 _len_0 = _len_0 + 1
2510end
2511last_four_items = _accum_0
2512local items = {
2513 1,
2514 2,
2515 3,
2516 4
2517}
2518local doubled
2519local _accum_0 = { }
2520local _len_0 = 1
2521for i, item in ipairs(items) do
2522 _accum_0[_len_0] = item * 2
2523 _len_0 = _len_0 + 1
2524end
2525doubled = _accum_0
2526local slice
2527local _accum_0 = { }
2528local _len_0 = 1
2529for i, item in ipairs(items) do
2530 if i > 1 and i < 3 then
2531 _accum_0[_len_0] = item
2532 _len_0 = _len_0 + 1
2533 end
2534end
2535slice = _accum_0
2536local doubled
2537local _accum_0 = { }
2538local _len_0 = 1
2539local _list_0 = items
2540for _index_0 = 1, #_list_0 do
2541 local item = _list_0[_index_0]
2542 _accum_0[_len_0] = item * 2
2543 _len_0 = _len_0 + 1
2544end
2545doubled = _accum_0
2546local data = {
2547 a = {
2548 1,
2549 2,
2550 3
2551 },
2552 b = {
2553 4,
2554 5,
2555 6
2556 }
2557}
2558local flat
2559local _accum_0 = { }
2560for k, v in pairs(data) do
2561 local _len_0 = #_accum_0 + 1
2562 for _index_0 = 1, #v do
2563 local _elm_0 = v[_index_0]
2564 _accum_0[_len_0], _len_0 = _elm_0, _len_0 + 1
2565 end
2566end
2567flat = _accum_0
2568local x_coords = {
2569 4,
2570 5,
2571 6,
2572 7
2573}
2574local y_coords = {
2575 9,
2576 2,
2577 3
2578}
2579local points
2580local _accum_0 = { }
2581local _len_0 = 1
2582for _index_0 = 1, #x_coords do
2583 local x = x_coords[_index_0]
2584 for _index_1 = 1, #y_coords do
2585 local y = y_coords[_index_1]
2586 _accum_0[_len_0] = {
2587 x,
2588 y
2589 }
2590 _len_0 = _len_0 + 1
2591 end
2592end
2593points = _accum_0
2594local evens
2595local _accum_0 = { }
2596local _len_0 = 1
2597for i = 1, 100 do
2598 if i % 2 == 0 then
2599 _accum_0[_len_0] = i
2600 _len_0 = _len_0 + 1
2601 end
2602end
2603evens = _accum_0
2604local thing = {
2605 color = "red",
2606 name = "fast",
2607 width = 123
2608}
2609local thing_copy
2610local _tbl_0 = { }
2611for k, v in pairs(thing) do
2612 _tbl_0[k] = v
2613end
2614thing_copy = _tbl_0
2615local no_color
2616local _tbl_0 = { }
2617for k, v in pairs(thing) do
2618 if k ~= "color" then
2619 _tbl_0[k] = v
2620 end
2621end
2622no_color = _tbl_0
2623local numbers = {
2624 1,
2625 2,
2626 3,
2627 4
2628}
2629local sqrts
2630local _tbl_0 = { }
2631for _index_0 = 1, #numbers do
2632 local i = numbers[_index_0]
2633 _tbl_0[i] = math.sqrt(i)
2634end
2635sqrts = _tbl_0
2636local tuples = {
2637 {
2638 "hello",
2639 "world"
2640 },
2641 {
2642 "foo",
2643 "bar"
2644 }
2645}
2646local tbl
2647local _tbl_0 = { }
2648for _index_0 = 1, #tuples do
2649 local tuple = tuples[_index_0]
2650 local _key_0, _val_0 = unpack(tuple)
2651 _tbl_0[_key_0] = _val_0
2652end
2653tbl = _tbl_0
2654local slice
2655local _accum_0 = { }
2656local _len_0 = 1
2657local _list_0 = items
2658for _index_0 = 1, 5 do
2659 local item = _list_0[_index_0]
2660 _accum_0[_len_0] = item
2661 _len_0 = _len_0 + 1
2662end
2663slice = _accum_0
2664local slice
2665local _accum_0 = { }
2666local _len_0 = 1
2667local _list_0 = items
2668local _max_0 = #_list_0
2669for _index_0 = 2, _max_0 do
2670 local item = _list_0[_index_0]
2671 _accum_0[_len_0] = item
2672 _len_0 = _len_0 + 1
2673end
2674slice = _accum_0
2675local slice
2676local _accum_0 = { }
2677local _len_0 = 1
2678local _list_0 = items
2679local _max_0 = #_list_0
2680for _index_0 = 1, _max_0, 2 do
2681 local item = _list_0[_index_0]
2682 _accum_0[_len_0] = item
2683 _len_0 = _len_0 + 1
2684end
2685slice = _accum_0
2686local slice
2687local _accum_0 = { }
2688local _len_0 = 1
2689local _list_0 = items
2690local _min_0 = #_list_0 + -4 + 1
2691local _max_0 = #_list_0 + -1 + 1
2692for _index_0 = _min_0, _max_0 do
2693 local item = _list_0[_index_0]
2694 _accum_0[_len_0] = item
2695 _len_0 = _len_0 + 1
2696end
2697slice = _accum_0
2698local reverse_slice
2699local _accum_0 = { }
2700local _len_0 = 1
2701local _list_0 = items
2702local _min_0 = #_list_0 + -1 + 1
2703for _index_0 = _min_0, 1, -1 do
2704 local item = _list_0[_index_0]
2705 _accum_0[_len_0] = item
2706 _len_0 = _len_0 + 1
2707end
2708reverse_slice = _accum_0
2709local sub_list
2710do
2711 local _accum_0 = { }
2712 local _len_0 = 1
2713 local _list_0 = items
2714 for _index_0 = 2, 4 do
2715 local _item_0 = _list_0[_index_0]
2716 _accum_0[_len_0] = _item_0
2717 _len_0 = _len_0 + 1
2718 end
2719 sub_list = _accum_0
2720end
2721local last_four_items
2722local _accum_0 = { }
2723local _len_0 = 1
2724local _list_0 = items
2725local _min_0 = #_list_0 + -4 + 1
2726local _max_0 = #_list_0 + -1 + 1
2727for _index_0 = _min_0, _max_0 do
2728 local _item_0 = _list_0[_index_0]
2729 _accum_0[_len_0] = _item_0
2730 _len_0 = _len_0 + 1
2731end
2732last_four_items = _accum_0
2733for i = 10, 20 do
2734 print(i)
2735end
2736for k = 1, 15, 2 do
2737 print(k)
2738end
2739for key, value in pairs(object) do
2740 print(key, value)
2741end
2742local _list_0 = items
2743for _index_0 = 2, 4 do
2744 local item = _list_0[_index_0]
2745 print(item)
2746end
2747local _list_0 = items
2748for _index_0 = 1, #_list_0 do
2749 local item = _list_0[_index_0]
2750 print(item)
2751end
2752for j = 1, 10, 3 do
2753 print(j)
2754end
2755local doubled_evens
2756local _accum_0 = { }
2757local _len_0 = 1
2758for i = 1, 20 do
2759 if i % 2 == 0 then
2760 _accum_0[_len_0] = i * 2
2761 _len_0 = _len_0 + 1
2762 else
2763 _accum_0[_len_0] = i
2764 _len_0 = _len_0 + 1
2765 end
2766end
2767doubled_evens = _accum_0
2768local first_large
2769local _accum_0
2770local _list_0 = numbers
2771for _index_0 = 1, #_list_0 do
2772 local n = _list_0[_index_0]
2773 if n > 10 then
2774 _accum_0 = n
2775 break
2776 end
2777end
2778first_large = _accum_0
2779local func_a
2780func_a = function()
2781 for i = 1, 10 do
2782 print(i)
2783 end
2784end
2785local func_b
2786func_b = function()
2787 local _accum_0 = { }
2788 local _len_0 = 1
2789 for i = 1, 10 do
2790 _accum_0[_len_0] = i
2791 _len_0 = _len_0 + 1
2792 end
2793 return _accum_0
2794end
2795print(func_a())
2796print(func_b())
2797for i = 10, 20 do
2798 print(i)
2799end
2800for k = 1, 15, 2 do
2801 print(k)
2802end
2803for key, value in pairs(object) do
2804 print(key, value)
2805end
2806local _list_0 = items
2807for _index_0 = 2, 4 do
2808 local item = _list_0[_index_0]
2809 print(item)
2810end
2811local _list_0 = items
2812for _index_0 = 1, #_list_0 do
2813 local item = _list_0[_index_0]
2814 print(item)
2815end
2816for j = 1, 10, 3 do
2817 print(j)
2818end
2819local doubled_evens
2820local _accum_0 = { }
2821local _len_0 = 1
2822for i = 1, 20 do
2823 if i % 2 == 0 then
2824 _accum_0[_len_0] = i * 2
2825 _len_0 = _len_0 + 1
2826 else
2827 _accum_0[_len_0] = i
2828 _len_0 = _len_0 + 1
2829 end
2830end
2831doubled_evens = _accum_0
2832local first_large
2833local _accum_0
2834local _list_0 = numbers
2835for _index_0 = 1, #_list_0 do
2836 local n = _list_0[_index_0]
2837 if n > 10 then
2838 _accum_0 = n
2839 break
2840 end
2841end
2842first_large = _accum_0
2843local func_a
2844func_a = function()
2845 for i = 1, 10 do
2846 print(i)
2847 end
2848end
2849local func_b
2850func_b = function()
2851 local _accum_0 = { }
2852 local _len_0 = 1
2853 for i = 1, 10 do
2854 _accum_0[_len_0] = i
2855 _len_0 = _len_0 + 1
2856 end
2857 return _accum_0
2858end
2859print(func_a())
2860print(func_b())
2861local i = 10
2862while i > 0 do
2863 print(i)
2864 i = i - 1
2865end
2866while running == true do
2867 my_function()
2868end
2869local i = 10
2870while not (i == 0) do
2871 print(i)
2872 i = i - 1
2873end
2874while not (running == false) do
2875 my_function()
2876end
2877local i = 10
2878repeat
2879 print(i)
2880 i = i - 1
2881until i == 0
2882local i = 10
2883while i > 0 do
2884 print(i)
2885 i = i - 1
2886end
2887while running == true do
2888 my_function()
2889end
2890local i = 10
2891while not (i == 0) do
2892 print(i)
2893 i = i - 1
2894end
2895while not (running == false) do
2896 my_function()
2897end
2898local i = 10
2899repeat
2900 print(i)
2901 i = i - 1
2902until i == 0
2903local i = 0
2904while i < 10 do
2905 i = i + 1
2906 if i % 2 == 0 then
2907 goto _continue_0
2908 end
2909 print(i)
2910 ::_continue_0::
2911end
2912local my_numbers = {
2913 1,
2914 2,
2915 3,
2916 4,
2917 5,
2918 6
2919}
2920local odds
2921local _accum_0 = { }
2922local _len_0 = 1
2923for _index_0 = 1, #my_numbers do
2924 local x = my_numbers[_index_0]
2925 if x % 2 == 1 then
2926 goto _continue_0
2927 end
2928 _accum_0[_len_0] = x
2929 _len_0 = _len_0 + 1
2930 ::_continue_0::
2931end
2932odds = _accum_0
2933local i = 0
2934while i < 10 do
2935 i = i + 1
2936 if i % 2 == 0 then
2937 goto _continue_0
2938 end
2939 print(i)
2940 ::_continue_0::
2941end
2942local my_numbers = {
2943 1,
2944 2,
2945 3,
2946 4,
2947 5,
2948 6
2949}
2950local odds
2951local _accum_0 = { }
2952local _len_0 = 1
2953for _index_0 = 1, #my_numbers do
2954 local x = my_numbers[_index_0]
2955 if x % 2 == 1 then
2956 goto _continue_0
2957 end
2958 _accum_0[_len_0] = x
2959 _len_0 = _len_0 + 1
2960 ::_continue_0::
2961end
2962odds = _accum_0
2963local have_coins = false
2964if have_coins then
2965 print("Got coins")
2966else
2967 print("No coins")
2968end
2969local have_coins = false
2970if have_coins then
2971 print("Got coins")
2972else
2973 print("No coins")
2974end
2975local have_coins = false
2976print((function()
2977 if have_coins then
2978 return "Got coins"
2979 else
2980 return "No coins"
2981 end
2982end)())
2983local is_tall
2984is_tall = function(name)
2985 if name == "Rob" then
2986 return true
2987 else
2988 return false
2989 end
2990end
2991local message
2992if is_tall("Rob") then
2993 message = "I am very tall"
2994else
2995 message = "I am not so tall"
2996end
2997print(message)
2998if not (os.date("%A") == "Monday") then
2999 print("it is not Monday!")
3000end
3001if not (math.random() > 0.1) then
3002 print("You're lucky!")
3003end
3004local a = 5
3005if (1 == a or 3 == a or 5 == a or 7 == a) then
3006 print("checking equality with discrete values")
3007end
3008if (function()
3009 local _check_0 = list
3010 for _index_0 = 1, #_check_0 do
3011 if _check_0[_index_0] == a then
3012 return true
3013 end
3014 end
3015 return false
3016end)() then
3017 print("checking if `a` is in a list")
3018end
3019if not (math.random() > 0.1) then
3020 print("You're lucky!")
3021end
3022local have_coins = false
3023if have_coins then
3024 print("Got coins")
3025else
3026 print("No coins")
3027end
3028local have_coins = false
3029if have_coins then
3030 print("Got coins")
3031else
3032 print("No coins")
3033end
3034local have_coins = false
3035print((function()
3036 if have_coins then
3037 return "Got coins"
3038 else
3039 return "No coins"
3040 end
3041end)())
3042local is_tall
3043is_tall = function(name)
3044 if name == "Rob" then
3045 return true
3046 else
3047 return false
3048 end
3049end
3050local message
3051if is_tall("Rob") then
3052 message = "I am very tall"
3053else
3054 message = "I am not so tall"
3055end
3056print(message)
3057if not (os.date("%A") == "Monday") then
3058 print("it is not Monday!")
3059end
3060if not (math.random() > 0.1) then
3061 print("You're lucky!")
3062end
3063local a = 5
3064if (1 == a or 3 == a or 5 == a or 7 == a) then
3065 print("checking equality with discrete values")
3066end
3067if (function()
3068 local _check_0 = list
3069 for _index_0 = 1, #_check_0 do
3070 if _check_0[_index_0] == a then
3071 return true
3072 end
3073 end
3074 return false
3075end)() then
3076 print("checking if `a` is in a list")
3077end
3078if not (math.random() > 0.1) then
3079 print("You're lucky!")
3080end
3081if name == "Rob" then
3082 print("hello world")
3083end
3084local _list_0 = items
3085for _index_0 = 1, #_list_0 do
3086 local item = _list_0[_index_0]
3087 print("item: ", item)
3088end
3089while game:isRunning() do
3090 game:update()
3091end
3092while not reader:eof() do
3093 reader:parse_line()
3094end
3095if name == "Rob" then
3096 print("hello world")
3097end
3098local _list_0 = items
3099for _index_0 = 1, #_list_0 do
3100 local item = _list_0[_index_0]
3101 print("item: ", item)
3102end
3103while game:isRunning() do
3104 game:update()
3105end
3106while not reader:eof() do
3107 reader:parse_line()
3108end
3109local name = "Dan"
3110if "Robert" == name then
3111 print("You are Robert")
3112elseif "Dan" == name or "Daniel" == name then
3113 print("Your name, it's Dan")
3114else
3115 print("I don't know about you with name " .. tostring(name))
3116end
3117local b = 1
3118local next_number
3119if 1 == b then
3120 next_number = 2
3121elseif 2 == b then
3122 next_number = 3
3123else
3124 next_number = error("can't count that high!")
3125end
3126local msg
3127local _exp_0 = math.random(1, 5)
3128if 1 == _exp_0 then
3129 msg = "you are lucky"
3130elseif 2 == _exp_0 then
3131 msg = "you are almost lucky"
3132else
3133 msg = "not so lucky"
3134end
3135do
3136 local _exp_0 = math.random(1, 5)
3137 if 1 == _exp_0 then
3138 print("you are lucky")
3139 else
3140 print("not so lucky")
3141 end
3142end
3143local _exp_0 = math.random(1, 5)
3144if 1 == _exp_0 then
3145 print("you are lucky")
3146else
3147 print("not so lucky")
3148end
3149local items = {
3150 {
3151 x = 100,
3152 y = 200
3153 },
3154 {
3155 width = 300,
3156 height = 400
3157 }
3158}
3159for _index_0 = 1, #items do
3160 local item = items[_index_0]
3161 local _type_0 = type(item)
3162 local _tab_0 = "table" == _type_0 or "userdata" == _type_0
3163 local _match_0 = false
3164 if _tab_0 then
3165 local x = item.x
3166 local y = item.y
3167 if x ~= nil and y ~= nil then
3168 _match_0 = true
3169 print("Vec2 " .. tostring(x) .. ", " .. tostring(y))
3170 end
3171 end
3172 if not _match_0 then
3173 if _tab_0 then
3174 local width = item.width
3175 local height = item.height
3176 if width ~= nil and height ~= nil then
3177 print("size " .. tostring(width) .. ", " .. tostring(height))
3178 end
3179 end
3180 end
3181end
3182local item = { }
3183local x, y = item.pos.x, item.pos.y
3184if x == nil then
3185 x = 50
3186end
3187if y == nil then
3188 y = 200
3189end
3190local _type_0 = type(item)
3191local _tab_0 = "table" == _type_0 or "userdata" == _type_0
3192if _tab_0 then
3193 do
3194 local _obj_0 = item.pos
3195 local _type_1 = type(_obj_0)
3196 if "table" == _type_1 or "userdata" == _type_1 then
3197 x = _obj_0.x
3198 end
3199 end
3200 do
3201 local _obj_0 = item.pos
3202 local _type_1 = type(_obj_0)
3203 if "table" == _type_1 or "userdata" == _type_1 then
3204 y = _obj_0.y
3205 end
3206 end
3207 if x == nil then
3208 x = 50
3209 end
3210 if y == nil then
3211 y = 200
3212 end
3213 print("Vec2 " .. tostring(x) .. ", " .. tostring(y))
3214end
3215local _exp_0 = tb
3216local _type_0 = type(_exp_0)
3217local _tab_0 = "table" == _type_0 or "userdata" == _type_0
3218local _match_0 = false
3219if _tab_0 then
3220 if 1 == _exp_0[1] and 2 == _exp_0[2] and 3 == _exp_0[3] then
3221 _match_0 = true
3222 print("1, 2, 3")
3223 end
3224end
3225if not _match_0 then
3226 local _match_1 = false
3227 if _tab_0 then
3228 local b = _exp_0[2]
3229 if 1 == _exp_0[1] and b ~= nil and 3 == _exp_0[3] then
3230 _match_1 = true
3231 print("1, " .. tostring(b) .. ", 3")
3232 end
3233 end
3234 if not _match_1 then
3235 if _tab_0 then
3236 local b = _exp_0[3]
3237 if b == nil then
3238 b = 3
3239 end
3240 if 1 == _exp_0[1] and 2 == _exp_0[2] then
3241 print("1, 2, " .. tostring(b))
3242 end
3243 end
3244 end
3245end
3246local _exp_0 = tb
3247local _type_0 = type(_exp_0)
3248local _tab_0 = "table" == _type_0 or "userdata" == _type_0
3249local _match_0 = false
3250if _tab_0 then
3251 local result = _exp_0.result
3252 if true == _exp_0.success and result ~= nil then
3253 _match_0 = true
3254 print("success", result)
3255 end
3256end
3257if not _match_0 then
3258 local _match_1 = false
3259 if _tab_0 then
3260 if false == _exp_0.success then
3261 _match_1 = true
3262 print("failed", result)
3263 end
3264 end
3265 if not _match_1 then
3266 print("invalid")
3267 end
3268end
3269local _exp_0 = tb
3270local _type_0 = type(_exp_0)
3271local _tab_0 = "table" == _type_0 or "userdata" == _type_0
3272local _match_0 = false
3273if _tab_0 then
3274 local content
3275 do
3276 local _obj_0 = _exp_0.data
3277 local _type_1 = type(_obj_0)
3278 if "table" == _type_1 or "userdata" == _type_1 then
3279 content = _obj_0.content
3280 end
3281 end
3282 local _val_0
3283 do
3284 local _obj_0 = _exp_0.data
3285 if _obj_0 ~= nil then
3286 _val_0 = _obj_0.type
3287 end
3288 end
3289 if "success" == _val_0 and content ~= nil then
3290 _match_0 = true
3291 print("success", content)
3292 end
3293end
3294if not _match_0 then
3295 local _match_1 = false
3296 if _tab_0 then
3297 local content
3298 do
3299 local _obj_0 = _exp_0.data
3300 local _type_1 = type(_obj_0)
3301 if "table" == _type_1 or "userdata" == _type_1 then
3302 content = _obj_0.content
3303 end
3304 end
3305 local _val_0
3306 do
3307 local _obj_0 = _exp_0.data
3308 if _obj_0 ~= nil then
3309 _val_0 = _obj_0.type
3310 end
3311 end
3312 if "error" == _val_0 and content ~= nil then
3313 _match_1 = true
3314 print("failed", content)
3315 end
3316 end
3317 if not _match_1 then
3318 print("invalid")
3319 end
3320end
3321local _exp_0 = tb
3322local _type_0 = type(_exp_0)
3323local _tab_0 = "table" == _type_0 or "userdata" == _type_0
3324if _tab_0 then
3325 local fourth = _exp_0[4]
3326 local _val_0
3327 do
3328 local _obj_0 = _exp_0[1]
3329 if _obj_0 ~= nil then
3330 _val_0 = _obj_0.a
3331 end
3332 end
3333 local _val_1
3334 do
3335 local _obj_0 = _exp_0[1]
3336 if _obj_0 ~= nil then
3337 _val_1 = _obj_0.b
3338 end
3339 end
3340 local _val_2
3341 do
3342 local _obj_0 = _exp_0[2]
3343 if _obj_0 ~= nil then
3344 _val_2 = _obj_0.a
3345 end
3346 end
3347 local _val_3
3348 do
3349 local _obj_0 = _exp_0[2]
3350 if _obj_0 ~= nil then
3351 _val_3 = _obj_0.b
3352 end
3353 end
3354 local _val_4
3355 do
3356 local _obj_0 = _exp_0[3]
3357 if _obj_0 ~= nil then
3358 _val_4 = _obj_0.a
3359 end
3360 end
3361 local _val_5
3362 do
3363 local _obj_0 = _exp_0[3]
3364 if _obj_0 ~= nil then
3365 _val_5 = _obj_0.b
3366 end
3367 end
3368 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
3369 print("matched", fourth)
3370 end
3371end
3372local segments = {
3373 "admin",
3374 "users",
3375 "logs",
3376 "view"
3377}
3378local _type_0 = type(segments)
3379local _tab_0 = "table" == _type_0 or "userdata" == _type_0
3380if _tab_0 then
3381 local groups
3382 do
3383 local _accum_0 = { }
3384 local _len_0 = 1
3385 local _max_0 = #segments + -3 + 1
3386 for _index_0 = 1, _max_0 do
3387 local _item_0 = segments[_index_0]
3388 _accum_0[_len_0] = _item_0
3389 _len_0 = _len_0 + 1
3390 end
3391 groups = _accum_0
3392 end
3393 local resource = segments[#segments - 1]
3394 local action = segments[#segments]
3395 if resource ~= nil and action ~= nil then
3396 print("Group:", groups)
3397 print("Resource:", resource)
3398 print("Action:", action)
3399 end
3400end
3401local name = "Dan"
3402if "Robert" == name then
3403 print("You are Robert")
3404elseif "Dan" == name or "Daniel" == name then
3405 print("Your name, it's Dan")
3406else
3407 print("I don't know about you with name " .. tostring(name))
3408end
3409local b = 1
3410local next_number
3411if 1 == b then
3412 next_number = 2
3413elseif 2 == b then
3414 next_number = 3
3415else
3416 next_number = error("can't count that high!")
3417end
3418local msg
3419local _exp_0 = math.random(1, 5)
3420if 1 == _exp_0 then
3421 msg = "you are lucky"
3422elseif 2 == _exp_0 then
3423 msg = "you are almost lucky"
3424else
3425 msg = "not so lucky"
3426end
3427do
3428 local _exp_0 = math.random(1, 5)
3429 if 1 == _exp_0 then
3430 print("you are lucky")
3431 else
3432 print("not so lucky")
3433 end
3434end
3435local _exp_0 = math.random(1, 5)
3436if 1 == _exp_0 then
3437 print("you are lucky")
3438else
3439 print("not so lucky")
3440end
3441local items = {
3442 {
3443 x = 100,
3444 y = 200
3445 },
3446 {
3447 width = 300,
3448 height = 400
3449 }
3450}
3451for _index_0 = 1, #items do
3452 local item = items[_index_0]
3453 local _type_0 = type(item)
3454 local _tab_0 = "table" == _type_0 or "userdata" == _type_0
3455 local _match_0 = false
3456 if _tab_0 then
3457 local x = item.x
3458 local y = item.y
3459 if x ~= nil and y ~= nil then
3460 _match_0 = true
3461 print("Vec2 " .. tostring(x) .. ", " .. tostring(y))
3462 end
3463 end
3464 if not _match_0 then
3465 if _tab_0 then
3466 local width = item.width
3467 local height = item.height
3468 if width ~= nil and height ~= nil then
3469 print("size " .. tostring(width) .. ", " .. tostring(height))
3470 end
3471 end
3472 end
3473end
3474local item = { }
3475local x, y = item.pos.x, item.pos.y
3476if x == nil then
3477 x = 50
3478end
3479if y == nil then
3480 y = 200
3481end
3482local _type_0 = type(item)
3483local _tab_0 = "table" == _type_0 or "userdata" == _type_0
3484if _tab_0 then
3485 do
3486 local _obj_0 = item.pos
3487 local _type_1 = type(_obj_0)
3488 if "table" == _type_1 or "userdata" == _type_1 then
3489 x = _obj_0.x
3490 end
3491 end
3492 do
3493 local _obj_0 = item.pos
3494 local _type_1 = type(_obj_0)
3495 if "table" == _type_1 or "userdata" == _type_1 then
3496 y = _obj_0.y
3497 end
3498 end
3499 if x == nil then
3500 x = 50
3501 end
3502 if y == nil then
3503 y = 200
3504 end
3505 print("Vec2 " .. tostring(x) .. ", " .. tostring(y))
3506end
3507local _exp_0 = tb
3508local _type_0 = type(_exp_0)
3509local _tab_0 = "table" == _type_0 or "userdata" == _type_0
3510local _match_0 = false
3511if _tab_0 then
3512 if 1 == _exp_0[1] and 2 == _exp_0[2] and 3 == _exp_0[3] then
3513 _match_0 = true
3514 print("1, 2, 3")
3515 end
3516end
3517if not _match_0 then
3518 local _match_1 = false
3519 if _tab_0 then
3520 local b = _exp_0[2]
3521 if 1 == _exp_0[1] and b ~= nil and 3 == _exp_0[3] then
3522 _match_1 = true
3523 print("1, " .. tostring(b) .. ", 3")
3524 end
3525 end
3526 if not _match_1 then
3527 if _tab_0 then
3528 local b = _exp_0[3]
3529 if b == nil then
3530 b = 3
3531 end
3532 if 1 == _exp_0[1] and 2 == _exp_0[2] then
3533 print("1, 2, " .. tostring(b))
3534 end
3535 end
3536 end
3537end
3538local _exp_0 = tb
3539local _type_0 = type(_exp_0)
3540local _tab_0 = "table" == _type_0 or "userdata" == _type_0
3541local _match_0 = false
3542if _tab_0 then
3543 local result = _exp_0.result
3544 if true == _exp_0.success and result ~= nil then
3545 _match_0 = true
3546 print("success", result)
3547 end
3548end
3549if not _match_0 then
3550 local _match_1 = false
3551 if _tab_0 then
3552 if false == _exp_0.success then
3553 _match_1 = true
3554 print("failed", result)
3555 end
3556 end
3557 if not _match_1 then
3558 print("invalid")
3559 end
3560end
3561local _exp_0 = tb
3562local _type_0 = type(_exp_0)
3563local _tab_0 = "table" == _type_0 or "userdata" == _type_0
3564local _match_0 = false
3565if _tab_0 then
3566 local content
3567 do
3568 local _obj_0 = _exp_0.data
3569 local _type_1 = type(_obj_0)
3570 if "table" == _type_1 or "userdata" == _type_1 then
3571 content = _obj_0.content
3572 end
3573 end
3574 local _val_0
3575 do
3576 local _obj_0 = _exp_0.data
3577 if _obj_0 ~= nil then
3578 _val_0 = _obj_0.type
3579 end
3580 end
3581 if "success" == _val_0 and content ~= nil then
3582 _match_0 = true
3583 print("success", content)
3584 end
3585end
3586if not _match_0 then
3587 local _match_1 = false
3588 if _tab_0 then
3589 local content
3590 do
3591 local _obj_0 = _exp_0.data
3592 local _type_1 = type(_obj_0)
3593 if "table" == _type_1 or "userdata" == _type_1 then
3594 content = _obj_0.content
3595 end
3596 end
3597 local _val_0
3598 do
3599 local _obj_0 = _exp_0.data
3600 if _obj_0 ~= nil then
3601 _val_0 = _obj_0.type
3602 end
3603 end
3604 if "error" == _val_0 and content ~= nil then
3605 _match_1 = true
3606 print("failed", content)
3607 end
3608 end
3609 if not _match_1 then
3610 print("invalid")
3611 end
3612end
3613local _exp_0 = tb
3614local _type_0 = type(_exp_0)
3615local _tab_0 = "table" == _type_0 or "userdata" == _type_0
3616if _tab_0 then
3617 local fourth = _exp_0[4]
3618 local _val_0
3619 do
3620 local _obj_0 = _exp_0[1]
3621 if _obj_0 ~= nil then
3622 _val_0 = _obj_0.a
3623 end
3624 end
3625 local _val_1
3626 do
3627 local _obj_0 = _exp_0[1]
3628 if _obj_0 ~= nil then
3629 _val_1 = _obj_0.b
3630 end
3631 end
3632 local _val_2
3633 do
3634 local _obj_0 = _exp_0[2]
3635 if _obj_0 ~= nil then
3636 _val_2 = _obj_0.a
3637 end
3638 end
3639 local _val_3
3640 do
3641 local _obj_0 = _exp_0[2]
3642 if _obj_0 ~= nil then
3643 _val_3 = _obj_0.b
3644 end
3645 end
3646 local _val_4
3647 do
3648 local _obj_0 = _exp_0[3]
3649 if _obj_0 ~= nil then
3650 _val_4 = _obj_0.a
3651 end
3652 end
3653 local _val_5
3654 do
3655 local _obj_0 = _exp_0[3]
3656 if _obj_0 ~= nil then
3657 _val_5 = _obj_0.b
3658 end
3659 end
3660 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
3661 print("matched", fourth)
3662 end
3663end
3664local segments = {
3665 "admin",
3666 "users",
3667 "logs",
3668 "view"
3669}
3670local _type_0 = type(segments)
3671local _tab_0 = "table" == _type_0 or "userdata" == _type_0
3672if _tab_0 then
3673 local groups
3674 do
3675 local _accum_0 = { }
3676 local _len_0 = 1
3677 local _max_0 = #segments + -3 + 1
3678 for _index_0 = 1, _max_0 do
3679 local _item_0 = segments[_index_0]
3680 _accum_0[_len_0] = _item_0
3681 _len_0 = _len_0 + 1
3682 end
3683 groups = _accum_0
3684 end
3685 local resource = segments[#segments - 1]
3686 local action = segments[#segments]
3687 if resource ~= nil and action ~= nil then
3688 print("Group:", groups)
3689 print("Resource:", resource)
3690 print("Action:", action)
3691 end
3692end
3693local Inventory
3694local _class_0
3695local _base_0 = {
3696 add_item = function(self, name)
3697 if self.items[name] then
3698 local _obj_0 = self.items
3699 _obj_0[name] = _obj_0[name] + 1
3700 else
3701 self.items[name] = 1
3702 end
3703 end
3704}
3705if _base_0.__index == nil then
3706 _base_0.__index = _base_0
3707end
3708_class_0 = setmetatable({
3709 __init = function(self)
3710 self.items = { }
3711 end,
3712 __base = _base_0,
3713 __name = "Inventory"
3714}, {
3715 __index = _base_0,
3716 __call = function(cls, ...)
3717 local _self_0 = setmetatable({ }, _base_0)
3718 cls.__init(_self_0, ...)
3719 return _self_0
3720 end
3721})
3722_base_0.__class = _class_0
3723Inventory = _class_0
3724local inv = Inventory()
3725inv:add_item("t-shirt")
3726inv:add_item("pants")
3727local Person
3728do
3729 local _class_0
3730 local _base_0 = {
3731 clothes = { },
3732 give_item = function(self, name)
3733 return table.insert(self.clothes, name)
3734 end
3735 }
3736 if _base_0.__index == nil then
3737 _base_0.__index = _base_0
3738 end
3739 _class_0 = setmetatable({
3740 __init = function() end,
3741 __base = _base_0,
3742 __name = "Person"
3743 }, {
3744 __index = _base_0,
3745 __call = function(cls, ...)
3746 local _self_0 = setmetatable({ }, _base_0)
3747 cls.__init(_self_0, ...)
3748 return _self_0
3749 end
3750 })
3751 _base_0.__class = _class_0
3752 Person = _class_0
3753end
3754local a = Person()
3755local b = Person()
3756a:give_item("pants")
3757b:give_item("shirt")
3758local _list_0 = a.clothes
3759for _index_0 = 1, #_list_0 do
3760 local item = _list_0[_index_0]
3761 print(item)
3762end
3763local Person
3764local _class_0
3765local _base_0 = { }
3766if _base_0.__index == nil then
3767 _base_0.__index = _base_0
3768end
3769_class_0 = setmetatable({
3770 __init = function(self)
3771 self.clothes = { }
3772 end,
3773 __base = _base_0,
3774 __name = "Person"
3775}, {
3776 __index = _base_0,
3777 __call = function(cls, ...)
3778 local _self_0 = setmetatable({ }, _base_0)
3779 cls.__init(_self_0, ...)
3780 return _self_0
3781 end
3782})
3783_base_0.__class = _class_0
3784Person = _class_0
3785local BackPack
3786local _class_0
3787local _parent_0 = Inventory
3788local _base_0 = {
3789 size = 10,
3790 add_item = function(self, name)
3791 if #self.items > size then
3792 error("backpack is full")
3793 end
3794 return _class_0.__parent.__base.add_item(self, name)
3795 end
3796}
3797for _key_0, _val_0 in pairs(_parent_0.__base) do
3798 if _base_0[_key_0] == nil and _key_0:match("^__") and not (_key_0 == "__index" and _val_0 == _parent_0.__base) then
3799 _base_0[_key_0] = _val_0
3800 end
3801end
3802if _base_0.__index == nil then
3803 _base_0.__index = _base_0
3804end
3805setmetatable(_base_0, _parent_0.__base)
3806_class_0 = setmetatable({
3807 __init = function(self, ...)
3808 return _class_0.__parent.__init(self, ...)
3809 end,
3810 __base = _base_0,
3811 __name = "BackPack",
3812 __parent = _parent_0
3813}, {
3814 __index = function(cls, name)
3815 local val = rawget(_base_0, name)
3816 if val == nil then
3817 local parent = rawget(cls, "__parent")
3818 if parent then
3819 return parent[name]
3820 end
3821 else
3822 return val
3823 end
3824 end,
3825 __call = function(cls, ...)
3826 local _self_0 = setmetatable({ }, _base_0)
3827 cls.__init(_self_0, ...)
3828 return _self_0
3829 end
3830})
3831_base_0.__class = _class_0
3832if _parent_0.__inherited then
3833 _parent_0.__inherited(_parent_0, _class_0)
3834end
3835BackPack = _class_0
3836local Shelf
3837do
3838 local _class_0
3839 local _base_0 = { }
3840 if _base_0.__index == nil then
3841 _base_0.__index = _base_0
3842 end
3843 _class_0 = setmetatable({
3844 __init = function() end,
3845 __base = _base_0,
3846 __name = "Shelf"
3847 }, {
3848 __index = _base_0,
3849 __call = function(cls, ...)
3850 local _self_0 = setmetatable({ }, _base_0)
3851 cls.__init(_self_0, ...)
3852 return _self_0
3853 end
3854 })
3855 _base_0.__class = _class_0
3856 local self = _class_0;
3857 self.__inherited = function(self, child)
3858 return print(self.__name, "was inherited by", child.__name)
3859 end
3860 Shelf = _class_0
3861end
3862local Cupboard
3863local _class_0
3864local _parent_0 = Shelf
3865local _base_0 = { }
3866for _key_0, _val_0 in pairs(_parent_0.__base) do
3867 if _base_0[_key_0] == nil and _key_0:match("^__") and not (_key_0 == "__index" and _val_0 == _parent_0.__base) then
3868 _base_0[_key_0] = _val_0
3869 end
3870end
3871if _base_0.__index == nil then
3872 _base_0.__index = _base_0
3873end
3874setmetatable(_base_0, _parent_0.__base)
3875_class_0 = setmetatable({
3876 __init = function(self, ...)
3877 return _class_0.__parent.__init(self, ...)
3878 end,
3879 __base = _base_0,
3880 __name = "Cupboard",
3881 __parent = _parent_0
3882}, {
3883 __index = function(cls, name)
3884 local val = rawget(_base_0, name)
3885 if val == nil then
3886 local parent = rawget(cls, "__parent")
3887 if parent then
3888 return parent[name]
3889 end
3890 else
3891 return val
3892 end
3893 end,
3894 __call = function(cls, ...)
3895 local _self_0 = setmetatable({ }, _base_0)
3896 cls.__init(_self_0, ...)
3897 return _self_0
3898 end
3899})
3900_base_0.__class = _class_0
3901if _parent_0.__inherited then
3902 _parent_0.__inherited(_parent_0, _class_0)
3903end
3904Cupboard = _class_0
3905local MyClass
3906local _class_0
3907local _parent_0 = ParentClass
3908local _base_0 = {
3909 a_method = function(self)
3910 _class_0.__parent.__base.a_method(self, "hello", "world")
3911 _class_0.__parent.a_method(self, "hello", "world")
3912 _class_0.__parent.a_method(self, "hello", "world")
3913 return assert(_class_0.__parent == ParentClass)
3914 end
3915}
3916for _key_0, _val_0 in pairs(_parent_0.__base) do
3917 if _base_0[_key_0] == nil and _key_0:match("^__") and not (_key_0 == "__index" and _val_0 == _parent_0.__base) then
3918 _base_0[_key_0] = _val_0
3919 end
3920end
3921if _base_0.__index == nil then
3922 _base_0.__index = _base_0
3923end
3924setmetatable(_base_0, _parent_0.__base)
3925_class_0 = setmetatable({
3926 __init = function(self, ...)
3927 return _class_0.__parent.__init(self, ...)
3928 end,
3929 __base = _base_0,
3930 __name = "MyClass",
3931 __parent = _parent_0
3932}, {
3933 __index = function(cls, name)
3934 local val = rawget(_base_0, name)
3935 if val == nil then
3936 local parent = rawget(cls, "__parent")
3937 if parent then
3938 return parent[name]
3939 end
3940 else
3941 return val
3942 end
3943 end,
3944 __call = function(cls, ...)
3945 local _self_0 = setmetatable({ }, _base_0)
3946 cls.__init(_self_0, ...)
3947 return _self_0
3948 end
3949})
3950_base_0.__class = _class_0
3951if _parent_0.__inherited then
3952 _parent_0.__inherited(_parent_0, _class_0)
3953end
3954MyClass = _class_0
3955local b = BackPack()
3956assert(b.__class == BackPack)
3957print(BackPack.size)
3958print(BackPack.__name)
3959local Things
3960do
3961 local _class_0
3962 local _base_0 = { }
3963 if _base_0.__index == nil then
3964 _base_0.__index = _base_0
3965 end
3966 _class_0 = setmetatable({
3967 __init = function() end,
3968 __base = _base_0,
3969 __name = "Things"
3970 }, {
3971 __index = _base_0,
3972 __call = function(cls, ...)
3973 local _self_0 = setmetatable({ }, _base_0)
3974 cls.__init(_self_0, ...)
3975 return _self_0
3976 end
3977 })
3978 _base_0.__class = _class_0
3979 local self = _class_0;
3980 self.some_func = function(self)
3981 return print("Hello from", self.__name)
3982 end
3983 Things = _class_0
3984end
3985Things:some_func()
3986assert(Things().some_func == nil)
3987local Counter
3988do
3989 local _class_0
3990 local _base_0 = { }
3991 if _base_0.__index == nil then
3992 _base_0.__index = _base_0
3993 end
3994 _class_0 = setmetatable({
3995 __init = function(self)
3996 self.__class.count = self.__class.count + 1
3997 end,
3998 __base = _base_0,
3999 __name = "Counter"
4000 }, {
4001 __index = _base_0,
4002 __call = function(cls, ...)
4003 local _self_0 = setmetatable({ }, _base_0)
4004 cls.__init(_self_0, ...)
4005 return _self_0
4006 end
4007 })
4008 _base_0.__class = _class_0
4009 local self = _class_0;
4010 self.count = 0
4011 Counter = _class_0
4012end
4013Counter()
4014Counter()
4015print(Counter.count)
4016self.__class:hello(1, 2, 3, 4)
4017local Things
4018local _class_0
4019local _base_0 = { }
4020if _base_0.__index == nil then
4021 _base_0.__index = _base_0
4022end
4023_class_0 = setmetatable({
4024 __init = function() end,
4025 __base = _base_0,
4026 __name = "Things"
4027}, {
4028 __index = _base_0,
4029 __call = function(cls, ...)
4030 local _self_0 = setmetatable({ }, _base_0)
4031 cls.__init(_self_0, ...)
4032 return _self_0
4033 end
4034})
4035_base_0.__class = _class_0
4036local self = _class_0;
4037self.class_var = "hello world"
4038Things = _class_0
4039local MoreThings
4040local _class_0
4041local secret, log
4042local _base_0 = {
4043 some_method = function(self)
4044 return log("hello world: " .. secret)
4045 end
4046}
4047if _base_0.__index == nil then
4048 _base_0.__index = _base_0
4049end
4050_class_0 = setmetatable({
4051 __init = function() end,
4052 __base = _base_0,
4053 __name = "MoreThings"
4054}, {
4055 __index = _base_0,
4056 __call = function(cls, ...)
4057 local _self_0 = setmetatable({ }, _base_0)
4058 cls.__init(_self_0, ...)
4059 return _self_0
4060 end
4061})
4062_base_0.__class = _class_0
4063local self = _class_0;
4064secret = 123
4065log = function(msg)
4066 return print("LOG:", msg)
4067end
4068MoreThings = _class_0
4069assert(self == self)
4070assert(self.__class == self.__class)
4071local some_instance_method
4072some_instance_method = function(self, ...)
4073 return self.__class(...)
4074end
4075local Something
4076do
4077 local _class_0
4078 local _base_0 = { }
4079 if _base_0.__index == nil then
4080 _base_0.__index = _base_0
4081 end
4082 _class_0 = setmetatable({
4083 __init = function(self, foo, bar, biz, baz)
4084 self.foo = foo
4085 self.bar = bar
4086 self.__class.biz = biz
4087 self.__class.baz = baz
4088 end,
4089 __base = _base_0,
4090 __name = "Something"
4091 }, {
4092 __index = _base_0,
4093 __call = function(cls, ...)
4094 local _self_0 = setmetatable({ }, _base_0)
4095 cls.__init(_self_0, ...)
4096 return _self_0
4097 end
4098 })
4099 _base_0.__class = _class_0
4100 Something = _class_0
4101end
4102local _class_0
4103local _base_0 = { }
4104if _base_0.__index == nil then
4105 _base_0.__index = _base_0
4106end
4107_class_0 = setmetatable({
4108 __init = function(self, foo, bar, biz, baz)
4109 self.foo = foo
4110 self.bar = bar
4111 self.__class.biz = biz
4112 self.__class.baz = baz
4113 end,
4114 __base = _base_0,
4115 __name = "Something"
4116}, {
4117 __index = _base_0,
4118 __call = function(cls, ...)
4119 local _self_0 = setmetatable({ }, _base_0)
4120 cls.__init(_self_0, ...)
4121 return _self_0
4122 end
4123})
4124_base_0.__class = _class_0
4125Something = _class_0
4126local new
4127new = function(self, fieldA, fieldB)
4128 self.fieldA = fieldA
4129 self.fieldB = fieldB
4130 return self
4131end
4132local obj = new({ }, 123, "abc")
4133print(obj)
4134local x
4135local Bucket
4136local _class_0
4137local _base_0 = {
4138 drops = 0,
4139 add_drop = function(self)
4140 self.drops = self.drops + 1
4141 end
4142}
4143if _base_0.__index == nil then
4144 _base_0.__index = _base_0
4145end
4146_class_0 = setmetatable({
4147 __init = function() end,
4148 __base = _base_0,
4149 __name = "Bucket"
4150}, {
4151 __index = _base_0,
4152 __call = function(cls, ...)
4153 local _self_0 = setmetatable({ }, _base_0)
4154 cls.__init(_self_0, ...)
4155 return _self_0
4156 end
4157})
4158_base_0.__class = _class_0
4159Bucket = _class_0
4160x = _class_0
4161local BigBucket
4162do
4163 local _class_0
4164 local _parent_0 = Bucket
4165 local _base_0 = {
4166 add_drop = function(self)
4167 self.drops = self.drops + 10
4168 end
4169 }
4170 for _key_0, _val_0 in pairs(_parent_0.__base) do
4171 if _base_0[_key_0] == nil and _key_0:match("^__") and not (_key_0 == "__index" and _val_0 == _parent_0.__base) then
4172 _base_0[_key_0] = _val_0
4173 end
4174 end
4175 if _base_0.__index == nil then
4176 _base_0.__index = _base_0
4177 end
4178 setmetatable(_base_0, _parent_0.__base)
4179 _class_0 = setmetatable({
4180 __init = function(self, ...)
4181 return _class_0.__parent.__init(self, ...)
4182 end,
4183 __base = _base_0,
4184 __name = "BigBucket",
4185 __parent = _parent_0
4186 }, {
4187 __index = function(cls, name)
4188 local val = rawget(_base_0, name)
4189 if val == nil then
4190 local parent = rawget(cls, "__parent")
4191 if parent then
4192 return parent[name]
4193 end
4194 else
4195 return val
4196 end
4197 end,
4198 __call = function(cls, ...)
4199 local _self_0 = setmetatable({ }, _base_0)
4200 cls.__init(_self_0, ...)
4201 return _self_0
4202 end
4203 })
4204 _base_0.__class = _class_0
4205 if _parent_0.__inherited then
4206 _parent_0.__inherited(_parent_0, _class_0)
4207 end
4208 BigBucket = _class_0
4209end
4210assert(Bucket.__name == "BigBucket")
4211local x
4212local _class_0
4213local _base_0 = { }
4214if _base_0.__index == nil then
4215 _base_0.__index = _base_0
4216end
4217_class_0 = setmetatable({
4218 __init = function() end,
4219 __base = _base_0,
4220 __name = "x"
4221}, {
4222 __index = _base_0,
4223 __call = function(cls, ...)
4224 local _self_0 = setmetatable({ }, _base_0)
4225 cls.__init(_self_0, ...)
4226 return _self_0
4227 end
4228})
4229_base_0.__class = _class_0
4230x = _class_0
4231local MyIndex = {
4232 __index = {
4233 var = 1
4234 }
4235}
4236local X
4237do
4238 local _class_0
4239 local _base_0 = {
4240 func = function(self)
4241 return print(123)
4242 end
4243 }
4244 local _list_0 = {
4245 MyIndex
4246 }
4247 for _index_0 = 1, #_list_0 do
4248 local _item_0 = _list_0[_index_0]
4249 local _cls_0, _mixin_0 = (_item_0.__base ~= nil), _item_0.__base or _item_0
4250 for _key_0, _val_0 in pairs(_mixin_0) do
4251 if _base_0[_key_0] == nil and (not _cls_0 or not _key_0:match("^__")) then
4252 _base_0[_key_0] = _val_0
4253 end
4254 end
4255 end
4256 if _base_0.__index == nil then
4257 _base_0.__index = _base_0
4258 end
4259 _class_0 = setmetatable({
4260 __init = function() end,
4261 __base = _base_0,
4262 __name = "X"
4263 }, {
4264 __index = _base_0,
4265 __call = function(cls, ...)
4266 local _self_0 = setmetatable({ }, _base_0)
4267 cls.__init(_self_0, ...)
4268 return _self_0
4269 end
4270 })
4271 _base_0.__class = _class_0
4272 X = _class_0
4273end
4274local x = X()
4275print(x.var)
4276local Y
4277do
4278 local _class_0
4279 local _base_0 = { }
4280 local _list_0 = {
4281 X
4282 }
4283 for _index_0 = 1, #_list_0 do
4284 local _item_0 = _list_0[_index_0]
4285 local _cls_0, _mixin_0 = (_item_0.__base ~= nil), _item_0.__base or _item_0
4286 for _key_0, _val_0 in pairs(_mixin_0) do
4287 if _base_0[_key_0] == nil and (not _cls_0 or not _key_0:match("^__")) then
4288 _base_0[_key_0] = _val_0
4289 end
4290 end
4291 end
4292 if _base_0.__index == nil then
4293 _base_0.__index = _base_0
4294 end
4295 _class_0 = setmetatable({
4296 __init = function() end,
4297 __base = _base_0,
4298 __name = "Y"
4299 }, {
4300 __index = _base_0,
4301 __call = function(cls, ...)
4302 local _self_0 = setmetatable({ }, _base_0)
4303 cls.__init(_self_0, ...)
4304 return _self_0
4305 end
4306 })
4307 _base_0.__class = _class_0
4308 Y = _class_0
4309end
4310local y = Y()
4311y:func()
4312assert(y.__class.__parent ~= X)
4313local Inventory
4314local _class_0
4315local _base_0 = {
4316 add_item = function(self, name)
4317 if self.items[name] then
4318 local _obj_0 = self.items
4319 _obj_0[name] = _obj_0[name] + 1
4320 else
4321 self.items[name] = 1
4322 end
4323 end
4324}
4325if _base_0.__index == nil then
4326 _base_0.__index = _base_0
4327end
4328_class_0 = setmetatable({
4329 __init = function(self)
4330 self.items = { }
4331 end,
4332 __base = _base_0,
4333 __name = "Inventory"
4334}, {
4335 __index = _base_0,
4336 __call = function(cls, ...)
4337 local _self_0 = setmetatable({ }, _base_0)
4338 cls.__init(_self_0, ...)
4339 return _self_0
4340 end
4341})
4342_base_0.__class = _class_0
4343Inventory = _class_0
4344local inv = Inventory()
4345inv:add_item("t-shirt")
4346inv:add_item("pants")
4347local Person
4348do
4349 local _class_0
4350 local _base_0 = {
4351 clothes = { },
4352 give_item = function(self, name)
4353 return table.insert(self.clothes, name)
4354 end
4355 }
4356 if _base_0.__index == nil then
4357 _base_0.__index = _base_0
4358 end
4359 _class_0 = setmetatable({
4360 __init = function() end,
4361 __base = _base_0,
4362 __name = "Person"
4363 }, {
4364 __index = _base_0,
4365 __call = function(cls, ...)
4366 local _self_0 = setmetatable({ }, _base_0)
4367 cls.__init(_self_0, ...)
4368 return _self_0
4369 end
4370 })
4371 _base_0.__class = _class_0
4372 Person = _class_0
4373end
4374local a = Person()
4375local b = Person()
4376a:give_item("pants")
4377b:give_item("shirt")
4378local _list_0 = a.clothes
4379for _index_0 = 1, #_list_0 do
4380 local item = _list_0[_index_0]
4381 print(item)
4382end
4383local Person
4384local _class_0
4385local _base_0 = { }
4386if _base_0.__index == nil then
4387 _base_0.__index = _base_0
4388end
4389_class_0 = setmetatable({
4390 __init = function(self)
4391 self.clothes = { }
4392 end,
4393 __base = _base_0,
4394 __name = "Person"
4395}, {
4396 __index = _base_0,
4397 __call = function(cls, ...)
4398 local _self_0 = setmetatable({ }, _base_0)
4399 cls.__init(_self_0, ...)
4400 return _self_0
4401 end
4402})
4403_base_0.__class = _class_0
4404Person = _class_0
4405local BackPack
4406local _class_0
4407local _parent_0 = Inventory
4408local _base_0 = {
4409 size = 10,
4410 add_item = function(self, name)
4411 if #self.items > size then
4412 error("backpack is full")
4413 end
4414 return _class_0.__parent.__base.add_item(self, name)
4415 end
4416}
4417for _key_0, _val_0 in pairs(_parent_0.__base) do
4418 if _base_0[_key_0] == nil and _key_0:match("^__") and not (_key_0 == "__index" and _val_0 == _parent_0.__base) then
4419 _base_0[_key_0] = _val_0
4420 end
4421end
4422if _base_0.__index == nil then
4423 _base_0.__index = _base_0
4424end
4425setmetatable(_base_0, _parent_0.__base)
4426_class_0 = setmetatable({
4427 __init = function(self, ...)
4428 return _class_0.__parent.__init(self, ...)
4429 end,
4430 __base = _base_0,
4431 __name = "BackPack",
4432 __parent = _parent_0
4433}, {
4434 __index = function(cls, name)
4435 local val = rawget(_base_0, name)
4436 if val == nil then
4437 local parent = rawget(cls, "__parent")
4438 if parent then
4439 return parent[name]
4440 end
4441 else
4442 return val
4443 end
4444 end,
4445 __call = function(cls, ...)
4446 local _self_0 = setmetatable({ }, _base_0)
4447 cls.__init(_self_0, ...)
4448 return _self_0
4449 end
4450})
4451_base_0.__class = _class_0
4452if _parent_0.__inherited then
4453 _parent_0.__inherited(_parent_0, _class_0)
4454end
4455BackPack = _class_0
4456local Shelf
4457do
4458 local _class_0
4459 local _base_0 = { }
4460 if _base_0.__index == nil then
4461 _base_0.__index = _base_0
4462 end
4463 _class_0 = setmetatable({
4464 __init = function() end,
4465 __base = _base_0,
4466 __name = "Shelf"
4467 }, {
4468 __index = _base_0,
4469 __call = function(cls, ...)
4470 local _self_0 = setmetatable({ }, _base_0)
4471 cls.__init(_self_0, ...)
4472 return _self_0
4473 end
4474 })
4475 _base_0.__class = _class_0
4476 local self = _class_0;
4477 self.__inherited = function(self, child)
4478 return print(self.__name, "was inherited by", child.__name)
4479 end
4480 Shelf = _class_0
4481end
4482local Cupboard
4483local _class_0
4484local _parent_0 = Shelf
4485local _base_0 = { }
4486for _key_0, _val_0 in pairs(_parent_0.__base) do
4487 if _base_0[_key_0] == nil and _key_0:match("^__") and not (_key_0 == "__index" and _val_0 == _parent_0.__base) then
4488 _base_0[_key_0] = _val_0
4489 end
4490end
4491if _base_0.__index == nil then
4492 _base_0.__index = _base_0
4493end
4494setmetatable(_base_0, _parent_0.__base)
4495_class_0 = setmetatable({
4496 __init = function(self, ...)
4497 return _class_0.__parent.__init(self, ...)
4498 end,
4499 __base = _base_0,
4500 __name = "Cupboard",
4501 __parent = _parent_0
4502}, {
4503 __index = function(cls, name)
4504 local val = rawget(_base_0, name)
4505 if val == nil then
4506 local parent = rawget(cls, "__parent")
4507 if parent then
4508 return parent[name]
4509 end
4510 else
4511 return val
4512 end
4513 end,
4514 __call = function(cls, ...)
4515 local _self_0 = setmetatable({ }, _base_0)
4516 cls.__init(_self_0, ...)
4517 return _self_0
4518 end
4519})
4520_base_0.__class = _class_0
4521if _parent_0.__inherited then
4522 _parent_0.__inherited(_parent_0, _class_0)
4523end
4524Cupboard = _class_0
4525local MyClass
4526local _class_0
4527local _parent_0 = ParentClass
4528local _base_0 = {
4529 a_method = function(self)
4530 _class_0.__parent.__base.a_method(self, "hello", "world")
4531 _class_0.__parent.a_method(self, "hello", "world")
4532 _class_0.__parent.a_method(self, "hello", "world")
4533 return assert(_class_0.__parent == ParentClass)
4534 end
4535}
4536for _key_0, _val_0 in pairs(_parent_0.__base) do
4537 if _base_0[_key_0] == nil and _key_0:match("^__") and not (_key_0 == "__index" and _val_0 == _parent_0.__base) then
4538 _base_0[_key_0] = _val_0
4539 end
4540end
4541if _base_0.__index == nil then
4542 _base_0.__index = _base_0
4543end
4544setmetatable(_base_0, _parent_0.__base)
4545_class_0 = setmetatable({
4546 __init = function(self, ...)
4547 return _class_0.__parent.__init(self, ...)
4548 end,
4549 __base = _base_0,
4550 __name = "MyClass",
4551 __parent = _parent_0
4552}, {
4553 __index = function(cls, name)
4554 local val = rawget(_base_0, name)
4555 if val == nil then
4556 local parent = rawget(cls, "__parent")
4557 if parent then
4558 return parent[name]
4559 end
4560 else
4561 return val
4562 end
4563 end,
4564 __call = function(cls, ...)
4565 local _self_0 = setmetatable({ }, _base_0)
4566 cls.__init(_self_0, ...)
4567 return _self_0
4568 end
4569})
4570_base_0.__class = _class_0
4571if _parent_0.__inherited then
4572 _parent_0.__inherited(_parent_0, _class_0)
4573end
4574MyClass = _class_0
4575local b = BackPack()
4576assert(b.__class == BackPack)
4577print(BackPack.size)
4578print(BackPack.__name)
4579local Things
4580do
4581 local _class_0
4582 local _base_0 = { }
4583 if _base_0.__index == nil then
4584 _base_0.__index = _base_0
4585 end
4586 _class_0 = setmetatable({
4587 __init = function() end,
4588 __base = _base_0,
4589 __name = "Things"
4590 }, {
4591 __index = _base_0,
4592 __call = function(cls, ...)
4593 local _self_0 = setmetatable({ }, _base_0)
4594 cls.__init(_self_0, ...)
4595 return _self_0
4596 end
4597 })
4598 _base_0.__class = _class_0
4599 local self = _class_0;
4600 self.some_func = function(self)
4601 return print("Hello from", self.__name)
4602 end
4603 Things = _class_0
4604end
4605Things:some_func()
4606assert(Things().some_func == nil)
4607local Counter
4608do
4609 local _class_0
4610 local _base_0 = { }
4611 if _base_0.__index == nil then
4612 _base_0.__index = _base_0
4613 end
4614 _class_0 = setmetatable({
4615 __init = function(self)
4616 self.__class.count = self.__class.count + 1
4617 end,
4618 __base = _base_0,
4619 __name = "Counter"
4620 }, {
4621 __index = _base_0,
4622 __call = function(cls, ...)
4623 local _self_0 = setmetatable({ }, _base_0)
4624 cls.__init(_self_0, ...)
4625 return _self_0
4626 end
4627 })
4628 _base_0.__class = _class_0
4629 local self = _class_0;
4630 self.count = 0
4631 Counter = _class_0
4632end
4633Counter()
4634Counter()
4635print(Counter.count)
4636self.__class:hello(1, 2, 3, 4)
4637local Things
4638local _class_0
4639local _base_0 = { }
4640if _base_0.__index == nil then
4641 _base_0.__index = _base_0
4642end
4643_class_0 = setmetatable({
4644 __init = function() end,
4645 __base = _base_0,
4646 __name = "Things"
4647}, {
4648 __index = _base_0,
4649 __call = function(cls, ...)
4650 local _self_0 = setmetatable({ }, _base_0)
4651 cls.__init(_self_0, ...)
4652 return _self_0
4653 end
4654})
4655_base_0.__class = _class_0
4656local self = _class_0;
4657self.class_var = "hello world"
4658Things = _class_0
4659local MoreThings
4660local _class_0
4661local secret, log
4662local _base_0 = {
4663 some_method = function(self)
4664 return log("hello world: " .. secret)
4665 end
4666}
4667if _base_0.__index == nil then
4668 _base_0.__index = _base_0
4669end
4670_class_0 = setmetatable({
4671 __init = function() end,
4672 __base = _base_0,
4673 __name = "MoreThings"
4674}, {
4675 __index = _base_0,
4676 __call = function(cls, ...)
4677 local _self_0 = setmetatable({ }, _base_0)
4678 cls.__init(_self_0, ...)
4679 return _self_0
4680 end
4681})
4682_base_0.__class = _class_0
4683local self = _class_0;
4684secret = 123
4685log = function(msg)
4686 return print("LOG:", msg)
4687end
4688MoreThings = _class_0
4689assert(self == self)
4690assert(self.__class == self.__class)
4691local some_instance_method
4692some_instance_method = function(self, ...)
4693 return self.__class(...)
4694end
4695local Something
4696do
4697 local _class_0
4698 local _base_0 = { }
4699 if _base_0.__index == nil then
4700 _base_0.__index = _base_0
4701 end
4702 _class_0 = setmetatable({
4703 __init = function(self, foo, bar, biz, baz)
4704 self.foo = foo
4705 self.bar = bar
4706 self.__class.biz = biz
4707 self.__class.baz = baz
4708 end,
4709 __base = _base_0,
4710 __name = "Something"
4711 }, {
4712 __index = _base_0,
4713 __call = function(cls, ...)
4714 local _self_0 = setmetatable({ }, _base_0)
4715 cls.__init(_self_0, ...)
4716 return _self_0
4717 end
4718 })
4719 _base_0.__class = _class_0
4720 Something = _class_0
4721end
4722local _class_0
4723local _base_0 = { }
4724if _base_0.__index == nil then
4725 _base_0.__index = _base_0
4726end
4727_class_0 = setmetatable({
4728 __init = function(self, foo, bar, biz, baz)
4729 self.foo = foo
4730 self.bar = bar
4731 self.__class.biz = biz
4732 self.__class.baz = baz
4733 end,
4734 __base = _base_0,
4735 __name = "Something"
4736}, {
4737 __index = _base_0,
4738 __call = function(cls, ...)
4739 local _self_0 = setmetatable({ }, _base_0)
4740 cls.__init(_self_0, ...)
4741 return _self_0
4742 end
4743})
4744_base_0.__class = _class_0
4745Something = _class_0
4746local new
4747new = function(self, fieldA, fieldB)
4748 self.fieldA = fieldA
4749 self.fieldB = fieldB
4750 return self
4751end
4752local obj = new({ }, 123, "abc")
4753print(obj)
4754local x
4755local Bucket
4756local _class_0
4757local _base_0 = {
4758 drops = 0,
4759 add_drop = function(self)
4760 self.drops = self.drops + 1
4761 end
4762}
4763if _base_0.__index == nil then
4764 _base_0.__index = _base_0
4765end
4766_class_0 = setmetatable({
4767 __init = function() end,
4768 __base = _base_0,
4769 __name = "Bucket"
4770}, {
4771 __index = _base_0,
4772 __call = function(cls, ...)
4773 local _self_0 = setmetatable({ }, _base_0)
4774 cls.__init(_self_0, ...)
4775 return _self_0
4776 end
4777})
4778_base_0.__class = _class_0
4779Bucket = _class_0
4780x = _class_0
4781local BigBucket
4782do
4783 local _class_0
4784 local _parent_0 = Bucket
4785 local _base_0 = {
4786 add_drop = function(self)
4787 self.drops = self.drops + 10
4788 end
4789 }
4790 for _key_0, _val_0 in pairs(_parent_0.__base) do
4791 if _base_0[_key_0] == nil and _key_0:match("^__") and not (_key_0 == "__index" and _val_0 == _parent_0.__base) then
4792 _base_0[_key_0] = _val_0
4793 end
4794 end
4795 if _base_0.__index == nil then
4796 _base_0.__index = _base_0
4797 end
4798 setmetatable(_base_0, _parent_0.__base)
4799 _class_0 = setmetatable({
4800 __init = function(self, ...)
4801 return _class_0.__parent.__init(self, ...)
4802 end,
4803 __base = _base_0,
4804 __name = "BigBucket",
4805 __parent = _parent_0
4806 }, {
4807 __index = function(cls, name)
4808 local val = rawget(_base_0, name)
4809 if val == nil then
4810 local parent = rawget(cls, "__parent")
4811 if parent then
4812 return parent[name]
4813 end
4814 else
4815 return val
4816 end
4817 end,
4818 __call = function(cls, ...)
4819 local _self_0 = setmetatable({ }, _base_0)
4820 cls.__init(_self_0, ...)
4821 return _self_0
4822 end
4823 })
4824 _base_0.__class = _class_0
4825 if _parent_0.__inherited then
4826 _parent_0.__inherited(_parent_0, _class_0)
4827 end
4828 BigBucket = _class_0
4829end
4830assert(Bucket.__name == "BigBucket")
4831local x
4832local _class_0
4833local _base_0 = { }
4834if _base_0.__index == nil then
4835 _base_0.__index = _base_0
4836end
4837_class_0 = setmetatable({
4838 __init = function() end,
4839 __base = _base_0,
4840 __name = "x"
4841}, {
4842 __index = _base_0,
4843 __call = function(cls, ...)
4844 local _self_0 = setmetatable({ }, _base_0)
4845 cls.__init(_self_0, ...)
4846 return _self_0
4847 end
4848})
4849_base_0.__class = _class_0
4850x = _class_0
4851local MyIndex = {
4852 __index = {
4853 var = 1
4854 }
4855}
4856local X
4857do
4858 local _class_0
4859 local _base_0 = {
4860 func = function(self)
4861 return print(123)
4862 end
4863 }
4864 local _list_0 = {
4865 MyIndex
4866 }
4867 for _index_0 = 1, #_list_0 do
4868 local _item_0 = _list_0[_index_0]
4869 local _cls_0, _mixin_0 = (_item_0.__base ~= nil), _item_0.__base or _item_0
4870 for _key_0, _val_0 in pairs(_mixin_0) do
4871 if _base_0[_key_0] == nil and (not _cls_0 or not _key_0:match("^__")) then
4872 _base_0[_key_0] = _val_0
4873 end
4874 end
4875 end
4876 if _base_0.__index == nil then
4877 _base_0.__index = _base_0
4878 end
4879 _class_0 = setmetatable({
4880 __init = function() end,
4881 __base = _base_0,
4882 __name = "X"
4883 }, {
4884 __index = _base_0,
4885 __call = function(cls, ...)
4886 local _self_0 = setmetatable({ }, _base_0)
4887 cls.__init(_self_0, ...)
4888 return _self_0
4889 end
4890 })
4891 _base_0.__class = _class_0
4892 X = _class_0
4893end
4894local x = X()
4895print(x.var)
4896local Y
4897do
4898 local _class_0
4899 local _base_0 = { }
4900 local _list_0 = {
4901 X
4902 }
4903 for _index_0 = 1, #_list_0 do
4904 local _item_0 = _list_0[_index_0]
4905 local _cls_0, _mixin_0 = (_item_0.__base ~= nil), _item_0.__base or _item_0
4906 for _key_0, _val_0 in pairs(_mixin_0) do
4907 if _base_0[_key_0] == nil and (not _cls_0 or not _key_0:match("^__")) then
4908 _base_0[_key_0] = _val_0
4909 end
4910 end
4911 end
4912 if _base_0.__index == nil then
4913 _base_0.__index = _base_0
4914 end
4915 _class_0 = setmetatable({
4916 __init = function() end,
4917 __base = _base_0,
4918 __name = "Y"
4919 }, {
4920 __index = _base_0,
4921 __call = function(cls, ...)
4922 local _self_0 = setmetatable({ }, _base_0)
4923 cls.__init(_self_0, ...)
4924 return _self_0
4925 end
4926 })
4927 _base_0.__class = _class_0
4928 Y = _class_0
4929end
4930local y = Y()
4931y:func()
4932assert(y.__class.__parent ~= X)
4933local _with_0 = Person()
4934_with_0.name = "Oswald"
4935_with_0:add_relative(my_dad)
4936_with_0:save()
4937print(_with_0.name)
4938local file
4939local _with_0 = File("favorite_foods.txt")
4940_with_0:set_encoding("utf8")
4941file = _with_0
4942local create_person
4943create_person = function(name, relatives)
4944 local _with_0 = Person()
4945 _with_0.name = name
4946 for _index_0 = 1, #relatives do
4947 local relative = relatives[_index_0]
4948 _with_0:add_relative(relative)
4949 end
4950 return _with_0
4951end
4952local me = create_person("Leaf", {
4953 dad,
4954 mother,
4955 sister
4956})
4957local str = "Hello"
4958print("original:", str)
4959print("upper:", str:upper())
4960local _with_0 = tb
4961_with_0[1] = 1
4962print(_with_0[2])
4963do
4964 local _with_1 = _with_0[abc]
4965 _with_1[3] = _with_1[2]:func()
4966 _with_1["key-name"] = value
4967end
4968_with_0[#_with_0 + 1] = "abc"
4969local _with_0 = obj
4970if _with_0 ~= nil then
4971 print(obj.name)
4972end
4973local _with_0 = Person()
4974_with_0.name = "Oswald"
4975_with_0:add_relative(my_dad)
4976_with_0:save()
4977print(_with_0.name)
4978local file
4979local _with_0 = File("favorite_foods.txt")
4980_with_0:set_encoding("utf8")
4981file = _with_0
4982local create_person
4983create_person = function(name, relatives)
4984 local _with_0 = Person()
4985 _with_0.name = name
4986 for _index_0 = 1, #relatives do
4987 local relative = relatives[_index_0]
4988 _with_0:add_relative(relative)
4989 end
4990 return _with_0
4991end
4992local me = create_person("Leaf", {
4993 dad,
4994 mother,
4995 sister
4996})
4997local str = "Hello"
4998print("original:", str)
4999print("upper:", str:upper())
5000local _with_0 = tb
5001_with_0[1] = 1
5002print(_with_0[2])
5003do
5004 local _with_1 = _with_0[abc]
5005 _with_1[3] = _with_1[2]:func()
5006 _with_1["key-name"] = value
5007end
5008_with_0[#_with_0 + 1] = "abc"
5009local _with_0 = obj
5010if _with_0 ~= nil then
5011 print(obj.name)
5012end
5013do
5014 local var = "hello"
5015 print(var)
5016end
5017print(var)
5018local counter
5019do
5020 local i = 0
5021 counter = function()
5022 i = i + 1
5023 return i
5024 end
5025end
5026print(counter())
5027print(counter())
5028local tbl = {
5029 key = (function()
5030 print("assigning key!")
5031 return 1234
5032 end)()
5033}
5034do
5035 local var = "hello"
5036 print(var)
5037end
5038print(var)
5039local counter
5040do
5041 local i = 0
5042 counter = function()
5043 i = i + 1
5044 return i
5045 end
5046end
5047print(counter())
5048print(counter())
5049local tbl = {
5050 key = (function()
5051 print("assigning key!")
5052 return 1234
5053 end)()
5054}
5055local my_object = {
5056 value = 1000,
5057 write = function(self)
5058 return print("the value:", self.value)
5059 end
5060}
5061local run_callback
5062run_callback = function(func)
5063 print("running callback...")
5064 return func()
5065end
5066run_callback(my_object.write)
5067run_callback((function()
5068 local _base_0 = my_object
5069 local _fn_0 = _base_0.write
5070 return _fn_0 and function(...)
5071 return _fn_0(_base_0, ...)
5072 end
5073end)())
5074local my_object = {
5075 value = 1000,
5076 write = function(self)
5077 return print("the value:", self.value)
5078 end
5079}
5080local run_callback
5081run_callback = function(func)
5082 print("running callback...")
5083 return func()
5084end
5085run_callback(my_object.write)
5086run_callback((function()
5087 local _base_0 = my_object
5088 local _fn_0 = _base_0.write
5089 return _fn_0 and function(...)
5090 return _fn_0(_base_0, ...)
5091 end
5092end)())
5093local i = 100
5094local my_func
5095my_func = function()
5096 i = 10
5097 while i > 0 do
5098 print(i)
5099 i = i - 1
5100 end
5101end
5102my_func()
5103print(i)
5104local i = 100
5105local my_func
5106my_func = function()
5107 local i = "hello"
5108end
5109my_func()
5110print(i)
5111local tmp = 1213
5112local i, k = 100, 50
5113local my_func
5114my_func = function(add)
5115 local tmp = tmp + add
5116 i = i + tmp
5117 k = k + tmp
5118end
5119my_func(22)
5120print(i, k)
5121local i = 100
5122local my_func
5123my_func = function()
5124 i = 10
5125 while i > 0 do
5126 print(i)
5127 i = i - 1
5128 end
5129end
5130my_func()
5131print(i)
5132local i = 100
5133local my_func
5134my_func = function()
5135 local i = "hello"
5136end
5137my_func()
5138print(i)
5139local tmp = 1213
5140local i, k = 100, 50
5141local my_func
5142my_func = function(add)
5143 local tmp = tmp + add
5144 i = i + tmp
5145 k = k + tmp
5146end
5147my_func(22)
5148print(i, k)