aboutsummaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorLi Jin <dragon-fly@qq.com>2024-03-21 09:14:34 +0800
committerLi Jin <dragon-fly@qq.com>2024-03-21 09:14:34 +0800
commit4a3cc26c6dfd74e61c8b6480038d6a292ea86e47 (patch)
tree9554b94cfc15e4acee0c2e60b63af16f1b828207 /spec
parent80b65520da432843f0c63431a1867bd2620bc4ac (diff)
downloadyuescript-4a3cc26c6dfd74e61c8b6480038d6a292ea86e47.tar.gz
yuescript-4a3cc26c6dfd74e61c8b6480038d6a292ea86e47.tar.bz2
yuescript-4a3cc26c6dfd74e61c8b6480038d6a292ea86e47.zip
remove redundant 'do' blocks in code generation.
Diffstat (limited to 'spec')
-rw-r--r--spec/outputs/5.1/attrib.lua18
-rw-r--r--spec/outputs/5.1/loops.lua22
-rw-r--r--spec/outputs/ambiguous.lua40
-rw-r--r--spec/outputs/assign.lua52
-rw-r--r--spec/outputs/attrib.lua18
-rw-r--r--spec/outputs/backcall.lua20
-rw-r--r--spec/outputs/bubbling.lua16
-rw-r--r--spec/outputs/class.lua44
-rw-r--r--spec/outputs/codes_from_doc.lua2250
-rw-r--r--spec/outputs/codes_from_doc_zh.lua2250
-rw-r--r--spec/outputs/compile_doc.lua40
-rw-r--r--spec/outputs/cond.lua64
-rw-r--r--spec/outputs/destructure.lua136
-rw-r--r--spec/outputs/funcs.lua38
-rw-r--r--spec/outputs/global.lua42
-rw-r--r--spec/outputs/import.lua54
-rw-r--r--spec/outputs/local.lua80
-rw-r--r--spec/outputs/loops.lua20
-rw-r--r--spec/outputs/macro.lua214
-rw-r--r--spec/outputs/metatable.lua22
-rw-r--r--spec/outputs/multiline_chain.lua14
-rw-r--r--spec/outputs/nil_coalescing.lua96
-rw-r--r--spec/outputs/stub.lua10
-rw-r--r--spec/outputs/switch.lua420
-rw-r--r--spec/outputs/syntax.lua14
-rw-r--r--spec/outputs/tables.lua246
-rw-r--r--spec/outputs/test/format_spec.lua16
-rw-r--r--spec/outputs/unicode/ambiguous.lua40
-rw-r--r--spec/outputs/unicode/assign.lua86
-rw-r--r--spec/outputs/unicode/attrib.lua18
-rw-r--r--spec/outputs/unicode/backcall.lua24
-rw-r--r--spec/outputs/unicode/bubbling.lua16
-rw-r--r--spec/outputs/unicode/class.lua44
-rw-r--r--spec/outputs/unicode/cond.lua68
-rw-r--r--spec/outputs/unicode/destructure.lua136
-rw-r--r--spec/outputs/unicode/global.lua42
-rw-r--r--spec/outputs/unicode/import.lua18
-rw-r--r--spec/outputs/unicode/in_expression.lua6
-rw-r--r--spec/outputs/unicode/local.lua80
-rw-r--r--spec/outputs/unicode/loops.lua20
-rw-r--r--spec/outputs/unicode/macro.lua262
-rw-r--r--spec/outputs/unicode/metatable.lua22
-rw-r--r--spec/outputs/unicode/multiline_chain.lua16
-rw-r--r--spec/outputs/unicode/nil_coalescing.lua96
-rw-r--r--spec/outputs/unicode/stub.lua10
-rw-r--r--spec/outputs/unicode/switch.lua366
-rw-r--r--spec/outputs/unicode/syntax.lua14
-rw-r--r--spec/outputs/unicode/tables.lua8
-rw-r--r--spec/outputs/unicode/vararg.lua88
-rw-r--r--spec/outputs/unicode/with.lua182
-rw-r--r--spec/outputs/upvalue_func.lua40
-rw-r--r--spec/outputs/vararg.lua88
-rw-r--r--spec/outputs/with.lua176
53 files changed, 3814 insertions, 4408 deletions
diff --git a/spec/outputs/5.1/attrib.lua b/spec/outputs/5.1/attrib.lua
index a9f12e3..af3f6cc 100644
--- a/spec/outputs/5.1/attrib.lua
+++ b/spec/outputs/5.1/attrib.lua
@@ -25,20 +25,16 @@ end
25do 25do
26 local a = f() 26 local a = f()
27 local b, c, d 27 local b, c, d
28 do 28 local _obj_0, _obj_1 = f1()
29 local _obj_0, _obj_1 = f1() 29 b, c = _obj_0[1], _obj_0[2]
30 b, c = _obj_0[1], _obj_0[2] 30 d = _obj_1[1]
31 d = _obj_1[1]
32 end
33end 31end
34do 32do
35 local a, b, c, d 33 local a, b, c, d
36 do 34 local _obj_0, _obj_1, _obj_2 = f()
37 local _obj_0, _obj_1, _obj_2 = f() 35 a = _obj_0
38 a = _obj_0 36 b, c = _obj_1[1], _obj_1[2]
39 b, c = _obj_1[1], _obj_1[2] 37 d = _obj_2[1]
40 d = _obj_2[1]
41 end
42end 38end
43do 39do
44 local a, b 40 local a, b
diff --git a/spec/outputs/5.1/loops.lua b/spec/outputs/5.1/loops.lua
index 6f0d072..cc019e0 100644
--- a/spec/outputs/5.1/loops.lua
+++ b/spec/outputs/5.1/loops.lua
@@ -390,20 +390,18 @@ do
390 local _cond_0 = false 390 local _cond_0 = false
391 local _continue_1 = false 391 local _continue_1 = false
392 repeat 392 repeat
393 do 393 local _with_0 = tb
394 local _with_0 = tb 394 if _with_0 ~= nil then
395 if _with_0 ~= nil then 395 _with_0.a = 1
396 _with_0.a = 1 396 if _with_0.b then
397 if _with_0.b then 397 _cond_0 = true
398 _cond_0 = true 398 _continue_1 = true
399 _continue_1 = true 399 break
400 end
401 do
402 if _with_0.c then
400 break 403 break
401 end 404 end
402 do
403 if _with_0.c then
404 break
405 end
406 end
407 end 405 end
408 end 406 end
409 _cond_0 = true 407 _cond_0 = true
diff --git a/spec/outputs/ambiguous.lua b/spec/outputs/ambiguous.lua
index 3da6f14..3c82a03 100644
--- a/spec/outputs/ambiguous.lua
+++ b/spec/outputs/ambiguous.lua
@@ -13,11 +13,17 @@ a, b = c, d;
13(d(a))(c) 13(d(a))(c)
14for i = 1, 10 do 14for i = 1, 10 do
15 a = function() end 15 a = function() end
16 (print)(1) 16 do
17 a = f; 17 (print)(1)
18 (print)(2) 18 end
19 a = f
20 do
21 (print)(2)
22 end
19 if cond then 23 if cond then
20 (print)(3) 24 do
25 (print)(3)
26 end
21 end 27 end
22 ::abc::; 28 ::abc::;
23 (print)(4) 29 (print)(4)
@@ -40,7 +46,9 @@ do
40 end) 46 end)
41end 47end
42do 48do
43 print(123) 49 do
50 print(123)
51 end
44end 52end
45do 53do
46 f({ 54 f({
@@ -97,18 +105,16 @@ do
97 nums = _accum_0 105 nums = _accum_0
98 end 106 end
99 local objects 107 local objects
100 do 108 local _accum_0 = { }
101 local _accum_0 = { } 109 local _len_0 = 1
102 local _len_0 = 1 110 local _list_0 = items
103 local _list_0 = items 111 for _index_0 = 1, #_list_0 do
104 for _index_0 = 1, #_list_0 do 112 local item = _list_0[_index_0]
105 local item = _list_0[_index_0] 113 _accum_0[_len_0] = {
106 _accum_0[_len_0] = { 114 name = item
107 name = item 115 }
108 } 116 _len_0 = _len_0 + 1
109 _len_0 = _len_0 + 1
110 end
111 objects = _accum_0
112 end 117 end
118 objects = _accum_0
113end 119end
114return nil 120return nil
diff --git a/spec/outputs/assign.lua b/spec/outputs/assign.lua
index 8bf7b35..61b0843 100644
--- a/spec/outputs/assign.lua
+++ b/spec/outputs/assign.lua
@@ -72,15 +72,11 @@ return _(function()
72 do 72 do
73 local a 73 local a
74 if x then 74 if x then
75 do 75 local _exp_0 = y
76 local _exp_0 = y 76 if 1 == _exp_0 then
77 if 1 == _exp_0 then 77 local _obj_0, _obj_1 = f()
78 do 78 b[#b + 1] = _obj_1
79 local _obj_0, _obj_1 = f() 79 a = _obj_0
80 b[#b + 1] = _obj_1
81 a = _obj_0
82 end
83 end
84 end 80 end
85 end 81 end
86 end 82 end
@@ -88,11 +84,9 @@ return _(function()
88 local a 84 local a
89 local b 85 local b
90 if x then 86 if x then
91 do 87 local _obj_0, _obj_1 = f()
92 local _obj_0, _obj_1 = f() 88 a = _obj_0
93 a = _obj_0 89 b = _obj_1[1]
94 b = _obj_1[1]
95 end
96 else 90 else
97 a = 123 91 a = 123
98 b = tb[1] 92 b = tb[1]
@@ -101,33 +95,25 @@ return _(function()
101 do 95 do
102 local a, c 96 local a, c
103 if x then 97 if x then
104 do 98 local _exp_0 = y
105 local _exp_0 = y 99 if 1 == _exp_0 then
106 if 1 == _exp_0 then 100 local _obj_0, _obj_1, _obj_2, _obj_3 = f()
107 do 101 b[#b + 1] = _obj_1
108 local _obj_0, _obj_1, _obj_2, _obj_3 = f() 102 a, c, getmetatable(d).__add = _obj_0, _obj_2, _obj_3
109 b[#b + 1] = _obj_1
110 a, c, getmetatable(d).__add = _obj_0, _obj_2, _obj_3
111 end
112 end
113 end 103 end
114 elseif x2 then 104 elseif x2 then
115 if y2 then 105 if y2 then
116 do 106 local _obj_0, _obj_1, _obj_2, _obj_3 = f1()
117 local _obj_0, _obj_1, _obj_2, _obj_3 = f1() 107 b[#b + 1] = _obj_1
118 b[#b + 1] = _obj_1 108 a, c, getmetatable(d).__add = _obj_0, _obj_2, _obj_3
119 a, c, getmetatable(d).__add = _obj_0, _obj_2, _obj_3
120 end
121 end 109 end
122 else 110 else
123 print("hello") 111 print("hello")
124 do 112 do
125 print(123) 113 print(123)
126 do 114 local _obj_0, _obj_1, _obj_2 = f2()
127 local _obj_0, _obj_1, _obj_2 = f2() 115 b[#b + 1] = _obj_0
128 b[#b + 1] = _obj_0 116 a, c, getmetatable(d).__add = 1, _obj_1, _obj_2
129 a, c, getmetatable(d).__add = 1, _obj_1, _obj_2
130 end
131 end 117 end
132 end 118 end
133 end 119 end
diff --git a/spec/outputs/attrib.lua b/spec/outputs/attrib.lua
index 07fc165..f6b0784 100644
--- a/spec/outputs/attrib.lua
+++ b/spec/outputs/attrib.lua
@@ -14,20 +14,16 @@ end
14do 14do
15 local a <const> = f() 15 local a <const> = f()
16 local b, c, d 16 local b, c, d
17 do 17 local _obj_0, _obj_1 = f1()
18 local _obj_0, _obj_1 = f1() 18 b, c = _obj_0[1], _obj_0[2]
19 b, c = _obj_0[1], _obj_0[2] 19 d = _obj_1[1]
20 d = _obj_1[1]
21 end
22end 20end
23do 21do
24 local a, b, c, d 22 local a, b, c, d
25 do 23 local _obj_0, _obj_1, _obj_2 = f()
26 local _obj_0, _obj_1, _obj_2 = f() 24 a = _obj_0
27 a = _obj_0 25 b, c = _obj_1[1], _obj_1[2]
28 b, c = _obj_1[1], _obj_1[2] 26 d = _obj_2[1]
29 d = _obj_2[1]
30 end
31end 27end
32do 28do
33 local a, b 29 local a, b
diff --git a/spec/outputs/backcall.lua b/spec/outputs/backcall.lua
index b065388..38e5754 100644
--- a/spec/outputs/backcall.lua
+++ b/spec/outputs/backcall.lua
@@ -31,19 +31,17 @@ do
31 end)()) 31 end)())
32end 32end
33do 33do
34 do 34 local _obj_0 = http
35 local _obj_0 = http 35 if _obj_0 ~= nil then
36 if _obj_0 ~= nil then 36 _obj_0.get("ajaxtest", function(data)
37 _obj_0.get("ajaxtest", function(data) 37 body[".result"]:html(data)
38 body[".result"]:html(data) 38 return http.post("ajaxprocess", data, function(processed)
39 return http.post("ajaxprocess", data, function(processed) 39 body[".result"]:append(processed)
40 body[".result"]:append(processed) 40 return setTimeout(1000, function()
41 return setTimeout(1000, function() 41 return print("done")
42 return print("done")
43 end)
44 end) 42 end)
45 end) 43 end)
46 end 44 end)
47 end 45 end
48end 46end
49do 47do
diff --git a/spec/outputs/bubbling.lua b/spec/outputs/bubbling.lua
index 7cb93c7..69f5f6b 100644
--- a/spec/outputs/bubbling.lua
+++ b/spec/outputs/bubbling.lua
@@ -109,15 +109,13 @@ _ = function(...)
109 a = _accum_0 109 a = _accum_0
110 end 110 end
111 local b 111 local b
112 do 112 local _accum_0 = { }
113 local _accum_0 = { } 113 local _len_0 = 1
114 local _len_0 = 1 114 for i = 1, 10 do
115 for i = 1, 10 do 115 _accum_0[_len_0] = function(...)
116 _accum_0[_len_0] = function(...) 116 return print(...)
117 return print(...)
118 end
119 _len_0 = _len_0 + 1
120 end 117 end
121 b = _accum_0 118 _len_0 = _len_0 + 1
122 end 119 end
120 b = _accum_0
123end 121end
diff --git a/spec/outputs/class.lua b/spec/outputs/class.lua
index d13b738..442ff4b 100644
--- a/spec/outputs/class.lua
+++ b/spec/outputs/class.lua
@@ -496,30 +496,28 @@ print("hello")
496local yyy 496local yyy
497yyy = function() 497yyy = function()
498 local Cool 498 local Cool
499 do 499 local _class_0
500 local _class_0 500 local _base_0 = { }
501 local _base_0 = { } 501 if _base_0.__index == nil then
502 if _base_0.__index == nil then 502 _base_0.__index = _base_0
503 _base_0.__index = _base_0
504 end
505 _class_0 = setmetatable({
506 __init = function() end,
507 __base = _base_0,
508 __name = "Cool"
509 }, {
510 __index = _base_0,
511 __call = function(cls, ...)
512 local _self_0 = setmetatable({ }, _base_0)
513 cls.__init(_self_0, ...)
514 return _self_0
515 end
516 })
517 _base_0.__class = _class_0
518 local self = _class_0;
519 _ = nil
520 Cool = _class_0
521 return _class_0
522 end 503 end
504 _class_0 = setmetatable({
505 __init = function() end,
506 __base = _base_0,
507 __name = "Cool"
508 }, {
509 __index = _base_0,
510 __call = function(cls, ...)
511 local _self_0 = setmetatable({ }, _base_0)
512 cls.__init(_self_0, ...)
513 return _self_0
514 end
515 })
516 _base_0.__class = _class_0
517 local self = _class_0;
518 _ = nil
519 Cool = _class_0
520 return _class_0
523end 521end
524do 522do
525 local _class_0 523 local _class_0
diff --git a/spec/outputs/codes_from_doc.lua b/spec/outputs/codes_from_doc.lua
index 1bcc587..1f593db 100644
--- a/spec/outputs/codes_from_doc.lua
+++ b/spec/outputs/codes_from_doc.lua
@@ -46,13 +46,18 @@ _module_0["🌛"] = _ud83c_udf1b
46return _module_0 46return _module_0
47local area = 6.2831853071796 * 5 47local area = 6.2831853071796 * 5
48print('hello world') 48print('hello world')
49assert(item ~= nil) 49do
50 assert(item ~= nil)
51end
50local value = item 52local value = item
51if (f1() and f2() and f3()) then 53if (f1() and f2() and f3()) then
52 print("OK") 54 print("OK")
53end 55end
56do
57 local funcA
58 funcA = function() end
59end
54local funcA 60local funcA
55funcA = function() end
56funcA = function() 61funcA = function()
57 return "assign the Yue defined variable" 62 return "assign the Yue defined variable"
58end 63end
@@ -146,28 +151,26 @@ local b = {
146 y = 1 151 y = 1
147} 152}
148local merge 153local merge
149do 154local _tab_0 = { }
150 local _tab_0 = { } 155local _idx_0 = 1
151 local _idx_0 = 1 156for _key_0, _value_0 in pairs(a) do
152 for _key_0, _value_0 in pairs(a) do 157 if _idx_0 == _key_0 then
153 if _idx_0 == _key_0 then 158 _tab_0[#_tab_0 + 1] = _value_0
154 _tab_0[#_tab_0 + 1] = _value_0 159 _idx_0 = _idx_0 + 1
155 _idx_0 = _idx_0 + 1 160 else
156 else 161 _tab_0[_key_0] = _value_0
157 _tab_0[_key_0] = _value_0
158 end
159 end 162 end
160 local _idx_1 = 1 163end
161 for _key_0, _value_0 in pairs(b) do 164local _idx_1 = 1
162 if _idx_1 == _key_0 then 165for _key_0, _value_0 in pairs(b) do
163 _tab_0[#_tab_0 + 1] = _value_0 166 if _idx_1 == _key_0 then
164 _idx_1 = _idx_1 + 1 167 _tab_0[#_tab_0 + 1] = _value_0
165 else 168 _idx_1 = _idx_1 + 1
166 _tab_0[_key_0] = _value_0 169 else
167 end 170 _tab_0[_key_0] = _value_0
168 end 171 end
169 merge = _tab_0
170end 172end
173merge = _tab_0
171local mt = { } 174local mt = { }
172local add 175local add
173add = function(self, right) 176add = function(self, right)
@@ -259,12 +262,10 @@ end
259if print and (x ~= nil) then 262if print and (x ~= nil) then
260 print(x) 263 print(x)
261end 264end
262do 265local _with_0 = io.open("test.txt", "w")
263 local _with_0 = io.open("test.txt", "w") 266if _with_0 ~= nil then
264 if _with_0 ~= nil then 267 _with_0:write("hello")
265 _with_0:write("hello") 268 _with_0:close()
266 _with_0:close()
267 end
268end 269end
269print("hello") 270print("hello")
270print(1, 2) 271print(1, 2)
@@ -341,10 +342,8 @@ do
341 x, y, z = _obj_0.x, _obj_0.y, _obj_0.z 342 x, y, z = _obj_0.x, _obj_0.y, _obj_0.z
342 end 343 end
343 local a, b, c 344 local a, b, c
344 do 345 local _obj_0 = require('module')
345 local _obj_0 = require('module') 346 a, b, c = _obj_0.a, _obj_0.b, _obj_0.c
346 a, b, c = _obj_0.a, _obj_0.b, _obj_0.c
347 end
348end 347end
349do 348do
350 local module = require('module') 349 local module = require('module')
@@ -383,29 +382,27 @@ y = function()
383end 382end
384_module_0["y"] = y 383_module_0["y"] = y
385local Something 384local Something
386do 385local _class_0
387 local _class_0 386local _base_0 = {
388 local _base_0 = { 387 umm = "cool"
389 umm = "cool" 388}
390 } 389if _base_0.__index == nil then
391 if _base_0.__index == nil then 390 _base_0.__index = _base_0
392 _base_0.__index = _base_0
393 end
394 _class_0 = setmetatable({
395 __init = function() end,
396 __base = _base_0,
397 __name = "Something"
398 }, {
399 __index = _base_0,
400 __call = function(cls, ...)
401 local _self_0 = setmetatable({ }, _base_0)
402 cls.__init(_self_0, ...)
403 return _self_0
404 end
405 })
406 _base_0.__class = _class_0
407 Something = _class_0
408end 391end
392_class_0 = setmetatable({
393 __init = function() end,
394 __base = _base_0,
395 __name = "Something"
396}, {
397 __index = _base_0,
398 __call = function(cls, ...)
399 local _self_0 = setmetatable({ }, _base_0)
400 cls.__init(_self_0, ...)
401 return _self_0
402 end
403})
404_base_0.__class = _class_0
405Something = _class_0
409_module_0["Something"] = Something 406_module_0["Something"] = Something
410return _module_0 407return _module_0
411local _module_0 = { } 408local _module_0 = { }
@@ -436,11 +433,9 @@ if this then
436else 433else
437 _module_0[#_module_0 + 1] = 456 434 _module_0[#_module_0 + 1] = 456
438end 435end
439do 436local _with_0 = tmp
440 local _with_0 = tmp 437local j = 2000
441 local j = 2000 438_module_0[#_module_0 + 1] = _with_0
442 _module_0[#_module_0 + 1] = _with_0
443end
444return _module_0 439return _module_0
445local _module_0 = nil 440local _module_0 = nil
446_module_0 = function() 441_module_0 = function()
@@ -577,25 +572,19 @@ for _index_0 = 1, #tuples do
577 local left, right = _des_0[1], _des_0[2] 572 local left, right = _des_0[1], _des_0[2]
578 print(left, right) 573 print(left, right)
579end 574end
580do 575local user = database.find_user("moon")
581 local user = database.find_user("moon") 576if user then
582 if user then 577 print(user.name)
583 print(user.name)
584 end
585end 578end
586do 579local hello = os.getenv("hello")
587 local hello = os.getenv("hello") 580if hello then
588 if hello then 581 print("You have hello", hello)
589 print("You have hello", hello) 582else
583 local world = os.getenv("world")
584 if world then
585 print("you have world", world)
590 else 586 else
591 do 587 print("nothing :(")
592 local world = os.getenv("world")
593 if world then
594 print("you have world", world)
595 else
596 print("nothing :(")
597 end
598 end
599 end 588 end
600end 589end
601do 590do
@@ -858,40 +847,34 @@ local items = {
858 4 847 4
859} 848}
860local doubled 849local doubled
861do 850local _accum_0 = { }
862 local _accum_0 = { } 851local _len_0 = 1
863 local _len_0 = 1 852for i, item in ipairs(items) do
864 for i, item in ipairs(items) do 853 _accum_0[_len_0] = item * 2
865 _accum_0[_len_0] = item * 2 854 _len_0 = _len_0 + 1
866 _len_0 = _len_0 + 1
867 end
868 doubled = _accum_0
869end 855end
856doubled = _accum_0
870local iter = ipairs(items) 857local iter = ipairs(items)
871local slice 858local slice
872do 859local _accum_0 = { }
873 local _accum_0 = { } 860local _len_0 = 1
874 local _len_0 = 1 861for i, item in iter do
875 for i, item in iter do 862 if i > 1 and i < 3 then
876 if i > 1 and i < 3 then 863 _accum_0[_len_0] = item
877 _accum_0[_len_0] = item 864 _len_0 = _len_0 + 1
878 _len_0 = _len_0 + 1
879 end
880 end 865 end
881 slice = _accum_0
882end 866end
867slice = _accum_0
883local doubled 868local doubled
884do 869local _accum_0 = { }
885 local _accum_0 = { } 870local _len_0 = 1
886 local _len_0 = 1 871local _list_0 = items
887 local _list_0 = items 872for _index_0 = 1, #_list_0 do
888 for _index_0 = 1, #_list_0 do 873 local item = _list_0[_index_0]
889 local item = _list_0[_index_0] 874 _accum_0[_len_0] = item * 2
890 _accum_0[_len_0] = item * 2 875 _len_0 = _len_0 + 1
891 _len_0 = _len_0 + 1
892 end
893 doubled = _accum_0
894end 876end
877doubled = _accum_0
895local x_coords = { 878local x_coords = {
896 4, 879 4,
897 5, 880 5,
@@ -904,57 +887,49 @@ local y_coords = {
904 3 887 3
905} 888}
906local points 889local points
907do 890local _accum_0 = { }
908 local _accum_0 = { } 891local _len_0 = 1
909 local _len_0 = 1 892for _index_0 = 1, #x_coords do
910 for _index_0 = 1, #x_coords do 893 local x = x_coords[_index_0]
911 local x = x_coords[_index_0] 894 for _index_1 = 1, #y_coords do
912 for _index_1 = 1, #y_coords do 895 local y = y_coords[_index_1]
913 local y = y_coords[_index_1] 896 _accum_0[_len_0] = {
914 _accum_0[_len_0] = { 897 x,
915 x, 898 y
916 y 899 }
917 } 900 _len_0 = _len_0 + 1
918 _len_0 = _len_0 + 1
919 end
920 end 901 end
921 points = _accum_0
922end 902end
903points = _accum_0
923local evens 904local evens
924do 905local _accum_0 = { }
925 local _accum_0 = { } 906local _len_0 = 1
926 local _len_0 = 1 907for i = 1, 100 do
927 for i = 1, 100 do 908 if i % 2 == 0 then
928 if i % 2 == 0 then 909 _accum_0[_len_0] = i
929 _accum_0[_len_0] = i 910 _len_0 = _len_0 + 1
930 _len_0 = _len_0 + 1
931 end
932 end 911 end
933 evens = _accum_0
934end 912end
913evens = _accum_0
935local thing = { 914local thing = {
936 color = "red", 915 color = "red",
937 name = "fast", 916 name = "fast",
938 width = 123 917 width = 123
939} 918}
940local thing_copy 919local thing_copy
941do 920local _tbl_0 = { }
942 local _tbl_0 = { } 921for k, v in pairs(thing) do
943 for k, v in pairs(thing) do 922 _tbl_0[k] = v
944 _tbl_0[k] = v
945 end
946 thing_copy = _tbl_0
947end 923end
924thing_copy = _tbl_0
948local no_color 925local no_color
949do 926local _tbl_0 = { }
950 local _tbl_0 = { } 927for k, v in pairs(thing) do
951 for k, v in pairs(thing) do 928 if k ~= "color" then
952 if k ~= "color" then 929 _tbl_0[k] = v
953 _tbl_0[k] = v
954 end
955 end 930 end
956 no_color = _tbl_0
957end 931end
932no_color = _tbl_0
958local numbers = { 933local numbers = {
959 1, 934 1,
960 2, 935 2,
@@ -962,14 +937,12 @@ local numbers = {
962 4 937 4
963} 938}
964local sqrts 939local sqrts
965do 940local _tbl_0 = { }
966 local _tbl_0 = { } 941for _index_0 = 1, #numbers do
967 for _index_0 = 1, #numbers do 942 local i = numbers[_index_0]
968 local i = numbers[_index_0] 943 _tbl_0[i] = math.sqrt(i)
969 _tbl_0[i] = math.sqrt(i)
970 end
971 sqrts = _tbl_0
972end 944end
945sqrts = _tbl_0
973local tuples = { 946local tuples = {
974 { 947 {
975 "hello", 948 "hello",
@@ -981,52 +954,44 @@ local tuples = {
981 } 954 }
982} 955}
983local tbl 956local tbl
984do 957local _tbl_0 = { }
985 local _tbl_0 = { } 958for _index_0 = 1, #tuples do
986 for _index_0 = 1, #tuples do 959 local tuple = tuples[_index_0]
987 local tuple = tuples[_index_0] 960 local _key_0, _val_0 = unpack(tuple)
988 local _key_0, _val_0 = unpack(tuple) 961 _tbl_0[_key_0] = _val_0
989 _tbl_0[_key_0] = _val_0
990 end
991 tbl = _tbl_0
992end 962end
963tbl = _tbl_0
993local slice 964local slice
994do 965local _accum_0 = { }
995 local _accum_0 = { } 966local _len_0 = 1
996 local _len_0 = 1 967local _list_0 = items
997 local _list_0 = items 968local _max_0 = 5
998 local _max_0 = 5 969for _index_0 = 1, _max_0 < 0 and #_list_0 + _max_0 or _max_0 do
999 for _index_0 = 1, _max_0 < 0 and #_list_0 + _max_0 or _max_0 do 970 local item = _list_0[_index_0]
1000 local item = _list_0[_index_0] 971 _accum_0[_len_0] = item
1001 _accum_0[_len_0] = item 972 _len_0 = _len_0 + 1
1002 _len_0 = _len_0 + 1
1003 end
1004 slice = _accum_0
1005end 973end
974slice = _accum_0
1006local slice 975local slice
1007do 976local _accum_0 = { }
1008 local _accum_0 = { } 977local _len_0 = 1
1009 local _len_0 = 1 978local _list_0 = items
1010 local _list_0 = items 979for _index_0 = 2, #_list_0 do
1011 for _index_0 = 2, #_list_0 do 980 local item = _list_0[_index_0]
1012 local item = _list_0[_index_0] 981 _accum_0[_len_0] = item
1013 _accum_0[_len_0] = item 982 _len_0 = _len_0 + 1
1014 _len_0 = _len_0 + 1
1015 end
1016 slice = _accum_0
1017end 983end
984slice = _accum_0
1018local slice 985local slice
1019do 986local _accum_0 = { }
1020 local _accum_0 = { } 987local _len_0 = 1
1021 local _len_0 = 1 988local _list_0 = items
1022 local _list_0 = items 989for _index_0 = 1, #_list_0, 2 do
1023 for _index_0 = 1, #_list_0, 2 do 990 local item = _list_0[_index_0]
1024 local item = _list_0[_index_0] 991 _accum_0[_len_0] = item
1025 _accum_0[_len_0] = item 992 _len_0 = _len_0 + 1
1026 _len_0 = _len_0 + 1
1027 end
1028 slice = _accum_0
1029end 993end
994slice = _accum_0
1030for i = 10, 20 do 995for i = 10, 20 do
1031 print(i) 996 print(i)
1032end 997end
@@ -1036,13 +1001,11 @@ end
1036for key, value in pairs(object) do 1001for key, value in pairs(object) do
1037 print(key, value) 1002 print(key, value)
1038end 1003end
1039do 1004local _list_0 = items
1040 local _list_0 = items 1005local _max_0 = 4
1041 local _max_0 = 4 1006for _index_0 = 2, _max_0 < 0 and #_list_0 + _max_0 or _max_0 do
1042 for _index_0 = 2, _max_0 < 0 and #_list_0 + _max_0 or _max_0 do 1007 local item = _list_0[_index_0]
1043 local item = _list_0[_index_0] 1008 print(item)
1044 print(item)
1045 end
1046end 1009end
1047local _list_0 = items 1010local _list_0 = items
1048for _index_0 = 1, #_list_0 do 1011for _index_0 = 1, #_list_0 do
@@ -1053,19 +1016,17 @@ for j = 1, 10, 3 do
1053 print(j) 1016 print(j)
1054end 1017end
1055local doubled_evens 1018local doubled_evens
1056do 1019local _accum_0 = { }
1057 local _accum_0 = { } 1020local _len_0 = 1
1058 local _len_0 = 1 1021for i = 1, 20 do
1059 for i = 1, 20 do 1022 if i % 2 == 0 then
1060 if i % 2 == 0 then 1023 _accum_0[_len_0] = i * 2
1061 _accum_0[_len_0] = i * 2 1024 else
1062 else 1025 _accum_0[_len_0] = i
1063 _accum_0[_len_0] = i
1064 end
1065 _len_0 = _len_0 + 1
1066 end 1026 end
1067 doubled_evens = _accum_0 1027 _len_0 = _len_0 + 1
1068end 1028end
1029doubled_evens = _accum_0
1069local func_a 1030local func_a
1070func_a = function() 1031func_a = function()
1071 for i = 1, 10 do 1032 for i = 1, 10 do
@@ -1123,20 +1084,18 @@ local my_numbers = {
1123 6 1084 6
1124} 1085}
1125local odds 1086local odds
1126do 1087local _accum_0 = { }
1127 local _accum_0 = { } 1088local _len_0 = 1
1128 local _len_0 = 1 1089for _index_0 = 1, #my_numbers do
1129 for _index_0 = 1, #my_numbers do 1090 local x = my_numbers[_index_0]
1130 local x = my_numbers[_index_0] 1091 if x % 2 == 1 then
1131 if x % 2 == 1 then 1092 goto _continue_0
1132 goto _continue_0
1133 end
1134 _accum_0[_len_0] = x
1135 _len_0 = _len_0 + 1
1136 ::_continue_0::
1137 end 1093 end
1138 odds = _accum_0 1094 _accum_0[_len_0] = x
1095 _len_0 = _len_0 + 1
1096 ::_continue_0::
1139end 1097end
1098odds = _accum_0
1140local have_coins = false 1099local have_coins = false
1141if have_coins then 1100if have_coins then
1142 print("Got coins") 1101 print("Got coins")
@@ -1228,15 +1187,13 @@ else
1228 next_number = error("can't count that high!") 1187 next_number = error("can't count that high!")
1229end 1188end
1230local msg 1189local msg
1231do 1190local _exp_0 = math.random(1, 5)
1232 local _exp_0 = math.random(1, 5) 1191if 1 == _exp_0 then
1233 if 1 == _exp_0 then 1192 msg = "you are lucky"
1234 msg = "you are lucky" 1193elseif 2 == _exp_0 then
1235 elseif 2 == _exp_0 then 1194 msg = "you are almost lucky"
1236 msg = "you are almost lucky" 1195else
1237 else 1196 msg = "not so lucky"
1238 msg = "not so lucky"
1239 end
1240end 1197end
1241do 1198do
1242 local _exp_0 = math.random(1, 5) 1199 local _exp_0 = math.random(1, 5)
@@ -1246,13 +1203,11 @@ do
1246 print("not so lucky") 1203 print("not so lucky")
1247 end 1204 end
1248end 1205end
1249do 1206local _exp_0 = math.random(1, 5)
1250 local _exp_0 = math.random(1, 5) 1207if 1 == _exp_0 then
1251 if 1 == _exp_0 then 1208 print("you are lucky")
1252 print("you are lucky") 1209else
1253 else 1210 print("not so lucky")
1254 print("not so lucky")
1255 end
1256end 1211end
1257local items = { 1212local items = {
1258 { 1213 {
@@ -1266,25 +1221,23 @@ local items = {
1266} 1221}
1267for _index_0 = 1, #items do 1222for _index_0 = 1, #items do
1268 local item = items[_index_0] 1223 local item = items[_index_0]
1269 do 1224 local _type_0 = type(item)
1270 local _type_0 = type(item) 1225 local _tab_0 = "table" == _type_0 or "userdata" == _type_0
1271 local _tab_0 = "table" == _type_0 or "userdata" == _type_0 1226 local _match_0 = false
1272 local _match_0 = false 1227 if _tab_0 then
1273 if _tab_0 then 1228 local x = item.x
1274 local x = item.x 1229 local y = item.y
1275 local y = item.y 1230 if x ~= nil and y ~= nil then
1276 if x ~= nil and y ~= nil then 1231 _match_0 = true
1277 _match_0 = true 1232 print("Vec2 " .. tostring(x) .. ", " .. tostring(y))
1278 print("Vec2 " .. tostring(x) .. ", " .. tostring(y))
1279 end
1280 end 1233 end
1281 if not _match_0 then 1234 end
1282 if _tab_0 then 1235 if not _match_0 then
1283 local width = item.width 1236 if _tab_0 then
1284 local height = item.height 1237 local width = item.width
1285 if width ~= nil and height ~= nil then 1238 local height = item.height
1286 print("size " .. tostring(width) .. ", " .. tostring(height)) 1239 if width ~= nil and height ~= nil then
1287 end 1240 print("size " .. tostring(width) .. ", " .. tostring(height))
1288 end 1241 end
1289 end 1242 end
1290 end 1243 end
@@ -1297,66 +1250,62 @@ end
1297if y == nil then 1250if y == nil then
1298 y = 200 1251 y = 200
1299end 1252end
1300do 1253local _type_0 = type(item)
1301 local _type_0 = type(item) 1254local _tab_0 = "table" == _type_0 or "userdata" == _type_0
1302 local _tab_0 = "table" == _type_0 or "userdata" == _type_0 1255if _tab_0 then
1303 if _tab_0 then 1256 do
1304 do 1257 local _obj_0 = item.pos
1305 local _obj_0 = item.pos 1258 local _type_1 = type(_obj_0)
1306 local _type_1 = type(_obj_0) 1259 if "table" == _type_1 or "userdata" == _type_1 then
1307 if "table" == _type_1 or "userdata" == _type_1 then 1260 x = _obj_0.x
1308 x = _obj_0.x
1309 end
1310 end
1311 do
1312 local _obj_0 = item.pos
1313 local _type_1 = type(_obj_0)
1314 if "table" == _type_1 or "userdata" == _type_1 then
1315 y = _obj_0.y
1316 end
1317 end
1318 if x == nil then
1319 x = 50
1320 end 1261 end
1321 if y == nil then 1262 end
1322 y = 200 1263 do
1264 local _obj_0 = item.pos
1265 local _type_1 = type(_obj_0)
1266 if "table" == _type_1 or "userdata" == _type_1 then
1267 y = _obj_0.y
1323 end 1268 end
1324 print("Vec2 " .. tostring(x) .. ", " .. tostring(y))
1325 end 1269 end
1270 if x == nil then
1271 x = 50
1272 end
1273 if y == nil then
1274 y = 200
1275 end
1276 print("Vec2 " .. tostring(x) .. ", " .. tostring(y))
1326end 1277end
1327local Inventory 1278local Inventory
1328do 1279local _class_0
1329 local _class_0 1280local _base_0 = {
1330 local _base_0 = { 1281 add_item = function(self, name)
1331 add_item = function(self, name) 1282 if self.items[name] then
1332 if self.items[name] then 1283 local _obj_0 = self.items
1333 local _obj_0 = self.items 1284 _obj_0[name] = _obj_0[name] + 1
1334 _obj_0[name] = _obj_0[name] + 1 1285 else
1335 else 1286 self.items[name] = 1
1336 self.items[name] = 1
1337 end
1338 end 1287 end
1339 }
1340 if _base_0.__index == nil then
1341 _base_0.__index = _base_0
1342 end 1288 end
1343 _class_0 = setmetatable({ 1289}
1344 __init = function(self) 1290if _base_0.__index == nil then
1345 self.items = { } 1291 _base_0.__index = _base_0
1346 end,
1347 __base = _base_0,
1348 __name = "Inventory"
1349 }, {
1350 __index = _base_0,
1351 __call = function(cls, ...)
1352 local _self_0 = setmetatable({ }, _base_0)
1353 cls.__init(_self_0, ...)
1354 return _self_0
1355 end
1356 })
1357 _base_0.__class = _class_0
1358 Inventory = _class_0
1359end 1292end
1293_class_0 = setmetatable({
1294 __init = function(self)
1295 self.items = { }
1296 end,
1297 __base = _base_0,
1298 __name = "Inventory"
1299}, {
1300 __index = _base_0,
1301 __call = function(cls, ...)
1302 local _self_0 = setmetatable({ }, _base_0)
1303 cls.__init(_self_0, ...)
1304 return _self_0
1305 end
1306})
1307_base_0.__class = _class_0
1308Inventory = _class_0
1360local inv = Inventory() 1309local inv = Inventory()
1361inv:add_item("t-shirt") 1310inv:add_item("t-shirt")
1362inv:add_item("pants") 1311inv:add_item("pants")
@@ -1397,82 +1346,78 @@ for _index_0 = 1, #_list_0 do
1397 print(item) 1346 print(item)
1398end 1347end
1399local Person 1348local Person
1400do 1349local _class_0
1401 local _class_0 1350local _base_0 = { }
1402 local _base_0 = { } 1351if _base_0.__index == nil then
1403 if _base_0.__index == nil then 1352 _base_0.__index = _base_0
1404 _base_0.__index = _base_0 1353end
1354_class_0 = setmetatable({
1355 __init = function(self)
1356 self.clothes = { }
1357 end,
1358 __base = _base_0,
1359 __name = "Person"
1360}, {
1361 __index = _base_0,
1362 __call = function(cls, ...)
1363 local _self_0 = setmetatable({ }, _base_0)
1364 cls.__init(_self_0, ...)
1365 return _self_0
1405 end 1366 end
1406 _class_0 = setmetatable({ 1367})
1407 __init = function(self) 1368_base_0.__class = _class_0
1408 self.clothes = { } 1369Person = _class_0
1409 end,
1410 __base = _base_0,
1411 __name = "Person"
1412 }, {
1413 __index = _base_0,
1414 __call = function(cls, ...)
1415 local _self_0 = setmetatable({ }, _base_0)
1416 cls.__init(_self_0, ...)
1417 return _self_0
1418 end
1419 })
1420 _base_0.__class = _class_0
1421 Person = _class_0
1422end
1423local BackPack 1370local BackPack
1424do 1371local _class_0
1425 local _class_0 1372local _parent_0 = Inventory
1426 local _parent_0 = Inventory 1373local _base_0 = {
1427 local _base_0 = { 1374 size = 10,
1428 size = 10, 1375 add_item = function(self, name)
1429 add_item = function(self, name) 1376 if #self.items > size then
1430 if #self.items > size then 1377 error("backpack is full")
1431 error("backpack is full")
1432 end
1433 return _class_0.__parent.__base.add_item(self, name)
1434 end
1435 }
1436 for _key_0, _val_0 in pairs(_parent_0.__base) do
1437 if _base_0[_key_0] == nil and _key_0:match("^__") and not (_key_0 == "__index" and _val_0 == _parent_0.__base) then
1438 _base_0[_key_0] = _val_0
1439 end 1378 end
1379 return _class_0.__parent.__base.add_item(self, name)
1440 end 1380 end
1441 if _base_0.__index == nil then 1381}
1442 _base_0.__index = _base_0 1382for _key_0, _val_0 in pairs(_parent_0.__base) do
1383 if _base_0[_key_0] == nil and _key_0:match("^__") and not (_key_0 == "__index" and _val_0 == _parent_0.__base) then
1384 _base_0[_key_0] = _val_0
1443 end 1385 end
1444 setmetatable(_base_0, _parent_0.__base) 1386end
1445 _class_0 = setmetatable({ 1387if _base_0.__index == nil then
1446 __init = function(self, ...) 1388 _base_0.__index = _base_0
1447 return _class_0.__parent.__init(self, ...) 1389end
1448 end, 1390setmetatable(_base_0, _parent_0.__base)
1449 __base = _base_0, 1391_class_0 = setmetatable({
1450 __name = "BackPack", 1392 __init = function(self, ...)
1451 __parent = _parent_0 1393 return _class_0.__parent.__init(self, ...)
1452 }, { 1394 end,
1453 __index = function(cls, name) 1395 __base = _base_0,
1454 local val = rawget(_base_0, name) 1396 __name = "BackPack",
1455 if val == nil then 1397 __parent = _parent_0
1456 local parent = rawget(cls, "__parent") 1398}, {
1457 if parent then 1399 __index = function(cls, name)
1458 return parent[name] 1400 local val = rawget(_base_0, name)
1459 end 1401 if val == nil then
1460 else 1402 local parent = rawget(cls, "__parent")
1461 return val 1403 if parent then
1404 return parent[name]
1462 end 1405 end
1463 end, 1406 else
1464 __call = function(cls, ...) 1407 return val
1465 local _self_0 = setmetatable({ }, _base_0)
1466 cls.__init(_self_0, ...)
1467 return _self_0
1468 end 1408 end
1469 }) 1409 end,
1470 _base_0.__class = _class_0 1410 __call = function(cls, ...)
1471 if _parent_0.__inherited then 1411 local _self_0 = setmetatable({ }, _base_0)
1472 _parent_0.__inherited(_parent_0, _class_0) 1412 cls.__init(_self_0, ...)
1413 return _self_0
1473 end 1414 end
1474 BackPack = _class_0 1415})
1416_base_0.__class = _class_0
1417if _parent_0.__inherited then
1418 _parent_0.__inherited(_parent_0, _class_0)
1475end 1419end
1420BackPack = _class_0
1476local Shelf 1421local Shelf
1477do 1422do
1478 local _class_0 1423 local _class_0
@@ -1500,102 +1445,98 @@ do
1500 Shelf = _class_0 1445 Shelf = _class_0
1501end 1446end
1502local Cupboard 1447local Cupboard
1503do 1448local _class_0
1504 local _class_0 1449local _parent_0 = Shelf
1505 local _parent_0 = Shelf 1450local _base_0 = { }
1506 local _base_0 = { } 1451for _key_0, _val_0 in pairs(_parent_0.__base) do
1507 for _key_0, _val_0 in pairs(_parent_0.__base) do 1452 if _base_0[_key_0] == nil and _key_0:match("^__") and not (_key_0 == "__index" and _val_0 == _parent_0.__base) then
1508 if _base_0[_key_0] == nil and _key_0:match("^__") and not (_key_0 == "__index" and _val_0 == _parent_0.__base) then 1453 _base_0[_key_0] = _val_0
1509 _base_0[_key_0] = _val_0 1454 end
1510 end 1455end
1511 end 1456if _base_0.__index == nil then
1512 if _base_0.__index == nil then 1457 _base_0.__index = _base_0
1513 _base_0.__index = _base_0 1458end
1514 end 1459setmetatable(_base_0, _parent_0.__base)
1515 setmetatable(_base_0, _parent_0.__base) 1460_class_0 = setmetatable({
1516 _class_0 = setmetatable({ 1461 __init = function(self, ...)
1517 __init = function(self, ...) 1462 return _class_0.__parent.__init(self, ...)
1518 return _class_0.__parent.__init(self, ...) 1463 end,
1519 end, 1464 __base = _base_0,
1520 __base = _base_0, 1465 __name = "Cupboard",
1521 __name = "Cupboard", 1466 __parent = _parent_0
1522 __parent = _parent_0 1467}, {
1523 }, { 1468 __index = function(cls, name)
1524 __index = function(cls, name) 1469 local val = rawget(_base_0, name)
1525 local val = rawget(_base_0, name) 1470 if val == nil then
1526 if val == nil then 1471 local parent = rawget(cls, "__parent")
1527 local parent = rawget(cls, "__parent") 1472 if parent then
1528 if parent then 1473 return parent[name]
1529 return parent[name]
1530 end
1531 else
1532 return val
1533 end 1474 end
1534 end, 1475 else
1535 __call = function(cls, ...) 1476 return val
1536 local _self_0 = setmetatable({ }, _base_0)
1537 cls.__init(_self_0, ...)
1538 return _self_0
1539 end 1477 end
1540 }) 1478 end,
1541 _base_0.__class = _class_0 1479 __call = function(cls, ...)
1542 if _parent_0.__inherited then 1480 local _self_0 = setmetatable({ }, _base_0)
1543 _parent_0.__inherited(_parent_0, _class_0) 1481 cls.__init(_self_0, ...)
1482 return _self_0
1544 end 1483 end
1545 Cupboard = _class_0 1484})
1485_base_0.__class = _class_0
1486if _parent_0.__inherited then
1487 _parent_0.__inherited(_parent_0, _class_0)
1546end 1488end
1489Cupboard = _class_0
1547local MyClass 1490local MyClass
1548do 1491local _class_0
1549 local _class_0 1492local _parent_0 = ParentClass
1550 local _parent_0 = ParentClass 1493local _base_0 = {
1551 local _base_0 = { 1494 a_method = function(self)
1552 a_method = function(self) 1495 _class_0.__parent.__base.a_method(self, "hello", "world")
1553 _class_0.__parent.__base.a_method(self, "hello", "world") 1496 _class_0.__parent.a_method(self, "hello", "world")
1554 _class_0.__parent.a_method(self, "hello", "world") 1497 _class_0.__parent.a_method(self, "hello", "world")
1555 _class_0.__parent.a_method(self, "hello", "world") 1498 return assert(_class_0.__parent == ParentClass)
1556 return assert(_class_0.__parent == ParentClass) 1499 end
1557 end 1500}
1558 } 1501for _key_0, _val_0 in pairs(_parent_0.__base) do
1559 for _key_0, _val_0 in pairs(_parent_0.__base) do 1502 if _base_0[_key_0] == nil and _key_0:match("^__") and not (_key_0 == "__index" and _val_0 == _parent_0.__base) then
1560 if _base_0[_key_0] == nil and _key_0:match("^__") and not (_key_0 == "__index" and _val_0 == _parent_0.__base) then 1503 _base_0[_key_0] = _val_0
1561 _base_0[_key_0] = _val_0 1504 end
1562 end 1505end
1563 end 1506if _base_0.__index == nil then
1564 if _base_0.__index == nil then 1507 _base_0.__index = _base_0
1565 _base_0.__index = _base_0 1508end
1566 end 1509setmetatable(_base_0, _parent_0.__base)
1567 setmetatable(_base_0, _parent_0.__base) 1510_class_0 = setmetatable({
1568 _class_0 = setmetatable({ 1511 __init = function(self, ...)
1569 __init = function(self, ...) 1512 return _class_0.__parent.__init(self, ...)
1570 return _class_0.__parent.__init(self, ...) 1513 end,
1571 end, 1514 __base = _base_0,
1572 __base = _base_0, 1515 __name = "MyClass",
1573 __name = "MyClass", 1516 __parent = _parent_0
1574 __parent = _parent_0 1517}, {
1575 }, { 1518 __index = function(cls, name)
1576 __index = function(cls, name) 1519 local val = rawget(_base_0, name)
1577 local val = rawget(_base_0, name) 1520 if val == nil then
1578 if val == nil then 1521 local parent = rawget(cls, "__parent")
1579 local parent = rawget(cls, "__parent") 1522 if parent then
1580 if parent then 1523 return parent[name]
1581 return parent[name]
1582 end
1583 else
1584 return val
1585 end 1524 end
1586 end, 1525 else
1587 __call = function(cls, ...) 1526 return val
1588 local _self_0 = setmetatable({ }, _base_0)
1589 cls.__init(_self_0, ...)
1590 return _self_0
1591 end 1527 end
1592 }) 1528 end,
1593 _base_0.__class = _class_0 1529 __call = function(cls, ...)
1594 if _parent_0.__inherited then 1530 local _self_0 = setmetatable({ }, _base_0)
1595 _parent_0.__inherited(_parent_0, _class_0) 1531 cls.__init(_self_0, ...)
1532 return _self_0
1596 end 1533 end
1597 MyClass = _class_0 1534})
1535_base_0.__class = _class_0
1536if _parent_0.__inherited then
1537 _parent_0.__inherited(_parent_0, _class_0)
1598end 1538end
1539MyClass = _class_0
1599local b = BackPack() 1540local b = BackPack()
1600assert(b.__class == BackPack) 1541assert(b.__class == BackPack)
1601print(BackPack.size) 1542print(BackPack.size)
@@ -1659,61 +1600,57 @@ Counter()
1659print(Counter.count) 1600print(Counter.count)
1660self.__class:hello(1, 2, 3, 4) 1601self.__class:hello(1, 2, 3, 4)
1661local Things 1602local Things
1662do 1603local _class_0
1663 local _class_0 1604local _base_0 = { }
1664 local _base_0 = { } 1605if _base_0.__index == nil then
1665 if _base_0.__index == nil then 1606 _base_0.__index = _base_0
1666 _base_0.__index = _base_0 1607end
1608_class_0 = setmetatable({
1609 __init = function() end,
1610 __base = _base_0,
1611 __name = "Things"
1612}, {
1613 __index = _base_0,
1614 __call = function(cls, ...)
1615 local _self_0 = setmetatable({ }, _base_0)
1616 cls.__init(_self_0, ...)
1617 return _self_0
1667 end 1618 end
1668 _class_0 = setmetatable({ 1619})
1669 __init = function() end, 1620_base_0.__class = _class_0
1670 __base = _base_0, 1621local self = _class_0;
1671 __name = "Things" 1622self.class_var = "hello world"
1672 }, { 1623Things = _class_0
1673 __index = _base_0,
1674 __call = function(cls, ...)
1675 local _self_0 = setmetatable({ }, _base_0)
1676 cls.__init(_self_0, ...)
1677 return _self_0
1678 end
1679 })
1680 _base_0.__class = _class_0
1681 local self = _class_0;
1682 self.class_var = "hello world"
1683 Things = _class_0
1684end
1685local MoreThings 1624local MoreThings
1686do 1625local _class_0
1687 local _class_0 1626local secret, log
1688 local secret, log 1627local _base_0 = {
1689 local _base_0 = { 1628 some_method = function(self)
1690 some_method = function(self) 1629 return log("hello world: " .. secret)
1691 return log("hello world: " .. secret)
1692 end
1693 }
1694 if _base_0.__index == nil then
1695 _base_0.__index = _base_0
1696 end 1630 end
1697 _class_0 = setmetatable({ 1631}
1698 __init = function() end, 1632if _base_0.__index == nil then
1699 __base = _base_0, 1633 _base_0.__index = _base_0
1700 __name = "MoreThings" 1634end
1701 }, { 1635_class_0 = setmetatable({
1702 __index = _base_0, 1636 __init = function() end,
1703 __call = function(cls, ...) 1637 __base = _base_0,
1704 local _self_0 = setmetatable({ }, _base_0) 1638 __name = "MoreThings"
1705 cls.__init(_self_0, ...) 1639}, {
1706 return _self_0 1640 __index = _base_0,
1707 end 1641 __call = function(cls, ...)
1708 }) 1642 local _self_0 = setmetatable({ }, _base_0)
1709 _base_0.__class = _class_0 1643 cls.__init(_self_0, ...)
1710 local self = _class_0; 1644 return _self_0
1711 secret = 123
1712 log = function(msg)
1713 return print("LOG:", msg)
1714 end 1645 end
1715 MoreThings = _class_0 1646})
1647_base_0.__class = _class_0
1648local self = _class_0;
1649secret = 123
1650log = function(msg)
1651 return print("LOG:", msg)
1716end 1652end
1653MoreThings = _class_0
1717assert(self == self) 1654assert(self == self)
1718assert(self.__class == self.__class) 1655assert(self.__class == self.__class)
1719local some_instance_method 1656local some_instance_method
@@ -1747,32 +1684,30 @@ do
1747 _base_0.__class = _class_0 1684 _base_0.__class = _class_0
1748 Something = _class_0 1685 Something = _class_0
1749end 1686end
1750do 1687local _class_0
1751 local _class_0 1688local _base_0 = { }
1752 local _base_0 = { } 1689if _base_0.__index == nil then
1753 if _base_0.__index == nil then 1690 _base_0.__index = _base_0
1754 _base_0.__index = _base_0 1691end
1692_class_0 = setmetatable({
1693 __init = function(self, foo, bar, biz, baz)
1694 self.foo = foo
1695 self.bar = bar
1696 self.__class.biz = biz
1697 self.__class.baz = baz
1698 end,
1699 __base = _base_0,
1700 __name = "Something"
1701}, {
1702 __index = _base_0,
1703 __call = function(cls, ...)
1704 local _self_0 = setmetatable({ }, _base_0)
1705 cls.__init(_self_0, ...)
1706 return _self_0
1755 end 1707 end
1756 _class_0 = setmetatable({ 1708})
1757 __init = function(self, foo, bar, biz, baz) 1709_base_0.__class = _class_0
1758 self.foo = foo 1710Something = _class_0
1759 self.bar = bar
1760 self.__class.biz = biz
1761 self.__class.baz = baz
1762 end,
1763 __base = _base_0,
1764 __name = "Something"
1765 }, {
1766 __index = _base_0,
1767 __call = function(cls, ...)
1768 local _self_0 = setmetatable({ }, _base_0)
1769 cls.__init(_self_0, ...)
1770 return _self_0
1771 end
1772 })
1773 _base_0.__class = _class_0
1774 Something = _class_0
1775end
1776local new 1711local new
1777new = function(self, fieldA, fieldB) 1712new = function(self, fieldA, fieldB)
1778 self.fieldA = fieldA 1713 self.fieldA = fieldA
@@ -1783,33 +1718,31 @@ local obj = new({ }, 123, "abc")
1783print(obj) 1718print(obj)
1784local x 1719local x
1785local Bucket 1720local Bucket
1786do 1721local _class_0
1787 local _class_0 1722local _base_0 = {
1788 local _base_0 = { 1723 drops = 0,
1789 drops = 0, 1724 add_drop = function(self)
1790 add_drop = function(self) 1725 self.drops = self.drops + 1
1791 self.drops = self.drops + 1
1792 end
1793 }
1794 if _base_0.__index == nil then
1795 _base_0.__index = _base_0
1796 end 1726 end
1797 _class_0 = setmetatable({ 1727}
1798 __init = function() end, 1728if _base_0.__index == nil then
1799 __base = _base_0, 1729 _base_0.__index = _base_0
1800 __name = "Bucket"
1801 }, {
1802 __index = _base_0,
1803 __call = function(cls, ...)
1804 local _self_0 = setmetatable({ }, _base_0)
1805 cls.__init(_self_0, ...)
1806 return _self_0
1807 end
1808 })
1809 _base_0.__class = _class_0
1810 Bucket = _class_0
1811 x = _class_0
1812end 1730end
1731_class_0 = setmetatable({
1732 __init = function() end,
1733 __base = _base_0,
1734 __name = "Bucket"
1735}, {
1736 __index = _base_0,
1737 __call = function(cls, ...)
1738 local _self_0 = setmetatable({ }, _base_0)
1739 cls.__init(_self_0, ...)
1740 return _self_0
1741 end
1742})
1743_base_0.__class = _class_0
1744Bucket = _class_0
1745x = _class_0
1813local BigBucket 1746local BigBucket
1814do 1747do
1815 local _class_0 1748 local _class_0
@@ -1861,27 +1794,25 @@ do
1861end 1794end
1862assert(Bucket.__name == "BigBucket") 1795assert(Bucket.__name == "BigBucket")
1863local x 1796local x
1864do 1797local _class_0
1865 local _class_0 1798local _base_0 = { }
1866 local _base_0 = { } 1799if _base_0.__index == nil then
1867 if _base_0.__index == nil then 1800 _base_0.__index = _base_0
1868 _base_0.__index = _base_0 1801end
1802_class_0 = setmetatable({
1803 __init = function() end,
1804 __base = _base_0,
1805 __name = "x"
1806}, {
1807 __index = _base_0,
1808 __call = function(cls, ...)
1809 local _self_0 = setmetatable({ }, _base_0)
1810 cls.__init(_self_0, ...)
1811 return _self_0
1869 end 1812 end
1870 _class_0 = setmetatable({ 1813})
1871 __init = function() end, 1814_base_0.__class = _class_0
1872 __base = _base_0, 1815x = _class_0
1873 __name = "x"
1874 }, {
1875 __index = _base_0,
1876 __call = function(cls, ...)
1877 local _self_0 = setmetatable({ }, _base_0)
1878 cls.__init(_self_0, ...)
1879 return _self_0
1880 end
1881 })
1882 _base_0.__class = _class_0
1883 x = _class_0
1884end
1885local MyIndex = { 1816local MyIndex = {
1886 __index = { 1817 __index = {
1887 var = 1 1818 var = 1
@@ -1964,19 +1895,15 @@ end
1964local y = Y() 1895local y = Y()
1965y:func() 1896y:func()
1966assert(y.__class.__parent ~= X) 1897assert(y.__class.__parent ~= X)
1967do 1898local _with_0 = Person()
1968 local _with_0 = Person() 1899_with_0.name = "Oswald"
1969 _with_0.name = "Oswald" 1900_with_0:add_relative(my_dad)
1970 _with_0:add_relative(my_dad) 1901_with_0:save()
1971 _with_0:save() 1902print(_with_0.name)
1972 print(_with_0.name)
1973end
1974local file 1903local file
1975do 1904local _with_0 = File("favorite_foods.txt")
1976 local _with_0 = File("favorite_foods.txt") 1905_with_0:set_encoding("utf8")
1977 _with_0:set_encoding("utf8") 1906file = _with_0
1978 file = _with_0
1979end
1980local create_person 1907local create_person
1981create_person = function(name, relatives) 1908create_person = function(name, relatives)
1982 local _with_0 = Person() 1909 local _with_0 = Person()
@@ -1992,22 +1919,18 @@ local me = create_person("Leaf", {
1992 mother, 1919 mother,
1993 sister 1920 sister
1994}) 1921})
1922local str = "Hello"
1923print("original:", str)
1924print("upper:", str:upper())
1925local _with_0 = tb
1926_with_0[1] = 1
1927print(_with_0[2])
1995do 1928do
1996 local str = "Hello" 1929 local _with_1 = _with_0[abc]
1997 print("original:", str) 1930 _with_1[3] = _with_1[2]:func()
1998 print("upper:", str:upper()) 1931 _with_1["key-name"] = value
1999end
2000do
2001 local _with_0 = tb
2002 _with_0[1] = 1
2003 print(_with_0[2])
2004 do
2005 local _with_1 = _with_0[abc]
2006 _with_1[3] = _with_1[2]:func()
2007 _with_1["key-name"] = value
2008 end
2009 _with_0[#_with_0 + 1] = "abc"
2010end 1932end
1933_with_0[#_with_0 + 1] = "abc"
2011do 1934do
2012 local var = "hello" 1935 local var = "hello"
2013 print(var) 1936 print(var)
@@ -2124,13 +2047,18 @@ _module_0["🌛"] = _ud83c_udf1b
2124return _module_0 2047return _module_0
2125local area = 6.2831853071796 * 5 2048local area = 6.2831853071796 * 5
2126print('hello world') 2049print('hello world')
2127assert(item ~= nil) 2050do
2051 assert(item ~= nil)
2052end
2128local value = item 2053local value = item
2129if (f1() and f2() and f3()) then 2054if (f1() and f2() and f3()) then
2130 print("OK") 2055 print("OK")
2131end 2056end
2057do
2058 local funcA
2059 funcA = function() end
2060end
2132local funcA 2061local funcA
2133funcA = function() end
2134funcA = function() 2062funcA = function()
2135 return "assign the Yue defined variable" 2063 return "assign the Yue defined variable"
2136end 2064end
@@ -2224,28 +2152,26 @@ local b = {
2224 y = 1 2152 y = 1
2225} 2153}
2226local merge 2154local merge
2227do 2155local _tab_0 = { }
2228 local _tab_0 = { } 2156local _idx_0 = 1
2229 local _idx_0 = 1 2157for _key_0, _value_0 in pairs(a) do
2230 for _key_0, _value_0 in pairs(a) do 2158 if _idx_0 == _key_0 then
2231 if _idx_0 == _key_0 then 2159 _tab_0[#_tab_0 + 1] = _value_0
2232 _tab_0[#_tab_0 + 1] = _value_0 2160 _idx_0 = _idx_0 + 1
2233 _idx_0 = _idx_0 + 1 2161 else
2234 else 2162 _tab_0[_key_0] = _value_0
2235 _tab_0[_key_0] = _value_0
2236 end
2237 end 2163 end
2238 local _idx_1 = 1 2164end
2239 for _key_0, _value_0 in pairs(b) do 2165local _idx_1 = 1
2240 if _idx_1 == _key_0 then 2166for _key_0, _value_0 in pairs(b) do
2241 _tab_0[#_tab_0 + 1] = _value_0 2167 if _idx_1 == _key_0 then
2242 _idx_1 = _idx_1 + 1 2168 _tab_0[#_tab_0 + 1] = _value_0
2243 else 2169 _idx_1 = _idx_1 + 1
2244 _tab_0[_key_0] = _value_0 2170 else
2245 end 2171 _tab_0[_key_0] = _value_0
2246 end 2172 end
2247 merge = _tab_0
2248end 2173end
2174merge = _tab_0
2249local mt = { } 2175local mt = { }
2250local add 2176local add
2251add = function(self, right) 2177add = function(self, right)
@@ -2337,12 +2263,10 @@ end
2337if print and (x ~= nil) then 2263if print and (x ~= nil) then
2338 print(x) 2264 print(x)
2339end 2265end
2340do 2266local _with_0 = io.open("test.txt", "w")
2341 local _with_0 = io.open("test.txt", "w") 2267if _with_0 ~= nil then
2342 if _with_0 ~= nil then 2268 _with_0:write("hello")
2343 _with_0:write("hello") 2269 _with_0:close()
2344 _with_0:close()
2345 end
2346end 2270end
2347print("hello") 2271print("hello")
2348print(1, 2) 2272print(1, 2)
@@ -2419,10 +2343,8 @@ do
2419 x, y, z = _obj_0.x, _obj_0.y, _obj_0.z 2343 x, y, z = _obj_0.x, _obj_0.y, _obj_0.z
2420 end 2344 end
2421 local a, b, c 2345 local a, b, c
2422 do 2346 local _obj_0 = require('module')
2423 local _obj_0 = require('module') 2347 a, b, c = _obj_0.a, _obj_0.b, _obj_0.c
2424 a, b, c = _obj_0.a, _obj_0.b, _obj_0.c
2425 end
2426end 2348end
2427do 2349do
2428 local module = require('module') 2350 local module = require('module')
@@ -2461,29 +2383,27 @@ y = function()
2461end 2383end
2462_module_0["y"] = y 2384_module_0["y"] = y
2463local Something 2385local Something
2464do 2386local _class_0
2465 local _class_0 2387local _base_0 = {
2466 local _base_0 = { 2388 umm = "cool"
2467 umm = "cool" 2389}
2468 } 2390if _base_0.__index == nil then
2469 if _base_0.__index == nil then 2391 _base_0.__index = _base_0
2470 _base_0.__index = _base_0
2471 end
2472 _class_0 = setmetatable({
2473 __init = function() end,
2474 __base = _base_0,
2475 __name = "Something"
2476 }, {
2477 __index = _base_0,
2478 __call = function(cls, ...)
2479 local _self_0 = setmetatable({ }, _base_0)
2480 cls.__init(_self_0, ...)
2481 return _self_0
2482 end
2483 })
2484 _base_0.__class = _class_0
2485 Something = _class_0
2486end 2392end
2393_class_0 = setmetatable({
2394 __init = function() end,
2395 __base = _base_0,
2396 __name = "Something"
2397}, {
2398 __index = _base_0,
2399 __call = function(cls, ...)
2400 local _self_0 = setmetatable({ }, _base_0)
2401 cls.__init(_self_0, ...)
2402 return _self_0
2403 end
2404})
2405_base_0.__class = _class_0
2406Something = _class_0
2487_module_0["Something"] = Something 2407_module_0["Something"] = Something
2488return _module_0 2408return _module_0
2489local _module_0 = { } 2409local _module_0 = { }
@@ -2514,11 +2434,9 @@ if this then
2514else 2434else
2515 _module_0[#_module_0 + 1] = 456 2435 _module_0[#_module_0 + 1] = 456
2516end 2436end
2517do 2437local _with_0 = tmp
2518 local _with_0 = tmp 2438local j = 2000
2519 local j = 2000 2439_module_0[#_module_0 + 1] = _with_0
2520 _module_0[#_module_0 + 1] = _with_0
2521end
2522return _module_0 2440return _module_0
2523local _module_0 = nil 2441local _module_0 = nil
2524_module_0 = function() 2442_module_0 = function()
@@ -2655,25 +2573,19 @@ for _index_0 = 1, #tuples do
2655 local left, right = _des_0[1], _des_0[2] 2573 local left, right = _des_0[1], _des_0[2]
2656 print(left, right) 2574 print(left, right)
2657end 2575end
2658do 2576local user = database.find_user("moon")
2659 local user = database.find_user("moon") 2577if user then
2660 if user then 2578 print(user.name)
2661 print(user.name)
2662 end
2663end 2579end
2664do 2580local hello = os.getenv("hello")
2665 local hello = os.getenv("hello") 2581if hello then
2666 if hello then 2582 print("You have hello", hello)
2667 print("You have hello", hello) 2583else
2584 local world = os.getenv("world")
2585 if world then
2586 print("you have world", world)
2668 else 2587 else
2669 do 2588 print("nothing :(")
2670 local world = os.getenv("world")
2671 if world then
2672 print("you have world", world)
2673 else
2674 print("nothing :(")
2675 end
2676 end
2677 end 2589 end
2678end 2590end
2679do 2591do
@@ -2936,40 +2848,34 @@ local items = {
2936 4 2848 4
2937} 2849}
2938local doubled 2850local doubled
2939do 2851local _accum_0 = { }
2940 local _accum_0 = { } 2852local _len_0 = 1
2941 local _len_0 = 1 2853for i, item in ipairs(items) do
2942 for i, item in ipairs(items) do 2854 _accum_0[_len_0] = item * 2
2943 _accum_0[_len_0] = item * 2 2855 _len_0 = _len_0 + 1
2944 _len_0 = _len_0 + 1
2945 end
2946 doubled = _accum_0
2947end 2856end
2857doubled = _accum_0
2948local iter = ipairs(items) 2858local iter = ipairs(items)
2949local slice 2859local slice
2950do 2860local _accum_0 = { }
2951 local _accum_0 = { } 2861local _len_0 = 1
2952 local _len_0 = 1 2862for i, item in iter do
2953 for i, item in iter do 2863 if i > 1 and i < 3 then
2954 if i > 1 and i < 3 then 2864 _accum_0[_len_0] = item
2955 _accum_0[_len_0] = item 2865 _len_0 = _len_0 + 1
2956 _len_0 = _len_0 + 1
2957 end
2958 end 2866 end
2959 slice = _accum_0
2960end 2867end
2868slice = _accum_0
2961local doubled 2869local doubled
2962do 2870local _accum_0 = { }
2963 local _accum_0 = { } 2871local _len_0 = 1
2964 local _len_0 = 1 2872local _list_0 = items
2965 local _list_0 = items 2873for _index_0 = 1, #_list_0 do
2966 for _index_0 = 1, #_list_0 do 2874 local item = _list_0[_index_0]
2967 local item = _list_0[_index_0] 2875 _accum_0[_len_0] = item * 2
2968 _accum_0[_len_0] = item * 2 2876 _len_0 = _len_0 + 1
2969 _len_0 = _len_0 + 1
2970 end
2971 doubled = _accum_0
2972end 2877end
2878doubled = _accum_0
2973local x_coords = { 2879local x_coords = {
2974 4, 2880 4,
2975 5, 2881 5,
@@ -2982,57 +2888,49 @@ local y_coords = {
2982 3 2888 3
2983} 2889}
2984local points 2890local points
2985do 2891local _accum_0 = { }
2986 local _accum_0 = { } 2892local _len_0 = 1
2987 local _len_0 = 1 2893for _index_0 = 1, #x_coords do
2988 for _index_0 = 1, #x_coords do 2894 local x = x_coords[_index_0]
2989 local x = x_coords[_index_0] 2895 for _index_1 = 1, #y_coords do
2990 for _index_1 = 1, #y_coords do 2896 local y = y_coords[_index_1]
2991 local y = y_coords[_index_1] 2897 _accum_0[_len_0] = {
2992 _accum_0[_len_0] = { 2898 x,
2993 x, 2899 y
2994 y 2900 }
2995 } 2901 _len_0 = _len_0 + 1
2996 _len_0 = _len_0 + 1
2997 end
2998 end 2902 end
2999 points = _accum_0
3000end 2903end
2904points = _accum_0
3001local evens 2905local evens
3002do 2906local _accum_0 = { }
3003 local _accum_0 = { } 2907local _len_0 = 1
3004 local _len_0 = 1 2908for i = 1, 100 do
3005 for i = 1, 100 do 2909 if i % 2 == 0 then
3006 if i % 2 == 0 then 2910 _accum_0[_len_0] = i
3007 _accum_0[_len_0] = i 2911 _len_0 = _len_0 + 1
3008 _len_0 = _len_0 + 1
3009 end
3010 end 2912 end
3011 evens = _accum_0
3012end 2913end
2914evens = _accum_0
3013local thing = { 2915local thing = {
3014 color = "red", 2916 color = "red",
3015 name = "fast", 2917 name = "fast",
3016 width = 123 2918 width = 123
3017} 2919}
3018local thing_copy 2920local thing_copy
3019do 2921local _tbl_0 = { }
3020 local _tbl_0 = { } 2922for k, v in pairs(thing) do
3021 for k, v in pairs(thing) do 2923 _tbl_0[k] = v
3022 _tbl_0[k] = v
3023 end
3024 thing_copy = _tbl_0
3025end 2924end
2925thing_copy = _tbl_0
3026local no_color 2926local no_color
3027do 2927local _tbl_0 = { }
3028 local _tbl_0 = { } 2928for k, v in pairs(thing) do
3029 for k, v in pairs(thing) do 2929 if k ~= "color" then
3030 if k ~= "color" then 2930 _tbl_0[k] = v
3031 _tbl_0[k] = v
3032 end
3033 end 2931 end
3034 no_color = _tbl_0
3035end 2932end
2933no_color = _tbl_0
3036local numbers = { 2934local numbers = {
3037 1, 2935 1,
3038 2, 2936 2,
@@ -3040,14 +2938,12 @@ local numbers = {
3040 4 2938 4
3041} 2939}
3042local sqrts 2940local sqrts
3043do 2941local _tbl_0 = { }
3044 local _tbl_0 = { } 2942for _index_0 = 1, #numbers do
3045 for _index_0 = 1, #numbers do 2943 local i = numbers[_index_0]
3046 local i = numbers[_index_0] 2944 _tbl_0[i] = math.sqrt(i)
3047 _tbl_0[i] = math.sqrt(i)
3048 end
3049 sqrts = _tbl_0
3050end 2945end
2946sqrts = _tbl_0
3051local tuples = { 2947local tuples = {
3052 { 2948 {
3053 "hello", 2949 "hello",
@@ -3059,52 +2955,44 @@ local tuples = {
3059 } 2955 }
3060} 2956}
3061local tbl 2957local tbl
3062do 2958local _tbl_0 = { }
3063 local _tbl_0 = { } 2959for _index_0 = 1, #tuples do
3064 for _index_0 = 1, #tuples do 2960 local tuple = tuples[_index_0]
3065 local tuple = tuples[_index_0] 2961 local _key_0, _val_0 = unpack(tuple)
3066 local _key_0, _val_0 = unpack(tuple) 2962 _tbl_0[_key_0] = _val_0
3067 _tbl_0[_key_0] = _val_0
3068 end
3069 tbl = _tbl_0
3070end 2963end
2964tbl = _tbl_0
3071local slice 2965local slice
3072do 2966local _accum_0 = { }
3073 local _accum_0 = { } 2967local _len_0 = 1
3074 local _len_0 = 1 2968local _list_0 = items
3075 local _list_0 = items 2969local _max_0 = 5
3076 local _max_0 = 5 2970for _index_0 = 1, _max_0 < 0 and #_list_0 + _max_0 or _max_0 do
3077 for _index_0 = 1, _max_0 < 0 and #_list_0 + _max_0 or _max_0 do 2971 local item = _list_0[_index_0]
3078 local item = _list_0[_index_0] 2972 _accum_0[_len_0] = item
3079 _accum_0[_len_0] = item 2973 _len_0 = _len_0 + 1
3080 _len_0 = _len_0 + 1
3081 end
3082 slice = _accum_0
3083end 2974end
2975slice = _accum_0
3084local slice 2976local slice
3085do 2977local _accum_0 = { }
3086 local _accum_0 = { } 2978local _len_0 = 1
3087 local _len_0 = 1 2979local _list_0 = items
3088 local _list_0 = items 2980for _index_0 = 2, #_list_0 do
3089 for _index_0 = 2, #_list_0 do 2981 local item = _list_0[_index_0]
3090 local item = _list_0[_index_0] 2982 _accum_0[_len_0] = item
3091 _accum_0[_len_0] = item 2983 _len_0 = _len_0 + 1
3092 _len_0 = _len_0 + 1
3093 end
3094 slice = _accum_0
3095end 2984end
2985slice = _accum_0
3096local slice 2986local slice
3097do 2987local _accum_0 = { }
3098 local _accum_0 = { } 2988local _len_0 = 1
3099 local _len_0 = 1 2989local _list_0 = items
3100 local _list_0 = items 2990for _index_0 = 1, #_list_0, 2 do
3101 for _index_0 = 1, #_list_0, 2 do 2991 local item = _list_0[_index_0]
3102 local item = _list_0[_index_0] 2992 _accum_0[_len_0] = item
3103 _accum_0[_len_0] = item 2993 _len_0 = _len_0 + 1
3104 _len_0 = _len_0 + 1
3105 end
3106 slice = _accum_0
3107end 2994end
2995slice = _accum_0
3108for i = 10, 20 do 2996for i = 10, 20 do
3109 print(i) 2997 print(i)
3110end 2998end
@@ -3114,13 +3002,11 @@ end
3114for key, value in pairs(object) do 3002for key, value in pairs(object) do
3115 print(key, value) 3003 print(key, value)
3116end 3004end
3117do 3005local _list_0 = items
3118 local _list_0 = items 3006local _max_0 = 4
3119 local _max_0 = 4 3007for _index_0 = 2, _max_0 < 0 and #_list_0 + _max_0 or _max_0 do
3120 for _index_0 = 2, _max_0 < 0 and #_list_0 + _max_0 or _max_0 do 3008 local item = _list_0[_index_0]
3121 local item = _list_0[_index_0] 3009 print(item)
3122 print(item)
3123 end
3124end 3010end
3125local _list_0 = items 3011local _list_0 = items
3126for _index_0 = 1, #_list_0 do 3012for _index_0 = 1, #_list_0 do
@@ -3131,19 +3017,17 @@ for j = 1, 10, 3 do
3131 print(j) 3017 print(j)
3132end 3018end
3133local doubled_evens 3019local doubled_evens
3134do 3020local _accum_0 = { }
3135 local _accum_0 = { } 3021local _len_0 = 1
3136 local _len_0 = 1 3022for i = 1, 20 do
3137 for i = 1, 20 do 3023 if i % 2 == 0 then
3138 if i % 2 == 0 then 3024 _accum_0[_len_0] = i * 2
3139 _accum_0[_len_0] = i * 2 3025 else
3140 else 3026 _accum_0[_len_0] = i
3141 _accum_0[_len_0] = i
3142 end
3143 _len_0 = _len_0 + 1
3144 end 3027 end
3145 doubled_evens = _accum_0 3028 _len_0 = _len_0 + 1
3146end 3029end
3030doubled_evens = _accum_0
3147local func_a 3031local func_a
3148func_a = function() 3032func_a = function()
3149 for i = 1, 10 do 3033 for i = 1, 10 do
@@ -3201,20 +3085,18 @@ local my_numbers = {
3201 6 3085 6
3202} 3086}
3203local odds 3087local odds
3204do 3088local _accum_0 = { }
3205 local _accum_0 = { } 3089local _len_0 = 1
3206 local _len_0 = 1 3090for _index_0 = 1, #my_numbers do
3207 for _index_0 = 1, #my_numbers do 3091 local x = my_numbers[_index_0]
3208 local x = my_numbers[_index_0] 3092 if x % 2 == 1 then
3209 if x % 2 == 1 then 3093 goto _continue_0
3210 goto _continue_0
3211 end
3212 _accum_0[_len_0] = x
3213 _len_0 = _len_0 + 1
3214 ::_continue_0::
3215 end 3094 end
3216 odds = _accum_0 3095 _accum_0[_len_0] = x
3096 _len_0 = _len_0 + 1
3097 ::_continue_0::
3217end 3098end
3099odds = _accum_0
3218local have_coins = false 3100local have_coins = false
3219if have_coins then 3101if have_coins then
3220 print("Got coins") 3102 print("Got coins")
@@ -3306,15 +3188,13 @@ else
3306 next_number = error("can't count that high!") 3188 next_number = error("can't count that high!")
3307end 3189end
3308local msg 3190local msg
3309do 3191local _exp_0 = math.random(1, 5)
3310 local _exp_0 = math.random(1, 5) 3192if 1 == _exp_0 then
3311 if 1 == _exp_0 then 3193 msg = "you are lucky"
3312 msg = "you are lucky" 3194elseif 2 == _exp_0 then
3313 elseif 2 == _exp_0 then 3195 msg = "you are almost lucky"
3314 msg = "you are almost lucky" 3196else
3315 else 3197 msg = "not so lucky"
3316 msg = "not so lucky"
3317 end
3318end 3198end
3319do 3199do
3320 local _exp_0 = math.random(1, 5) 3200 local _exp_0 = math.random(1, 5)
@@ -3324,13 +3204,11 @@ do
3324 print("not so lucky") 3204 print("not so lucky")
3325 end 3205 end
3326end 3206end
3327do 3207local _exp_0 = math.random(1, 5)
3328 local _exp_0 = math.random(1, 5) 3208if 1 == _exp_0 then
3329 if 1 == _exp_0 then 3209 print("you are lucky")
3330 print("you are lucky") 3210else
3331 else 3211 print("not so lucky")
3332 print("not so lucky")
3333 end
3334end 3212end
3335local items = { 3213local items = {
3336 { 3214 {
@@ -3344,25 +3222,23 @@ local items = {
3344} 3222}
3345for _index_0 = 1, #items do 3223for _index_0 = 1, #items do
3346 local item = items[_index_0] 3224 local item = items[_index_0]
3347 do 3225 local _type_0 = type(item)
3348 local _type_0 = type(item) 3226 local _tab_0 = "table" == _type_0 or "userdata" == _type_0
3349 local _tab_0 = "table" == _type_0 or "userdata" == _type_0 3227 local _match_0 = false
3350 local _match_0 = false 3228 if _tab_0 then
3351 if _tab_0 then 3229 local x = item.x
3352 local x = item.x 3230 local y = item.y
3353 local y = item.y 3231 if x ~= nil and y ~= nil then
3354 if x ~= nil and y ~= nil then 3232 _match_0 = true
3355 _match_0 = true 3233 print("Vec2 " .. tostring(x) .. ", " .. tostring(y))
3356 print("Vec2 " .. tostring(x) .. ", " .. tostring(y))
3357 end
3358 end 3234 end
3359 if not _match_0 then 3235 end
3360 if _tab_0 then 3236 if not _match_0 then
3361 local width = item.width 3237 if _tab_0 then
3362 local height = item.height 3238 local width = item.width
3363 if width ~= nil and height ~= nil then 3239 local height = item.height
3364 print("size " .. tostring(width) .. ", " .. tostring(height)) 3240 if width ~= nil and height ~= nil then
3365 end 3241 print("size " .. tostring(width) .. ", " .. tostring(height))
3366 end 3242 end
3367 end 3243 end
3368 end 3244 end
@@ -3375,66 +3251,62 @@ end
3375if y == nil then 3251if y == nil then
3376 y = 200 3252 y = 200
3377end 3253end
3378do 3254local _type_0 = type(item)
3379 local _type_0 = type(item) 3255local _tab_0 = "table" == _type_0 or "userdata" == _type_0
3380 local _tab_0 = "table" == _type_0 or "userdata" == _type_0 3256if _tab_0 then
3381 if _tab_0 then 3257 do
3382 do 3258 local _obj_0 = item.pos
3383 local _obj_0 = item.pos 3259 local _type_1 = type(_obj_0)
3384 local _type_1 = type(_obj_0) 3260 if "table" == _type_1 or "userdata" == _type_1 then
3385 if "table" == _type_1 or "userdata" == _type_1 then 3261 x = _obj_0.x
3386 x = _obj_0.x
3387 end
3388 end
3389 do
3390 local _obj_0 = item.pos
3391 local _type_1 = type(_obj_0)
3392 if "table" == _type_1 or "userdata" == _type_1 then
3393 y = _obj_0.y
3394 end
3395 end
3396 if x == nil then
3397 x = 50
3398 end 3262 end
3399 if y == nil then 3263 end
3400 y = 200 3264 do
3265 local _obj_0 = item.pos
3266 local _type_1 = type(_obj_0)
3267 if "table" == _type_1 or "userdata" == _type_1 then
3268 y = _obj_0.y
3401 end 3269 end
3402 print("Vec2 " .. tostring(x) .. ", " .. tostring(y))
3403 end 3270 end
3271 if x == nil then
3272 x = 50
3273 end
3274 if y == nil then
3275 y = 200
3276 end
3277 print("Vec2 " .. tostring(x) .. ", " .. tostring(y))
3404end 3278end
3405local Inventory 3279local Inventory
3406do 3280local _class_0
3407 local _class_0 3281local _base_0 = {
3408 local _base_0 = { 3282 add_item = function(self, name)
3409 add_item = function(self, name) 3283 if self.items[name] then
3410 if self.items[name] then 3284 local _obj_0 = self.items
3411 local _obj_0 = self.items 3285 _obj_0[name] = _obj_0[name] + 1
3412 _obj_0[name] = _obj_0[name] + 1 3286 else
3413 else 3287 self.items[name] = 1
3414 self.items[name] = 1
3415 end
3416 end 3288 end
3417 }
3418 if _base_0.__index == nil then
3419 _base_0.__index = _base_0
3420 end 3289 end
3421 _class_0 = setmetatable({ 3290}
3422 __init = function(self) 3291if _base_0.__index == nil then
3423 self.items = { } 3292 _base_0.__index = _base_0
3424 end,
3425 __base = _base_0,
3426 __name = "Inventory"
3427 }, {
3428 __index = _base_0,
3429 __call = function(cls, ...)
3430 local _self_0 = setmetatable({ }, _base_0)
3431 cls.__init(_self_0, ...)
3432 return _self_0
3433 end
3434 })
3435 _base_0.__class = _class_0
3436 Inventory = _class_0
3437end 3293end
3294_class_0 = setmetatable({
3295 __init = function(self)
3296 self.items = { }
3297 end,
3298 __base = _base_0,
3299 __name = "Inventory"
3300}, {
3301 __index = _base_0,
3302 __call = function(cls, ...)
3303 local _self_0 = setmetatable({ }, _base_0)
3304 cls.__init(_self_0, ...)
3305 return _self_0
3306 end
3307})
3308_base_0.__class = _class_0
3309Inventory = _class_0
3438local inv = Inventory() 3310local inv = Inventory()
3439inv:add_item("t-shirt") 3311inv:add_item("t-shirt")
3440inv:add_item("pants") 3312inv:add_item("pants")
@@ -3475,82 +3347,78 @@ for _index_0 = 1, #_list_0 do
3475 print(item) 3347 print(item)
3476end 3348end
3477local Person 3349local Person
3478do 3350local _class_0
3479 local _class_0 3351local _base_0 = { }
3480 local _base_0 = { } 3352if _base_0.__index == nil then
3481 if _base_0.__index == nil then 3353 _base_0.__index = _base_0
3482 _base_0.__index = _base_0 3354end
3355_class_0 = setmetatable({
3356 __init = function(self)
3357 self.clothes = { }
3358 end,
3359 __base = _base_0,
3360 __name = "Person"
3361}, {
3362 __index = _base_0,
3363 __call = function(cls, ...)
3364 local _self_0 = setmetatable({ }, _base_0)
3365 cls.__init(_self_0, ...)
3366 return _self_0
3483 end 3367 end
3484 _class_0 = setmetatable({ 3368})
3485 __init = function(self) 3369_base_0.__class = _class_0
3486 self.clothes = { } 3370Person = _class_0
3487 end,
3488 __base = _base_0,
3489 __name = "Person"
3490 }, {
3491 __index = _base_0,
3492 __call = function(cls, ...)
3493 local _self_0 = setmetatable({ }, _base_0)
3494 cls.__init(_self_0, ...)
3495 return _self_0
3496 end
3497 })
3498 _base_0.__class = _class_0
3499 Person = _class_0
3500end
3501local BackPack 3371local BackPack
3502do 3372local _class_0
3503 local _class_0 3373local _parent_0 = Inventory
3504 local _parent_0 = Inventory 3374local _base_0 = {
3505 local _base_0 = { 3375 size = 10,
3506 size = 10, 3376 add_item = function(self, name)
3507 add_item = function(self, name) 3377 if #self.items > size then
3508 if #self.items > size then 3378 error("backpack is full")
3509 error("backpack is full")
3510 end
3511 return _class_0.__parent.__base.add_item(self, name)
3512 end
3513 }
3514 for _key_0, _val_0 in pairs(_parent_0.__base) do
3515 if _base_0[_key_0] == nil and _key_0:match("^__") and not (_key_0 == "__index" and _val_0 == _parent_0.__base) then
3516 _base_0[_key_0] = _val_0
3517 end 3379 end
3380 return _class_0.__parent.__base.add_item(self, name)
3518 end 3381 end
3519 if _base_0.__index == nil then 3382}
3520 _base_0.__index = _base_0 3383for _key_0, _val_0 in pairs(_parent_0.__base) do
3384 if _base_0[_key_0] == nil and _key_0:match("^__") and not (_key_0 == "__index" and _val_0 == _parent_0.__base) then
3385 _base_0[_key_0] = _val_0
3521 end 3386 end
3522 setmetatable(_base_0, _parent_0.__base) 3387end
3523 _class_0 = setmetatable({ 3388if _base_0.__index == nil then
3524 __init = function(self, ...) 3389 _base_0.__index = _base_0
3525 return _class_0.__parent.__init(self, ...) 3390end
3526 end, 3391setmetatable(_base_0, _parent_0.__base)
3527 __base = _base_0, 3392_class_0 = setmetatable({
3528 __name = "BackPack", 3393 __init = function(self, ...)
3529 __parent = _parent_0 3394 return _class_0.__parent.__init(self, ...)
3530 }, { 3395 end,
3531 __index = function(cls, name) 3396 __base = _base_0,
3532 local val = rawget(_base_0, name) 3397 __name = "BackPack",
3533 if val == nil then 3398 __parent = _parent_0
3534 local parent = rawget(cls, "__parent") 3399}, {
3535 if parent then 3400 __index = function(cls, name)
3536 return parent[name] 3401 local val = rawget(_base_0, name)
3537 end 3402 if val == nil then
3538 else 3403 local parent = rawget(cls, "__parent")
3539 return val 3404 if parent then
3405 return parent[name]
3540 end 3406 end
3541 end, 3407 else
3542 __call = function(cls, ...) 3408 return val
3543 local _self_0 = setmetatable({ }, _base_0)
3544 cls.__init(_self_0, ...)
3545 return _self_0
3546 end 3409 end
3547 }) 3410 end,
3548 _base_0.__class = _class_0 3411 __call = function(cls, ...)
3549 if _parent_0.__inherited then 3412 local _self_0 = setmetatable({ }, _base_0)
3550 _parent_0.__inherited(_parent_0, _class_0) 3413 cls.__init(_self_0, ...)
3414 return _self_0
3551 end 3415 end
3552 BackPack = _class_0 3416})
3417_base_0.__class = _class_0
3418if _parent_0.__inherited then
3419 _parent_0.__inherited(_parent_0, _class_0)
3553end 3420end
3421BackPack = _class_0
3554local Shelf 3422local Shelf
3555do 3423do
3556 local _class_0 3424 local _class_0
@@ -3578,102 +3446,98 @@ do
3578 Shelf = _class_0 3446 Shelf = _class_0
3579end 3447end
3580local Cupboard 3448local Cupboard
3581do 3449local _class_0
3582 local _class_0 3450local _parent_0 = Shelf
3583 local _parent_0 = Shelf 3451local _base_0 = { }
3584 local _base_0 = { } 3452for _key_0, _val_0 in pairs(_parent_0.__base) do
3585 for _key_0, _val_0 in pairs(_parent_0.__base) do 3453 if _base_0[_key_0] == nil and _key_0:match("^__") and not (_key_0 == "__index" and _val_0 == _parent_0.__base) then
3586 if _base_0[_key_0] == nil and _key_0:match("^__") and not (_key_0 == "__index" and _val_0 == _parent_0.__base) then 3454 _base_0[_key_0] = _val_0
3587 _base_0[_key_0] = _val_0 3455 end
3588 end 3456end
3589 end 3457if _base_0.__index == nil then
3590 if _base_0.__index == nil then 3458 _base_0.__index = _base_0
3591 _base_0.__index = _base_0 3459end
3592 end 3460setmetatable(_base_0, _parent_0.__base)
3593 setmetatable(_base_0, _parent_0.__base) 3461_class_0 = setmetatable({
3594 _class_0 = setmetatable({ 3462 __init = function(self, ...)
3595 __init = function(self, ...) 3463 return _class_0.__parent.__init(self, ...)
3596 return _class_0.__parent.__init(self, ...) 3464 end,
3597 end, 3465 __base = _base_0,
3598 __base = _base_0, 3466 __name = "Cupboard",
3599 __name = "Cupboard", 3467 __parent = _parent_0
3600 __parent = _parent_0 3468}, {
3601 }, { 3469 __index = function(cls, name)
3602 __index = function(cls, name) 3470 local val = rawget(_base_0, name)
3603 local val = rawget(_base_0, name) 3471 if val == nil then
3604 if val == nil then 3472 local parent = rawget(cls, "__parent")
3605 local parent = rawget(cls, "__parent") 3473 if parent then
3606 if parent then 3474 return parent[name]
3607 return parent[name]
3608 end
3609 else
3610 return val
3611 end 3475 end
3612 end, 3476 else
3613 __call = function(cls, ...) 3477 return val
3614 local _self_0 = setmetatable({ }, _base_0)
3615 cls.__init(_self_0, ...)
3616 return _self_0
3617 end 3478 end
3618 }) 3479 end,
3619 _base_0.__class = _class_0 3480 __call = function(cls, ...)
3620 if _parent_0.__inherited then 3481 local _self_0 = setmetatable({ }, _base_0)
3621 _parent_0.__inherited(_parent_0, _class_0) 3482 cls.__init(_self_0, ...)
3483 return _self_0
3622 end 3484 end
3623 Cupboard = _class_0 3485})
3486_base_0.__class = _class_0
3487if _parent_0.__inherited then
3488 _parent_0.__inherited(_parent_0, _class_0)
3624end 3489end
3490Cupboard = _class_0
3625local MyClass 3491local MyClass
3626do 3492local _class_0
3627 local _class_0 3493local _parent_0 = ParentClass
3628 local _parent_0 = ParentClass 3494local _base_0 = {
3629 local _base_0 = { 3495 a_method = function(self)
3630 a_method = function(self) 3496 _class_0.__parent.__base.a_method(self, "hello", "world")
3631 _class_0.__parent.__base.a_method(self, "hello", "world") 3497 _class_0.__parent.a_method(self, "hello", "world")
3632 _class_0.__parent.a_method(self, "hello", "world") 3498 _class_0.__parent.a_method(self, "hello", "world")
3633 _class_0.__parent.a_method(self, "hello", "world") 3499 return assert(_class_0.__parent == ParentClass)
3634 return assert(_class_0.__parent == ParentClass) 3500 end
3635 end 3501}
3636 } 3502for _key_0, _val_0 in pairs(_parent_0.__base) do
3637 for _key_0, _val_0 in pairs(_parent_0.__base) do 3503 if _base_0[_key_0] == nil and _key_0:match("^__") and not (_key_0 == "__index" and _val_0 == _parent_0.__base) then
3638 if _base_0[_key_0] == nil and _key_0:match("^__") and not (_key_0 == "__index" and _val_0 == _parent_0.__base) then 3504 _base_0[_key_0] = _val_0
3639 _base_0[_key_0] = _val_0 3505 end
3640 end 3506end
3641 end 3507if _base_0.__index == nil then
3642 if _base_0.__index == nil then 3508 _base_0.__index = _base_0
3643 _base_0.__index = _base_0 3509end
3644 end 3510setmetatable(_base_0, _parent_0.__base)
3645 setmetatable(_base_0, _parent_0.__base) 3511_class_0 = setmetatable({
3646 _class_0 = setmetatable({ 3512 __init = function(self, ...)
3647 __init = function(self, ...) 3513 return _class_0.__parent.__init(self, ...)
3648 return _class_0.__parent.__init(self, ...) 3514 end,
3649 end, 3515 __base = _base_0,
3650 __base = _base_0, 3516 __name = "MyClass",
3651 __name = "MyClass", 3517 __parent = _parent_0
3652 __parent = _parent_0 3518}, {
3653 }, { 3519 __index = function(cls, name)
3654 __index = function(cls, name) 3520 local val = rawget(_base_0, name)
3655 local val = rawget(_base_0, name) 3521 if val == nil then
3656 if val == nil then 3522 local parent = rawget(cls, "__parent")
3657 local parent = rawget(cls, "__parent") 3523 if parent then
3658 if parent then 3524 return parent[name]
3659 return parent[name]
3660 end
3661 else
3662 return val
3663 end 3525 end
3664 end, 3526 else
3665 __call = function(cls, ...) 3527 return val
3666 local _self_0 = setmetatable({ }, _base_0)
3667 cls.__init(_self_0, ...)
3668 return _self_0
3669 end 3528 end
3670 }) 3529 end,
3671 _base_0.__class = _class_0 3530 __call = function(cls, ...)
3672 if _parent_0.__inherited then 3531 local _self_0 = setmetatable({ }, _base_0)
3673 _parent_0.__inherited(_parent_0, _class_0) 3532 cls.__init(_self_0, ...)
3533 return _self_0
3674 end 3534 end
3675 MyClass = _class_0 3535})
3536_base_0.__class = _class_0
3537if _parent_0.__inherited then
3538 _parent_0.__inherited(_parent_0, _class_0)
3676end 3539end
3540MyClass = _class_0
3677local b = BackPack() 3541local b = BackPack()
3678assert(b.__class == BackPack) 3542assert(b.__class == BackPack)
3679print(BackPack.size) 3543print(BackPack.size)
@@ -3737,61 +3601,57 @@ Counter()
3737print(Counter.count) 3601print(Counter.count)
3738self.__class:hello(1, 2, 3, 4) 3602self.__class:hello(1, 2, 3, 4)
3739local Things 3603local Things
3740do 3604local _class_0
3741 local _class_0 3605local _base_0 = { }
3742 local _base_0 = { } 3606if _base_0.__index == nil then
3743 if _base_0.__index == nil then 3607 _base_0.__index = _base_0
3744 _base_0.__index = _base_0 3608end
3609_class_0 = setmetatable({
3610 __init = function() end,
3611 __base = _base_0,
3612 __name = "Things"
3613}, {
3614 __index = _base_0,
3615 __call = function(cls, ...)
3616 local _self_0 = setmetatable({ }, _base_0)
3617 cls.__init(_self_0, ...)
3618 return _self_0
3745 end 3619 end
3746 _class_0 = setmetatable({ 3620})
3747 __init = function() end, 3621_base_0.__class = _class_0
3748 __base = _base_0, 3622local self = _class_0;
3749 __name = "Things" 3623self.class_var = "hello world"
3750 }, { 3624Things = _class_0
3751 __index = _base_0,
3752 __call = function(cls, ...)
3753 local _self_0 = setmetatable({ }, _base_0)
3754 cls.__init(_self_0, ...)
3755 return _self_0
3756 end
3757 })
3758 _base_0.__class = _class_0
3759 local self = _class_0;
3760 self.class_var = "hello world"
3761 Things = _class_0
3762end
3763local MoreThings 3625local MoreThings
3764do 3626local _class_0
3765 local _class_0 3627local secret, log
3766 local secret, log 3628local _base_0 = {
3767 local _base_0 = { 3629 some_method = function(self)
3768 some_method = function(self) 3630 return log("hello world: " .. secret)
3769 return log("hello world: " .. secret)
3770 end
3771 }
3772 if _base_0.__index == nil then
3773 _base_0.__index = _base_0
3774 end 3631 end
3775 _class_0 = setmetatable({ 3632}
3776 __init = function() end, 3633if _base_0.__index == nil then
3777 __base = _base_0, 3634 _base_0.__index = _base_0
3778 __name = "MoreThings" 3635end
3779 }, { 3636_class_0 = setmetatable({
3780 __index = _base_0, 3637 __init = function() end,
3781 __call = function(cls, ...) 3638 __base = _base_0,
3782 local _self_0 = setmetatable({ }, _base_0) 3639 __name = "MoreThings"
3783 cls.__init(_self_0, ...) 3640}, {
3784 return _self_0 3641 __index = _base_0,
3785 end 3642 __call = function(cls, ...)
3786 }) 3643 local _self_0 = setmetatable({ }, _base_0)
3787 _base_0.__class = _class_0 3644 cls.__init(_self_0, ...)
3788 local self = _class_0; 3645 return _self_0
3789 secret = 123
3790 log = function(msg)
3791 return print("LOG:", msg)
3792 end 3646 end
3793 MoreThings = _class_0 3647})
3648_base_0.__class = _class_0
3649local self = _class_0;
3650secret = 123
3651log = function(msg)
3652 return print("LOG:", msg)
3794end 3653end
3654MoreThings = _class_0
3795assert(self == self) 3655assert(self == self)
3796assert(self.__class == self.__class) 3656assert(self.__class == self.__class)
3797local some_instance_method 3657local some_instance_method
@@ -3825,32 +3685,30 @@ do
3825 _base_0.__class = _class_0 3685 _base_0.__class = _class_0
3826 Something = _class_0 3686 Something = _class_0
3827end 3687end
3828do 3688local _class_0
3829 local _class_0 3689local _base_0 = { }
3830 local _base_0 = { } 3690if _base_0.__index == nil then
3831 if _base_0.__index == nil then 3691 _base_0.__index = _base_0
3832 _base_0.__index = _base_0 3692end
3693_class_0 = setmetatable({
3694 __init = function(self, foo, bar, biz, baz)
3695 self.foo = foo
3696 self.bar = bar
3697 self.__class.biz = biz
3698 self.__class.baz = baz
3699 end,
3700 __base = _base_0,
3701 __name = "Something"
3702}, {
3703 __index = _base_0,
3704 __call = function(cls, ...)
3705 local _self_0 = setmetatable({ }, _base_0)
3706 cls.__init(_self_0, ...)
3707 return _self_0
3833 end 3708 end
3834 _class_0 = setmetatable({ 3709})
3835 __init = function(self, foo, bar, biz, baz) 3710_base_0.__class = _class_0
3836 self.foo = foo 3711Something = _class_0
3837 self.bar = bar
3838 self.__class.biz = biz
3839 self.__class.baz = baz
3840 end,
3841 __base = _base_0,
3842 __name = "Something"
3843 }, {
3844 __index = _base_0,
3845 __call = function(cls, ...)
3846 local _self_0 = setmetatable({ }, _base_0)
3847 cls.__init(_self_0, ...)
3848 return _self_0
3849 end
3850 })
3851 _base_0.__class = _class_0
3852 Something = _class_0
3853end
3854local new 3712local new
3855new = function(self, fieldA, fieldB) 3713new = function(self, fieldA, fieldB)
3856 self.fieldA = fieldA 3714 self.fieldA = fieldA
@@ -3861,33 +3719,31 @@ local obj = new({ }, 123, "abc")
3861print(obj) 3719print(obj)
3862local x 3720local x
3863local Bucket 3721local Bucket
3864do 3722local _class_0
3865 local _class_0 3723local _base_0 = {
3866 local _base_0 = { 3724 drops = 0,
3867 drops = 0, 3725 add_drop = function(self)
3868 add_drop = function(self) 3726 self.drops = self.drops + 1
3869 self.drops = self.drops + 1
3870 end
3871 }
3872 if _base_0.__index == nil then
3873 _base_0.__index = _base_0
3874 end 3727 end
3875 _class_0 = setmetatable({ 3728}
3876 __init = function() end, 3729if _base_0.__index == nil then
3877 __base = _base_0, 3730 _base_0.__index = _base_0
3878 __name = "Bucket"
3879 }, {
3880 __index = _base_0,
3881 __call = function(cls, ...)
3882 local _self_0 = setmetatable({ }, _base_0)
3883 cls.__init(_self_0, ...)
3884 return _self_0
3885 end
3886 })
3887 _base_0.__class = _class_0
3888 Bucket = _class_0
3889 x = _class_0
3890end 3731end
3732_class_0 = setmetatable({
3733 __init = function() end,
3734 __base = _base_0,
3735 __name = "Bucket"
3736}, {
3737 __index = _base_0,
3738 __call = function(cls, ...)
3739 local _self_0 = setmetatable({ }, _base_0)
3740 cls.__init(_self_0, ...)
3741 return _self_0
3742 end
3743})
3744_base_0.__class = _class_0
3745Bucket = _class_0
3746x = _class_0
3891local BigBucket 3747local BigBucket
3892do 3748do
3893 local _class_0 3749 local _class_0
@@ -3939,27 +3795,25 @@ do
3939end 3795end
3940assert(Bucket.__name == "BigBucket") 3796assert(Bucket.__name == "BigBucket")
3941local x 3797local x
3942do 3798local _class_0
3943 local _class_0 3799local _base_0 = { }
3944 local _base_0 = { } 3800if _base_0.__index == nil then
3945 if _base_0.__index == nil then 3801 _base_0.__index = _base_0
3946 _base_0.__index = _base_0 3802end
3803_class_0 = setmetatable({
3804 __init = function() end,
3805 __base = _base_0,
3806 __name = "x"
3807}, {
3808 __index = _base_0,
3809 __call = function(cls, ...)
3810 local _self_0 = setmetatable({ }, _base_0)
3811 cls.__init(_self_0, ...)
3812 return _self_0
3947 end 3813 end
3948 _class_0 = setmetatable({ 3814})
3949 __init = function() end, 3815_base_0.__class = _class_0
3950 __base = _base_0, 3816x = _class_0
3951 __name = "x"
3952 }, {
3953 __index = _base_0,
3954 __call = function(cls, ...)
3955 local _self_0 = setmetatable({ }, _base_0)
3956 cls.__init(_self_0, ...)
3957 return _self_0
3958 end
3959 })
3960 _base_0.__class = _class_0
3961 x = _class_0
3962end
3963local MyIndex = { 3817local MyIndex = {
3964 __index = { 3818 __index = {
3965 var = 1 3819 var = 1
@@ -4042,19 +3896,15 @@ end
4042local y = Y() 3896local y = Y()
4043y:func() 3897y:func()
4044assert(y.__class.__parent ~= X) 3898assert(y.__class.__parent ~= X)
4045do 3899local _with_0 = Person()
4046 local _with_0 = Person() 3900_with_0.name = "Oswald"
4047 _with_0.name = "Oswald" 3901_with_0:add_relative(my_dad)
4048 _with_0:add_relative(my_dad) 3902_with_0:save()
4049 _with_0:save() 3903print(_with_0.name)
4050 print(_with_0.name)
4051end
4052local file 3904local file
4053do 3905local _with_0 = File("favorite_foods.txt")
4054 local _with_0 = File("favorite_foods.txt") 3906_with_0:set_encoding("utf8")
4055 _with_0:set_encoding("utf8") 3907file = _with_0
4056 file = _with_0
4057end
4058local create_person 3908local create_person
4059create_person = function(name, relatives) 3909create_person = function(name, relatives)
4060 local _with_0 = Person() 3910 local _with_0 = Person()
@@ -4070,22 +3920,18 @@ local me = create_person("Leaf", {
4070 mother, 3920 mother,
4071 sister 3921 sister
4072}) 3922})
4073do 3923local str = "Hello"
4074 local str = "Hello" 3924print("original:", str)
4075 print("original:", str) 3925print("upper:", str:upper())
4076 print("upper:", str:upper()) 3926local _with_0 = tb
4077end 3927_with_0[1] = 1
4078do 3928print(_with_0[2])
4079 local _with_0 = tb 3929do
4080 _with_0[1] = 1 3930 local _with_1 = _with_0[abc]
4081 print(_with_0[2]) 3931 _with_1[3] = _with_1[2]:func()
4082 do 3932 _with_1["key-name"] = value
4083 local _with_1 = _with_0[abc] 3933end
4084 _with_1[3] = _with_1[2]:func() 3934_with_0[#_with_0 + 1] = "abc"
4085 _with_1["key-name"] = value
4086 end
4087 _with_0[#_with_0 + 1] = "abc"
4088end
4089do 3935do
4090 local var = "hello" 3936 local var = "hello"
4091 print(var) 3937 print(var)
diff --git a/spec/outputs/codes_from_doc_zh.lua b/spec/outputs/codes_from_doc_zh.lua
index 15647b2..fff0bdd 100644
--- a/spec/outputs/codes_from_doc_zh.lua
+++ b/spec/outputs/codes_from_doc_zh.lua
@@ -46,13 +46,18 @@ _module_0["🌛"] = _ud83c_udf1b
46return _module_0 46return _module_0
47local area = 6.2831853071796 * 5 47local area = 6.2831853071796 * 5
48print('你好 世界') 48print('你好 世界')
49assert(item ~= nil) 49do
50 assert(item ~= nil)
51end
50local value = item 52local value = item
51if (f1() and f2() and f3()) then 53if (f1() and f2() and f3()) then
52 print("OK") 54 print("OK")
53end 55end
56do
57 local funcA
58 funcA = function() end
59end
54local funcA 60local funcA
55funcA = function() end
56funcA = function() 61funcA = function()
57 return "访问月之脚本定义的å˜é‡" 62 return "访问月之脚本定义的å˜é‡"
58end 63end
@@ -146,28 +151,26 @@ local b = {
146 y = 1 151 y = 1
147} 152}
148local merge 153local merge
149do 154local _tab_0 = { }
150 local _tab_0 = { } 155local _idx_0 = 1
151 local _idx_0 = 1 156for _key_0, _value_0 in pairs(a) do
152 for _key_0, _value_0 in pairs(a) do 157 if _idx_0 == _key_0 then
153 if _idx_0 == _key_0 then 158 _tab_0[#_tab_0 + 1] = _value_0
154 _tab_0[#_tab_0 + 1] = _value_0 159 _idx_0 = _idx_0 + 1
155 _idx_0 = _idx_0 + 1 160 else
156 else 161 _tab_0[_key_0] = _value_0
157 _tab_0[_key_0] = _value_0
158 end
159 end 162 end
160 local _idx_1 = 1 163end
161 for _key_0, _value_0 in pairs(b) do 164local _idx_1 = 1
162 if _idx_1 == _key_0 then 165for _key_0, _value_0 in pairs(b) do
163 _tab_0[#_tab_0 + 1] = _value_0 166 if _idx_1 == _key_0 then
164 _idx_1 = _idx_1 + 1 167 _tab_0[#_tab_0 + 1] = _value_0
165 else 168 _idx_1 = _idx_1 + 1
166 _tab_0[_key_0] = _value_0 169 else
167 end 170 _tab_0[_key_0] = _value_0
168 end 171 end
169 merge = _tab_0
170end 172end
173merge = _tab_0
171local mt = { } 174local mt = { }
172local add 175local add
173add = function(self, right) 176add = function(self, right)
@@ -259,12 +262,10 @@ end
259if print and (x ~= nil) then 262if print and (x ~= nil) then
260 print(x) 263 print(x)
261end 264end
262do 265local _with_0 = io.open("test.txt", "w")
263 local _with_0 = io.open("test.txt", "w") 266if _with_0 ~= nil then
264 if _with_0 ~= nil then 267 _with_0:write("你好")
265 _with_0:write("你好") 268 _with_0:close()
266 _with_0:close()
267 end
268end 269end
269print("你好") 270print("你好")
270print(1, 2) 271print(1, 2)
@@ -341,10 +342,8 @@ do
341 x, y, z = _obj_0.x, _obj_0.y, _obj_0.z 342 x, y, z = _obj_0.x, _obj_0.y, _obj_0.z
342 end 343 end
343 local a, b, c 344 local a, b, c
344 do 345 local _obj_0 = require('module')
345 local _obj_0 = require('module') 346 a, b, c = _obj_0.a, _obj_0.b, _obj_0.c
346 a, b, c = _obj_0.a, _obj_0.b, _obj_0.c
347 end
348end 347end
349do 348do
350 local module = require('module') 349 local module = require('module')
@@ -383,29 +382,27 @@ y = function()
383end 382end
384_module_0["y"] = y 383_module_0["y"] = y
385local Something 384local Something
386do 385local _class_0
387 local _class_0 386local _base_0 = {
388 local _base_0 = { 387 umm = "cool"
389 umm = "cool" 388}
390 } 389if _base_0.__index == nil then
391 if _base_0.__index == nil then 390 _base_0.__index = _base_0
392 _base_0.__index = _base_0
393 end
394 _class_0 = setmetatable({
395 __init = function() end,
396 __base = _base_0,
397 __name = "Something"
398 }, {
399 __index = _base_0,
400 __call = function(cls, ...)
401 local _self_0 = setmetatable({ }, _base_0)
402 cls.__init(_self_0, ...)
403 return _self_0
404 end
405 })
406 _base_0.__class = _class_0
407 Something = _class_0
408end 391end
392_class_0 = setmetatable({
393 __init = function() end,
394 __base = _base_0,
395 __name = "Something"
396}, {
397 __index = _base_0,
398 __call = function(cls, ...)
399 local _self_0 = setmetatable({ }, _base_0)
400 cls.__init(_self_0, ...)
401 return _self_0
402 end
403})
404_base_0.__class = _class_0
405Something = _class_0
409_module_0["Something"] = Something 406_module_0["Something"] = Something
410return _module_0 407return _module_0
411local _module_0 = { } 408local _module_0 = { }
@@ -436,11 +433,9 @@ if this then
436else 433else
437 _module_0[#_module_0 + 1] = 456 434 _module_0[#_module_0 + 1] = 456
438end 435end
439do 436local _with_0 = tmp
440 local _with_0 = tmp 437local j = 2000
441 local j = 2000 438_module_0[#_module_0 + 1] = _with_0
442 _module_0[#_module_0 + 1] = _with_0
443end
444return _module_0 439return _module_0
445local _module_0 = nil 440local _module_0 = nil
446_module_0 = function() 441_module_0 = function()
@@ -577,25 +572,19 @@ for _index_0 = 1, #tuples do
577 local left, right = _des_0[1], _des_0[2] 572 local left, right = _des_0[1], _des_0[2]
578 print(left, right) 573 print(left, right)
579end 574end
580do 575local user = database.find_user("moon")
581 local user = database.find_user("moon") 576if user then
582 if user then 577 print(user.name)
583 print(user.name)
584 end
585end 578end
586do 579local hello = os.getenv("hello")
587 local hello = os.getenv("hello") 580if hello then
588 if hello then 581 print("你有 hello", hello)
589 print("你有 hello", hello) 582else
583 local world = os.getenv("world")
584 if world then
585 print("你有 world", world)
590 else 586 else
591 do 587 print("什么都没有 :(")
592 local world = os.getenv("world")
593 if world then
594 print("你有 world", world)
595 else
596 print("什么都没有 :(")
597 end
598 end
599 end 588 end
600end 589end
601do 590do
@@ -852,40 +841,34 @@ local items = {
852 4 841 4
853} 842}
854local doubled 843local doubled
855do 844local _accum_0 = { }
856 local _accum_0 = { } 845local _len_0 = 1
857 local _len_0 = 1 846for i, item in ipairs(items) do
858 for i, item in ipairs(items) do 847 _accum_0[_len_0] = item * 2
859 _accum_0[_len_0] = item * 2 848 _len_0 = _len_0 + 1
860 _len_0 = _len_0 + 1
861 end
862 doubled = _accum_0
863end 849end
850doubled = _accum_0
864local iter = ipairs(items) 851local iter = ipairs(items)
865local slice 852local slice
866do 853local _accum_0 = { }
867 local _accum_0 = { } 854local _len_0 = 1
868 local _len_0 = 1 855for i, item in iter do
869 for i, item in iter do 856 if i > 1 and i < 3 then
870 if i > 1 and i < 3 then 857 _accum_0[_len_0] = item
871 _accum_0[_len_0] = item 858 _len_0 = _len_0 + 1
872 _len_0 = _len_0 + 1
873 end
874 end 859 end
875 slice = _accum_0
876end 860end
861slice = _accum_0
877local doubled 862local doubled
878do 863local _accum_0 = { }
879 local _accum_0 = { } 864local _len_0 = 1
880 local _len_0 = 1 865local _list_0 = items
881 local _list_0 = items 866for _index_0 = 1, #_list_0 do
882 for _index_0 = 1, #_list_0 do 867 local item = _list_0[_index_0]
883 local item = _list_0[_index_0] 868 _accum_0[_len_0] = item * 2
884 _accum_0[_len_0] = item * 2 869 _len_0 = _len_0 + 1
885 _len_0 = _len_0 + 1
886 end
887 doubled = _accum_0
888end 870end
871doubled = _accum_0
889local x_coords = { 872local x_coords = {
890 4, 873 4,
891 5, 874 5,
@@ -898,57 +881,49 @@ local y_coords = {
898 3 881 3
899} 882}
900local points 883local points
901do 884local _accum_0 = { }
902 local _accum_0 = { } 885local _len_0 = 1
903 local _len_0 = 1 886for _index_0 = 1, #x_coords do
904 for _index_0 = 1, #x_coords do 887 local x = x_coords[_index_0]
905 local x = x_coords[_index_0] 888 for _index_1 = 1, #y_coords do
906 for _index_1 = 1, #y_coords do 889 local y = y_coords[_index_1]
907 local y = y_coords[_index_1] 890 _accum_0[_len_0] = {
908 _accum_0[_len_0] = { 891 x,
909 x, 892 y
910 y 893 }
911 } 894 _len_0 = _len_0 + 1
912 _len_0 = _len_0 + 1
913 end
914 end 895 end
915 points = _accum_0
916end 896end
897points = _accum_0
917local evens 898local evens
918do 899local _accum_0 = { }
919 local _accum_0 = { } 900local _len_0 = 1
920 local _len_0 = 1 901for i = 1, 100 do
921 for i = 1, 100 do 902 if i % 2 == 0 then
922 if i % 2 == 0 then 903 _accum_0[_len_0] = i
923 _accum_0[_len_0] = i 904 _len_0 = _len_0 + 1
924 _len_0 = _len_0 + 1
925 end
926 end 905 end
927 evens = _accum_0
928end 906end
907evens = _accum_0
929local thing = { 908local thing = {
930 color = "red", 909 color = "red",
931 name = "fast", 910 name = "fast",
932 width = 123 911 width = 123
933} 912}
934local thing_copy 913local thing_copy
935do 914local _tbl_0 = { }
936 local _tbl_0 = { } 915for k, v in pairs(thing) do
937 for k, v in pairs(thing) do 916 _tbl_0[k] = v
938 _tbl_0[k] = v
939 end
940 thing_copy = _tbl_0
941end 917end
918thing_copy = _tbl_0
942local no_color 919local no_color
943do 920local _tbl_0 = { }
944 local _tbl_0 = { } 921for k, v in pairs(thing) do
945 for k, v in pairs(thing) do 922 if k ~= "color" then
946 if k ~= "color" then 923 _tbl_0[k] = v
947 _tbl_0[k] = v
948 end
949 end 924 end
950 no_color = _tbl_0
951end 925end
926no_color = _tbl_0
952local numbers = { 927local numbers = {
953 1, 928 1,
954 2, 929 2,
@@ -956,14 +931,12 @@ local numbers = {
956 4 931 4
957} 932}
958local sqrts 933local sqrts
959do 934local _tbl_0 = { }
960 local _tbl_0 = { } 935for _index_0 = 1, #numbers do
961 for _index_0 = 1, #numbers do 936 local i = numbers[_index_0]
962 local i = numbers[_index_0] 937 _tbl_0[i] = math.sqrt(i)
963 _tbl_0[i] = math.sqrt(i)
964 end
965 sqrts = _tbl_0
966end 938end
939sqrts = _tbl_0
967local tuples = { 940local tuples = {
968 { 941 {
969 "hello", 942 "hello",
@@ -975,52 +948,44 @@ local tuples = {
975 } 948 }
976} 949}
977local tbl 950local tbl
978do 951local _tbl_0 = { }
979 local _tbl_0 = { } 952for _index_0 = 1, #tuples do
980 for _index_0 = 1, #tuples do 953 local tuple = tuples[_index_0]
981 local tuple = tuples[_index_0] 954 local _key_0, _val_0 = unpack(tuple)
982 local _key_0, _val_0 = unpack(tuple) 955 _tbl_0[_key_0] = _val_0
983 _tbl_0[_key_0] = _val_0
984 end
985 tbl = _tbl_0
986end 956end
957tbl = _tbl_0
987local slice 958local slice
988do 959local _accum_0 = { }
989 local _accum_0 = { } 960local _len_0 = 1
990 local _len_0 = 1 961local _list_0 = items
991 local _list_0 = items 962local _max_0 = 5
992 local _max_0 = 5 963for _index_0 = 1, _max_0 < 0 and #_list_0 + _max_0 or _max_0 do
993 for _index_0 = 1, _max_0 < 0 and #_list_0 + _max_0 or _max_0 do 964 local item = _list_0[_index_0]
994 local item = _list_0[_index_0] 965 _accum_0[_len_0] = item
995 _accum_0[_len_0] = item 966 _len_0 = _len_0 + 1
996 _len_0 = _len_0 + 1
997 end
998 slice = _accum_0
999end 967end
968slice = _accum_0
1000local slice 969local slice
1001do 970local _accum_0 = { }
1002 local _accum_0 = { } 971local _len_0 = 1
1003 local _len_0 = 1 972local _list_0 = items
1004 local _list_0 = items 973for _index_0 = 2, #_list_0 do
1005 for _index_0 = 2, #_list_0 do 974 local item = _list_0[_index_0]
1006 local item = _list_0[_index_0] 975 _accum_0[_len_0] = item
1007 _accum_0[_len_0] = item 976 _len_0 = _len_0 + 1
1008 _len_0 = _len_0 + 1
1009 end
1010 slice = _accum_0
1011end 977end
978slice = _accum_0
1012local slice 979local slice
1013do 980local _accum_0 = { }
1014 local _accum_0 = { } 981local _len_0 = 1
1015 local _len_0 = 1 982local _list_0 = items
1016 local _list_0 = items 983for _index_0 = 1, #_list_0, 2 do
1017 for _index_0 = 1, #_list_0, 2 do 984 local item = _list_0[_index_0]
1018 local item = _list_0[_index_0] 985 _accum_0[_len_0] = item
1019 _accum_0[_len_0] = item 986 _len_0 = _len_0 + 1
1020 _len_0 = _len_0 + 1
1021 end
1022 slice = _accum_0
1023end 987end
988slice = _accum_0
1024for i = 10, 20 do 989for i = 10, 20 do
1025 print(i) 990 print(i)
1026end 991end
@@ -1030,13 +995,11 @@ end
1030for key, value in pairs(object) do 995for key, value in pairs(object) do
1031 print(key, value) 996 print(key, value)
1032end 997end
1033do 998local _list_0 = items
1034 local _list_0 = items 999local _max_0 = 4
1035 local _max_0 = 4 1000for _index_0 = 2, _max_0 < 0 and #_list_0 + _max_0 or _max_0 do
1036 for _index_0 = 2, _max_0 < 0 and #_list_0 + _max_0 or _max_0 do 1001 local item = _list_0[_index_0]
1037 local item = _list_0[_index_0] 1002 print(item)
1038 print(item)
1039 end
1040end 1003end
1041local _list_0 = items 1004local _list_0 = items
1042for _index_0 = 1, #_list_0 do 1005for _index_0 = 1, #_list_0 do
@@ -1047,19 +1010,17 @@ for j = 1, 10, 3 do
1047 print(j) 1010 print(j)
1048end 1011end
1049local doubled_evens 1012local doubled_evens
1050do 1013local _accum_0 = { }
1051 local _accum_0 = { } 1014local _len_0 = 1
1052 local _len_0 = 1 1015for i = 1, 20 do
1053 for i = 1, 20 do 1016 if i % 2 == 0 then
1054 if i % 2 == 0 then 1017 _accum_0[_len_0] = i * 2
1055 _accum_0[_len_0] = i * 2 1018 else
1056 else 1019 _accum_0[_len_0] = i
1057 _accum_0[_len_0] = i
1058 end
1059 _len_0 = _len_0 + 1
1060 end 1020 end
1061 doubled_evens = _accum_0 1021 _len_0 = _len_0 + 1
1062end 1022end
1023doubled_evens = _accum_0
1063local func_a 1024local func_a
1064func_a = function() 1025func_a = function()
1065 for i = 1, 10 do 1026 for i = 1, 10 do
@@ -1117,20 +1078,18 @@ local my_numbers = {
1117 6 1078 6
1118} 1079}
1119local odds 1080local odds
1120do 1081local _accum_0 = { }
1121 local _accum_0 = { } 1082local _len_0 = 1
1122 local _len_0 = 1 1083for _index_0 = 1, #my_numbers do
1123 for _index_0 = 1, #my_numbers do 1084 local x = my_numbers[_index_0]
1124 local x = my_numbers[_index_0] 1085 if x % 2 == 1 then
1125 if x % 2 == 1 then 1086 goto _continue_0
1126 goto _continue_0
1127 end
1128 _accum_0[_len_0] = x
1129 _len_0 = _len_0 + 1
1130 ::_continue_0::
1131 end 1087 end
1132 odds = _accum_0 1088 _accum_0[_len_0] = x
1089 _len_0 = _len_0 + 1
1090 ::_continue_0::
1133end 1091end
1092odds = _accum_0
1134local have_coins = false 1093local have_coins = false
1135if have_coins then 1094if have_coins then
1136 print("有硬å¸") 1095 print("有硬å¸")
@@ -1222,15 +1181,13 @@ else
1222 next_number = error("数字数得太大了ï¼") 1181 next_number = error("数字数得太大了ï¼")
1223end 1182end
1224local msg 1183local msg
1225do 1184local _exp_0 = math.random(1, 5)
1226 local _exp_0 = math.random(1, 5) 1185if 1 == _exp_0 then
1227 if 1 == _exp_0 then 1186 msg = "你很幸è¿"
1228 msg = "你很幸è¿" 1187elseif 2 == _exp_0 then
1229 elseif 2 == _exp_0 then 1188 msg = "你差点很幸è¿"
1230 msg = "你差点很幸è¿" 1189else
1231 else 1190 msg = "ä¸å¤ªå¹¸è¿"
1232 msg = "ä¸å¤ªå¹¸è¿"
1233 end
1234end 1191end
1235do 1192do
1236 local _exp_0 = math.random(1, 5) 1193 local _exp_0 = math.random(1, 5)
@@ -1240,13 +1197,11 @@ do
1240 print("ä¸å¤ªå¹¸è¿") 1197 print("ä¸å¤ªå¹¸è¿")
1241 end 1198 end
1242end 1199end
1243do 1200local _exp_0 = math.random(1, 5)
1244 local _exp_0 = math.random(1, 5) 1201if 1 == _exp_0 then
1245 if 1 == _exp_0 then 1202 print("你很幸è¿")
1246 print("你很幸è¿") 1203else
1247 else 1204 print("ä¸å¤ªå¹¸è¿")
1248 print("ä¸å¤ªå¹¸è¿")
1249 end
1250end 1205end
1251local items = { 1206local items = {
1252 { 1207 {
@@ -1260,25 +1215,23 @@ local items = {
1260} 1215}
1261for _index_0 = 1, #items do 1216for _index_0 = 1, #items do
1262 local item = items[_index_0] 1217 local item = items[_index_0]
1263 do 1218 local _type_0 = type(item)
1264 local _type_0 = type(item) 1219 local _tab_0 = "table" == _type_0 or "userdata" == _type_0
1265 local _tab_0 = "table" == _type_0 or "userdata" == _type_0 1220 local _match_0 = false
1266 local _match_0 = false 1221 if _tab_0 then
1267 if _tab_0 then 1222 local x = item.x
1268 local x = item.x 1223 local y = item.y
1269 local y = item.y 1224 if x ~= nil and y ~= nil then
1270 if x ~= nil and y ~= nil then 1225 _match_0 = true
1271 _match_0 = true 1226 print("Vec2 " .. tostring(x) .. ", " .. tostring(y))
1272 print("Vec2 " .. tostring(x) .. ", " .. tostring(y))
1273 end
1274 end 1227 end
1275 if not _match_0 then 1228 end
1276 if _tab_0 then 1229 if not _match_0 then
1277 local width = item.width 1230 if _tab_0 then
1278 local height = item.height 1231 local width = item.width
1279 if width ~= nil and height ~= nil then 1232 local height = item.height
1280 print("尺寸 " .. tostring(width) .. ", " .. tostring(height)) 1233 if width ~= nil and height ~= nil then
1281 end 1234 print("尺寸 " .. tostring(width) .. ", " .. tostring(height))
1282 end 1235 end
1283 end 1236 end
1284 end 1237 end
@@ -1291,66 +1244,62 @@ end
1291if y == nil then 1244if y == nil then
1292 y = 200 1245 y = 200
1293end 1246end
1294do 1247local _type_0 = type(item)
1295 local _type_0 = type(item) 1248local _tab_0 = "table" == _type_0 or "userdata" == _type_0
1296 local _tab_0 = "table" == _type_0 or "userdata" == _type_0 1249if _tab_0 then
1297 if _tab_0 then 1250 do
1298 do 1251 local _obj_0 = item.pos
1299 local _obj_0 = item.pos 1252 local _type_1 = type(_obj_0)
1300 local _type_1 = type(_obj_0) 1253 if "table" == _type_1 or "userdata" == _type_1 then
1301 if "table" == _type_1 or "userdata" == _type_1 then 1254 x = _obj_0.x
1302 x = _obj_0.x
1303 end
1304 end
1305 do
1306 local _obj_0 = item.pos
1307 local _type_1 = type(_obj_0)
1308 if "table" == _type_1 or "userdata" == _type_1 then
1309 y = _obj_0.y
1310 end
1311 end
1312 if x == nil then
1313 x = 50
1314 end 1255 end
1315 if y == nil then 1256 end
1316 y = 200 1257 do
1258 local _obj_0 = item.pos
1259 local _type_1 = type(_obj_0)
1260 if "table" == _type_1 or "userdata" == _type_1 then
1261 y = _obj_0.y
1317 end 1262 end
1318 print("Vec2 " .. tostring(x) .. ", " .. tostring(y))
1319 end 1263 end
1264 if x == nil then
1265 x = 50
1266 end
1267 if y == nil then
1268 y = 200
1269 end
1270 print("Vec2 " .. tostring(x) .. ", " .. tostring(y))
1320end 1271end
1321local Inventory 1272local Inventory
1322do 1273local _class_0
1323 local _class_0 1274local _base_0 = {
1324 local _base_0 = { 1275 add_item = function(self, name)
1325 add_item = function(self, name) 1276 if self.items[name] then
1326 if self.items[name] then 1277 local _obj_0 = self.items
1327 local _obj_0 = self.items 1278 _obj_0[name] = _obj_0[name] + 1
1328 _obj_0[name] = _obj_0[name] + 1 1279 else
1329 else 1280 self.items[name] = 1
1330 self.items[name] = 1
1331 end
1332 end 1281 end
1333 }
1334 if _base_0.__index == nil then
1335 _base_0.__index = _base_0
1336 end 1282 end
1337 _class_0 = setmetatable({ 1283}
1338 __init = function(self) 1284if _base_0.__index == nil then
1339 self.items = { } 1285 _base_0.__index = _base_0
1340 end,
1341 __base = _base_0,
1342 __name = "Inventory"
1343 }, {
1344 __index = _base_0,
1345 __call = function(cls, ...)
1346 local _self_0 = setmetatable({ }, _base_0)
1347 cls.__init(_self_0, ...)
1348 return _self_0
1349 end
1350 })
1351 _base_0.__class = _class_0
1352 Inventory = _class_0
1353end 1286end
1287_class_0 = setmetatable({
1288 __init = function(self)
1289 self.items = { }
1290 end,
1291 __base = _base_0,
1292 __name = "Inventory"
1293}, {
1294 __index = _base_0,
1295 __call = function(cls, ...)
1296 local _self_0 = setmetatable({ }, _base_0)
1297 cls.__init(_self_0, ...)
1298 return _self_0
1299 end
1300})
1301_base_0.__class = _class_0
1302Inventory = _class_0
1354local inv = Inventory() 1303local inv = Inventory()
1355inv:add_item("t-shirt") 1304inv:add_item("t-shirt")
1356inv:add_item("pants") 1305inv:add_item("pants")
@@ -1391,82 +1340,78 @@ for _index_0 = 1, #_list_0 do
1391 print(item) 1340 print(item)
1392end 1341end
1393local Person 1342local Person
1394do 1343local _class_0
1395 local _class_0 1344local _base_0 = { }
1396 local _base_0 = { } 1345if _base_0.__index == nil then
1397 if _base_0.__index == nil then 1346 _base_0.__index = _base_0
1398 _base_0.__index = _base_0 1347end
1348_class_0 = setmetatable({
1349 __init = function(self)
1350 self.clothes = { }
1351 end,
1352 __base = _base_0,
1353 __name = "Person"
1354}, {
1355 __index = _base_0,
1356 __call = function(cls, ...)
1357 local _self_0 = setmetatable({ }, _base_0)
1358 cls.__init(_self_0, ...)
1359 return _self_0
1399 end 1360 end
1400 _class_0 = setmetatable({ 1361})
1401 __init = function(self) 1362_base_0.__class = _class_0
1402 self.clothes = { } 1363Person = _class_0
1403 end,
1404 __base = _base_0,
1405 __name = "Person"
1406 }, {
1407 __index = _base_0,
1408 __call = function(cls, ...)
1409 local _self_0 = setmetatable({ }, _base_0)
1410 cls.__init(_self_0, ...)
1411 return _self_0
1412 end
1413 })
1414 _base_0.__class = _class_0
1415 Person = _class_0
1416end
1417local BackPack 1364local BackPack
1418do 1365local _class_0
1419 local _class_0 1366local _parent_0 = Inventory
1420 local _parent_0 = Inventory 1367local _base_0 = {
1421 local _base_0 = { 1368 size = 10,
1422 size = 10, 1369 add_item = function(self, name)
1423 add_item = function(self, name) 1370 if #self.items > size then
1424 if #self.items > size then 1371 error("背包已满")
1425 error("背包已满")
1426 end
1427 return _class_0.__parent.__base.add_item(self, name)
1428 end
1429 }
1430 for _key_0, _val_0 in pairs(_parent_0.__base) do
1431 if _base_0[_key_0] == nil and _key_0:match("^__") and not (_key_0 == "__index" and _val_0 == _parent_0.__base) then
1432 _base_0[_key_0] = _val_0
1433 end 1372 end
1373 return _class_0.__parent.__base.add_item(self, name)
1434 end 1374 end
1435 if _base_0.__index == nil then 1375}
1436 _base_0.__index = _base_0 1376for _key_0, _val_0 in pairs(_parent_0.__base) do
1377 if _base_0[_key_0] == nil and _key_0:match("^__") and not (_key_0 == "__index" and _val_0 == _parent_0.__base) then
1378 _base_0[_key_0] = _val_0
1437 end 1379 end
1438 setmetatable(_base_0, _parent_0.__base) 1380end
1439 _class_0 = setmetatable({ 1381if _base_0.__index == nil then
1440 __init = function(self, ...) 1382 _base_0.__index = _base_0
1441 return _class_0.__parent.__init(self, ...) 1383end
1442 end, 1384setmetatable(_base_0, _parent_0.__base)
1443 __base = _base_0, 1385_class_0 = setmetatable({
1444 __name = "BackPack", 1386 __init = function(self, ...)
1445 __parent = _parent_0 1387 return _class_0.__parent.__init(self, ...)
1446 }, { 1388 end,
1447 __index = function(cls, name) 1389 __base = _base_0,
1448 local val = rawget(_base_0, name) 1390 __name = "BackPack",
1449 if val == nil then 1391 __parent = _parent_0
1450 local parent = rawget(cls, "__parent") 1392}, {
1451 if parent then 1393 __index = function(cls, name)
1452 return parent[name] 1394 local val = rawget(_base_0, name)
1453 end 1395 if val == nil then
1454 else 1396 local parent = rawget(cls, "__parent")
1455 return val 1397 if parent then
1398 return parent[name]
1456 end 1399 end
1457 end, 1400 else
1458 __call = function(cls, ...) 1401 return val
1459 local _self_0 = setmetatable({ }, _base_0)
1460 cls.__init(_self_0, ...)
1461 return _self_0
1462 end 1402 end
1463 }) 1403 end,
1464 _base_0.__class = _class_0 1404 __call = function(cls, ...)
1465 if _parent_0.__inherited then 1405 local _self_0 = setmetatable({ }, _base_0)
1466 _parent_0.__inherited(_parent_0, _class_0) 1406 cls.__init(_self_0, ...)
1407 return _self_0
1467 end 1408 end
1468 BackPack = _class_0 1409})
1410_base_0.__class = _class_0
1411if _parent_0.__inherited then
1412 _parent_0.__inherited(_parent_0, _class_0)
1469end 1413end
1414BackPack = _class_0
1470local Shelf 1415local Shelf
1471do 1416do
1472 local _class_0 1417 local _class_0
@@ -1494,102 +1439,98 @@ do
1494 Shelf = _class_0 1439 Shelf = _class_0
1495end 1440end
1496local Cupboard 1441local Cupboard
1497do 1442local _class_0
1498 local _class_0 1443local _parent_0 = Shelf
1499 local _parent_0 = Shelf 1444local _base_0 = { }
1500 local _base_0 = { } 1445for _key_0, _val_0 in pairs(_parent_0.__base) do
1501 for _key_0, _val_0 in pairs(_parent_0.__base) do 1446 if _base_0[_key_0] == nil and _key_0:match("^__") and not (_key_0 == "__index" and _val_0 == _parent_0.__base) then
1502 if _base_0[_key_0] == nil and _key_0:match("^__") and not (_key_0 == "__index" and _val_0 == _parent_0.__base) then 1447 _base_0[_key_0] = _val_0
1503 _base_0[_key_0] = _val_0 1448 end
1504 end 1449end
1505 end 1450if _base_0.__index == nil then
1506 if _base_0.__index == nil then 1451 _base_0.__index = _base_0
1507 _base_0.__index = _base_0 1452end
1508 end 1453setmetatable(_base_0, _parent_0.__base)
1509 setmetatable(_base_0, _parent_0.__base) 1454_class_0 = setmetatable({
1510 _class_0 = setmetatable({ 1455 __init = function(self, ...)
1511 __init = function(self, ...) 1456 return _class_0.__parent.__init(self, ...)
1512 return _class_0.__parent.__init(self, ...) 1457 end,
1513 end, 1458 __base = _base_0,
1514 __base = _base_0, 1459 __name = "Cupboard",
1515 __name = "Cupboard", 1460 __parent = _parent_0
1516 __parent = _parent_0 1461}, {
1517 }, { 1462 __index = function(cls, name)
1518 __index = function(cls, name) 1463 local val = rawget(_base_0, name)
1519 local val = rawget(_base_0, name) 1464 if val == nil then
1520 if val == nil then 1465 local parent = rawget(cls, "__parent")
1521 local parent = rawget(cls, "__parent") 1466 if parent then
1522 if parent then 1467 return parent[name]
1523 return parent[name]
1524 end
1525 else
1526 return val
1527 end 1468 end
1528 end, 1469 else
1529 __call = function(cls, ...) 1470 return val
1530 local _self_0 = setmetatable({ }, _base_0)
1531 cls.__init(_self_0, ...)
1532 return _self_0
1533 end 1471 end
1534 }) 1472 end,
1535 _base_0.__class = _class_0 1473 __call = function(cls, ...)
1536 if _parent_0.__inherited then 1474 local _self_0 = setmetatable({ }, _base_0)
1537 _parent_0.__inherited(_parent_0, _class_0) 1475 cls.__init(_self_0, ...)
1476 return _self_0
1538 end 1477 end
1539 Cupboard = _class_0 1478})
1479_base_0.__class = _class_0
1480if _parent_0.__inherited then
1481 _parent_0.__inherited(_parent_0, _class_0)
1540end 1482end
1483Cupboard = _class_0
1541local MyClass 1484local MyClass
1542do 1485local _class_0
1543 local _class_0 1486local _parent_0 = ParentClass
1544 local _parent_0 = ParentClass 1487local _base_0 = {
1545 local _base_0 = { 1488 a_method = function(self)
1546 a_method = function(self) 1489 _class_0.__parent.__base.a_method(self, "你好", "世界")
1547 _class_0.__parent.__base.a_method(self, "你好", "世界") 1490 _class_0.__parent.a_method(self, "你好", "世界")
1548 _class_0.__parent.a_method(self, "你好", "世界") 1491 _class_0.__parent.a_method(self, "你好", "世界")
1549 _class_0.__parent.a_method(self, "你好", "世界") 1492 return assert(_class_0.__parent == ParentClass)
1550 return assert(_class_0.__parent == ParentClass) 1493 end
1551 end 1494}
1552 } 1495for _key_0, _val_0 in pairs(_parent_0.__base) do
1553 for _key_0, _val_0 in pairs(_parent_0.__base) do 1496 if _base_0[_key_0] == nil and _key_0:match("^__") and not (_key_0 == "__index" and _val_0 == _parent_0.__base) then
1554 if _base_0[_key_0] == nil and _key_0:match("^__") and not (_key_0 == "__index" and _val_0 == _parent_0.__base) then 1497 _base_0[_key_0] = _val_0
1555 _base_0[_key_0] = _val_0 1498 end
1556 end 1499end
1557 end 1500if _base_0.__index == nil then
1558 if _base_0.__index == nil then 1501 _base_0.__index = _base_0
1559 _base_0.__index = _base_0 1502end
1560 end 1503setmetatable(_base_0, _parent_0.__base)
1561 setmetatable(_base_0, _parent_0.__base) 1504_class_0 = setmetatable({
1562 _class_0 = setmetatable({ 1505 __init = function(self, ...)
1563 __init = function(self, ...) 1506 return _class_0.__parent.__init(self, ...)
1564 return _class_0.__parent.__init(self, ...) 1507 end,
1565 end, 1508 __base = _base_0,
1566 __base = _base_0, 1509 __name = "MyClass",
1567 __name = "MyClass", 1510 __parent = _parent_0
1568 __parent = _parent_0 1511}, {
1569 }, { 1512 __index = function(cls, name)
1570 __index = function(cls, name) 1513 local val = rawget(_base_0, name)
1571 local val = rawget(_base_0, name) 1514 if val == nil then
1572 if val == nil then 1515 local parent = rawget(cls, "__parent")
1573 local parent = rawget(cls, "__parent") 1516 if parent then
1574 if parent then 1517 return parent[name]
1575 return parent[name]
1576 end
1577 else
1578 return val
1579 end 1518 end
1580 end, 1519 else
1581 __call = function(cls, ...) 1520 return val
1582 local _self_0 = setmetatable({ }, _base_0)
1583 cls.__init(_self_0, ...)
1584 return _self_0
1585 end 1521 end
1586 }) 1522 end,
1587 _base_0.__class = _class_0 1523 __call = function(cls, ...)
1588 if _parent_0.__inherited then 1524 local _self_0 = setmetatable({ }, _base_0)
1589 _parent_0.__inherited(_parent_0, _class_0) 1525 cls.__init(_self_0, ...)
1526 return _self_0
1590 end 1527 end
1591 MyClass = _class_0 1528})
1529_base_0.__class = _class_0
1530if _parent_0.__inherited then
1531 _parent_0.__inherited(_parent_0, _class_0)
1592end 1532end
1533MyClass = _class_0
1593local b = BackPack() 1534local b = BackPack()
1594assert(b.__class == BackPack) 1535assert(b.__class == BackPack)
1595print(BackPack.size) 1536print(BackPack.size)
@@ -1653,61 +1594,57 @@ Counter()
1653print(Counter.count) 1594print(Counter.count)
1654self.__class:hello(1, 2, 3, 4) 1595self.__class:hello(1, 2, 3, 4)
1655local Things 1596local Things
1656do 1597local _class_0
1657 local _class_0 1598local _base_0 = { }
1658 local _base_0 = { } 1599if _base_0.__index == nil then
1659 if _base_0.__index == nil then 1600 _base_0.__index = _base_0
1660 _base_0.__index = _base_0 1601end
1602_class_0 = setmetatable({
1603 __init = function() end,
1604 __base = _base_0,
1605 __name = "Things"
1606}, {
1607 __index = _base_0,
1608 __call = function(cls, ...)
1609 local _self_0 = setmetatable({ }, _base_0)
1610 cls.__init(_self_0, ...)
1611 return _self_0
1661 end 1612 end
1662 _class_0 = setmetatable({ 1613})
1663 __init = function() end, 1614_base_0.__class = _class_0
1664 __base = _base_0, 1615local self = _class_0;
1665 __name = "Things" 1616self.class_var = "hello world"
1666 }, { 1617Things = _class_0
1667 __index = _base_0,
1668 __call = function(cls, ...)
1669 local _self_0 = setmetatable({ }, _base_0)
1670 cls.__init(_self_0, ...)
1671 return _self_0
1672 end
1673 })
1674 _base_0.__class = _class_0
1675 local self = _class_0;
1676 self.class_var = "hello world"
1677 Things = _class_0
1678end
1679local MoreThings 1618local MoreThings
1680do 1619local _class_0
1681 local _class_0 1620local secret, log
1682 local secret, log 1621local _base_0 = {
1683 local _base_0 = { 1622 some_method = function(self)
1684 some_method = function(self) 1623 return log("hello world: " .. secret)
1685 return log("hello world: " .. secret)
1686 end
1687 }
1688 if _base_0.__index == nil then
1689 _base_0.__index = _base_0
1690 end 1624 end
1691 _class_0 = setmetatable({ 1625}
1692 __init = function() end, 1626if _base_0.__index == nil then
1693 __base = _base_0, 1627 _base_0.__index = _base_0
1694 __name = "MoreThings" 1628end
1695 }, { 1629_class_0 = setmetatable({
1696 __index = _base_0, 1630 __init = function() end,
1697 __call = function(cls, ...) 1631 __base = _base_0,
1698 local _self_0 = setmetatable({ }, _base_0) 1632 __name = "MoreThings"
1699 cls.__init(_self_0, ...) 1633}, {
1700 return _self_0 1634 __index = _base_0,
1701 end 1635 __call = function(cls, ...)
1702 }) 1636 local _self_0 = setmetatable({ }, _base_0)
1703 _base_0.__class = _class_0 1637 cls.__init(_self_0, ...)
1704 local self = _class_0; 1638 return _self_0
1705 secret = 123
1706 log = function(msg)
1707 return print("LOG:", msg)
1708 end 1639 end
1709 MoreThings = _class_0 1640})
1641_base_0.__class = _class_0
1642local self = _class_0;
1643secret = 123
1644log = function(msg)
1645 return print("LOG:", msg)
1710end 1646end
1647MoreThings = _class_0
1711assert(self == self) 1648assert(self == self)
1712assert(self.__class == self.__class) 1649assert(self.__class == self.__class)
1713local some_instance_method 1650local some_instance_method
@@ -1741,32 +1678,30 @@ do
1741 _base_0.__class = _class_0 1678 _base_0.__class = _class_0
1742 Something = _class_0 1679 Something = _class_0
1743end 1680end
1744do 1681local _class_0
1745 local _class_0 1682local _base_0 = { }
1746 local _base_0 = { } 1683if _base_0.__index == nil then
1747 if _base_0.__index == nil then 1684 _base_0.__index = _base_0
1748 _base_0.__index = _base_0 1685end
1686_class_0 = setmetatable({
1687 __init = function(self, foo, bar, biz, baz)
1688 self.foo = foo
1689 self.bar = bar
1690 self.__class.biz = biz
1691 self.__class.baz = baz
1692 end,
1693 __base = _base_0,
1694 __name = "Something"
1695}, {
1696 __index = _base_0,
1697 __call = function(cls, ...)
1698 local _self_0 = setmetatable({ }, _base_0)
1699 cls.__init(_self_0, ...)
1700 return _self_0
1749 end 1701 end
1750 _class_0 = setmetatable({ 1702})
1751 __init = function(self, foo, bar, biz, baz) 1703_base_0.__class = _class_0
1752 self.foo = foo 1704Something = _class_0
1753 self.bar = bar
1754 self.__class.biz = biz
1755 self.__class.baz = baz
1756 end,
1757 __base = _base_0,
1758 __name = "Something"
1759 }, {
1760 __index = _base_0,
1761 __call = function(cls, ...)
1762 local _self_0 = setmetatable({ }, _base_0)
1763 cls.__init(_self_0, ...)
1764 return _self_0
1765 end
1766 })
1767 _base_0.__class = _class_0
1768 Something = _class_0
1769end
1770local new 1705local new
1771new = function(self, fieldA, fieldB) 1706new = function(self, fieldA, fieldB)
1772 self.fieldA = fieldA 1707 self.fieldA = fieldA
@@ -1777,33 +1712,31 @@ local obj = new({ }, 123, "abc")
1777print(obj) 1712print(obj)
1778local x 1713local x
1779local Bucket 1714local Bucket
1780do 1715local _class_0
1781 local _class_0 1716local _base_0 = {
1782 local _base_0 = { 1717 drops = 0,
1783 drops = 0, 1718 add_drop = function(self)
1784 add_drop = function(self) 1719 self.drops = self.drops + 1
1785 self.drops = self.drops + 1
1786 end
1787 }
1788 if _base_0.__index == nil then
1789 _base_0.__index = _base_0
1790 end 1720 end
1791 _class_0 = setmetatable({ 1721}
1792 __init = function() end, 1722if _base_0.__index == nil then
1793 __base = _base_0, 1723 _base_0.__index = _base_0
1794 __name = "Bucket"
1795 }, {
1796 __index = _base_0,
1797 __call = function(cls, ...)
1798 local _self_0 = setmetatable({ }, _base_0)
1799 cls.__init(_self_0, ...)
1800 return _self_0
1801 end
1802 })
1803 _base_0.__class = _class_0
1804 Bucket = _class_0
1805 x = _class_0
1806end 1724end
1725_class_0 = setmetatable({
1726 __init = function() end,
1727 __base = _base_0,
1728 __name = "Bucket"
1729}, {
1730 __index = _base_0,
1731 __call = function(cls, ...)
1732 local _self_0 = setmetatable({ }, _base_0)
1733 cls.__init(_self_0, ...)
1734 return _self_0
1735 end
1736})
1737_base_0.__class = _class_0
1738Bucket = _class_0
1739x = _class_0
1807local BigBucket 1740local BigBucket
1808do 1741do
1809 local _class_0 1742 local _class_0
@@ -1855,27 +1788,25 @@ do
1855end 1788end
1856assert(Bucket.__name == "BigBucket") 1789assert(Bucket.__name == "BigBucket")
1857local x 1790local x
1858do 1791local _class_0
1859 local _class_0 1792local _base_0 = { }
1860 local _base_0 = { } 1793if _base_0.__index == nil then
1861 if _base_0.__index == nil then 1794 _base_0.__index = _base_0
1862 _base_0.__index = _base_0 1795end
1796_class_0 = setmetatable({
1797 __init = function() end,
1798 __base = _base_0,
1799 __name = "x"
1800}, {
1801 __index = _base_0,
1802 __call = function(cls, ...)
1803 local _self_0 = setmetatable({ }, _base_0)
1804 cls.__init(_self_0, ...)
1805 return _self_0
1863 end 1806 end
1864 _class_0 = setmetatable({ 1807})
1865 __init = function() end, 1808_base_0.__class = _class_0
1866 __base = _base_0, 1809x = _class_0
1867 __name = "x"
1868 }, {
1869 __index = _base_0,
1870 __call = function(cls, ...)
1871 local _self_0 = setmetatable({ }, _base_0)
1872 cls.__init(_self_0, ...)
1873 return _self_0
1874 end
1875 })
1876 _base_0.__class = _class_0
1877 x = _class_0
1878end
1879local MyIndex = { 1810local MyIndex = {
1880 __index = { 1811 __index = {
1881 var = 1 1812 var = 1
@@ -1958,19 +1889,15 @@ end
1958local y = Y() 1889local y = Y()
1959y:func() 1890y:func()
1960assert(y.__class.__parent ~= X) 1891assert(y.__class.__parent ~= X)
1961do 1892local _with_0 = Person()
1962 local _with_0 = Person() 1893_with_0.name = "Oswald"
1963 _with_0.name = "Oswald" 1894_with_0:add_relative(my_dad)
1964 _with_0:add_relative(my_dad) 1895_with_0:save()
1965 _with_0:save() 1896print(_with_0.name)
1966 print(_with_0.name)
1967end
1968local file 1897local file
1969do 1898local _with_0 = File("favorite_foods.txt")
1970 local _with_0 = File("favorite_foods.txt") 1899_with_0:set_encoding("utf8")
1971 _with_0:set_encoding("utf8") 1900file = _with_0
1972 file = _with_0
1973end
1974local create_person 1901local create_person
1975create_person = function(name, relatives) 1902create_person = function(name, relatives)
1976 local _with_0 = Person() 1903 local _with_0 = Person()
@@ -1986,22 +1913,18 @@ local me = create_person("Leaf", {
1986 mother, 1913 mother,
1987 sister 1914 sister
1988}) 1915})
1916local str = "你好"
1917print("原始:", str)
1918print("大写:", str:upper())
1919local _with_0 = tb
1920_with_0[1] = 1
1921print(_with_0[2])
1989do 1922do
1990 local str = "你好" 1923 local _with_1 = _with_0[abc]
1991 print("原始:", str) 1924 _with_1[3] = _with_1[2]:func()
1992 print("大写:", str:upper()) 1925 _with_1["key-name"] = value
1993end
1994do
1995 local _with_0 = tb
1996 _with_0[1] = 1
1997 print(_with_0[2])
1998 do
1999 local _with_1 = _with_0[abc]
2000 _with_1[3] = _with_1[2]:func()
2001 _with_1["key-name"] = value
2002 end
2003 _with_0[#_with_0 + 1] = "abc"
2004end 1926end
1927_with_0[#_with_0 + 1] = "abc"
2005do 1928do
2006 local var = "hello" 1929 local var = "hello"
2007 print(var) 1930 print(var)
@@ -2118,13 +2041,18 @@ _module_0["🌛"] = _ud83c_udf1b
2118return _module_0 2041return _module_0
2119local area = 6.2831853071796 * 5 2042local area = 6.2831853071796 * 5
2120print('你好 世界') 2043print('你好 世界')
2121assert(item ~= nil) 2044do
2045 assert(item ~= nil)
2046end
2122local value = item 2047local value = item
2123if (f1() and f2() and f3()) then 2048if (f1() and f2() and f3()) then
2124 print("OK") 2049 print("OK")
2125end 2050end
2051do
2052 local funcA
2053 funcA = function() end
2054end
2126local funcA 2055local funcA
2127funcA = function() end
2128funcA = function() 2056funcA = function()
2129 return "访问月之脚本定义的å˜é‡" 2057 return "访问月之脚本定义的å˜é‡"
2130end 2058end
@@ -2218,28 +2146,26 @@ local b = {
2218 y = 1 2146 y = 1
2219} 2147}
2220local merge 2148local merge
2221do 2149local _tab_0 = { }
2222 local _tab_0 = { } 2150local _idx_0 = 1
2223 local _idx_0 = 1 2151for _key_0, _value_0 in pairs(a) do
2224 for _key_0, _value_0 in pairs(a) do 2152 if _idx_0 == _key_0 then
2225 if _idx_0 == _key_0 then 2153 _tab_0[#_tab_0 + 1] = _value_0
2226 _tab_0[#_tab_0 + 1] = _value_0 2154 _idx_0 = _idx_0 + 1
2227 _idx_0 = _idx_0 + 1 2155 else
2228 else 2156 _tab_0[_key_0] = _value_0
2229 _tab_0[_key_0] = _value_0
2230 end
2231 end 2157 end
2232 local _idx_1 = 1 2158end
2233 for _key_0, _value_0 in pairs(b) do 2159local _idx_1 = 1
2234 if _idx_1 == _key_0 then 2160for _key_0, _value_0 in pairs(b) do
2235 _tab_0[#_tab_0 + 1] = _value_0 2161 if _idx_1 == _key_0 then
2236 _idx_1 = _idx_1 + 1 2162 _tab_0[#_tab_0 + 1] = _value_0
2237 else 2163 _idx_1 = _idx_1 + 1
2238 _tab_0[_key_0] = _value_0 2164 else
2239 end 2165 _tab_0[_key_0] = _value_0
2240 end 2166 end
2241 merge = _tab_0
2242end 2167end
2168merge = _tab_0
2243local mt = { } 2169local mt = { }
2244local add 2170local add
2245add = function(self, right) 2171add = function(self, right)
@@ -2331,12 +2257,10 @@ end
2331if print and (x ~= nil) then 2257if print and (x ~= nil) then
2332 print(x) 2258 print(x)
2333end 2259end
2334do 2260local _with_0 = io.open("test.txt", "w")
2335 local _with_0 = io.open("test.txt", "w") 2261if _with_0 ~= nil then
2336 if _with_0 ~= nil then 2262 _with_0:write("你好")
2337 _with_0:write("你好") 2263 _with_0:close()
2338 _with_0:close()
2339 end
2340end 2264end
2341print("你好") 2265print("你好")
2342print(1, 2) 2266print(1, 2)
@@ -2413,10 +2337,8 @@ do
2413 x, y, z = _obj_0.x, _obj_0.y, _obj_0.z 2337 x, y, z = _obj_0.x, _obj_0.y, _obj_0.z
2414 end 2338 end
2415 local a, b, c 2339 local a, b, c
2416 do 2340 local _obj_0 = require('module')
2417 local _obj_0 = require('module') 2341 a, b, c = _obj_0.a, _obj_0.b, _obj_0.c
2418 a, b, c = _obj_0.a, _obj_0.b, _obj_0.c
2419 end
2420end 2342end
2421do 2343do
2422 local module = require('module') 2344 local module = require('module')
@@ -2455,29 +2377,27 @@ y = function()
2455end 2377end
2456_module_0["y"] = y 2378_module_0["y"] = y
2457local Something 2379local Something
2458do 2380local _class_0
2459 local _class_0 2381local _base_0 = {
2460 local _base_0 = { 2382 umm = "cool"
2461 umm = "cool" 2383}
2462 } 2384if _base_0.__index == nil then
2463 if _base_0.__index == nil then 2385 _base_0.__index = _base_0
2464 _base_0.__index = _base_0
2465 end
2466 _class_0 = setmetatable({
2467 __init = function() end,
2468 __base = _base_0,
2469 __name = "Something"
2470 }, {
2471 __index = _base_0,
2472 __call = function(cls, ...)
2473 local _self_0 = setmetatable({ }, _base_0)
2474 cls.__init(_self_0, ...)
2475 return _self_0
2476 end
2477 })
2478 _base_0.__class = _class_0
2479 Something = _class_0
2480end 2386end
2387_class_0 = setmetatable({
2388 __init = function() end,
2389 __base = _base_0,
2390 __name = "Something"
2391}, {
2392 __index = _base_0,
2393 __call = function(cls, ...)
2394 local _self_0 = setmetatable({ }, _base_0)
2395 cls.__init(_self_0, ...)
2396 return _self_0
2397 end
2398})
2399_base_0.__class = _class_0
2400Something = _class_0
2481_module_0["Something"] = Something 2401_module_0["Something"] = Something
2482return _module_0 2402return _module_0
2483local _module_0 = { } 2403local _module_0 = { }
@@ -2508,11 +2428,9 @@ if this then
2508else 2428else
2509 _module_0[#_module_0 + 1] = 456 2429 _module_0[#_module_0 + 1] = 456
2510end 2430end
2511do 2431local _with_0 = tmp
2512 local _with_0 = tmp 2432local j = 2000
2513 local j = 2000 2433_module_0[#_module_0 + 1] = _with_0
2514 _module_0[#_module_0 + 1] = _with_0
2515end
2516return _module_0 2434return _module_0
2517local _module_0 = nil 2435local _module_0 = nil
2518_module_0 = function() 2436_module_0 = function()
@@ -2649,25 +2567,19 @@ for _index_0 = 1, #tuples do
2649 local left, right = _des_0[1], _des_0[2] 2567 local left, right = _des_0[1], _des_0[2]
2650 print(left, right) 2568 print(left, right)
2651end 2569end
2652do 2570local user = database.find_user("moon")
2653 local user = database.find_user("moon") 2571if user then
2654 if user then 2572 print(user.name)
2655 print(user.name)
2656 end
2657end 2573end
2658do 2574local hello = os.getenv("hello")
2659 local hello = os.getenv("hello") 2575if hello then
2660 if hello then 2576 print("你有 hello", hello)
2661 print("你有 hello", hello) 2577else
2578 local world = os.getenv("world")
2579 if world then
2580 print("你有 world", world)
2662 else 2581 else
2663 do 2582 print("什么都没有 :(")
2664 local world = os.getenv("world")
2665 if world then
2666 print("你有 world", world)
2667 else
2668 print("什么都没有 :(")
2669 end
2670 end
2671 end 2583 end
2672end 2584end
2673do 2585do
@@ -2924,40 +2836,34 @@ local items = {
2924 4 2836 4
2925} 2837}
2926local doubled 2838local doubled
2927do 2839local _accum_0 = { }
2928 local _accum_0 = { } 2840local _len_0 = 1
2929 local _len_0 = 1 2841for i, item in ipairs(items) do
2930 for i, item in ipairs(items) do 2842 _accum_0[_len_0] = item * 2
2931 _accum_0[_len_0] = item * 2 2843 _len_0 = _len_0 + 1
2932 _len_0 = _len_0 + 1
2933 end
2934 doubled = _accum_0
2935end 2844end
2845doubled = _accum_0
2936local iter = ipairs(items) 2846local iter = ipairs(items)
2937local slice 2847local slice
2938do 2848local _accum_0 = { }
2939 local _accum_0 = { } 2849local _len_0 = 1
2940 local _len_0 = 1 2850for i, item in iter do
2941 for i, item in iter do 2851 if i > 1 and i < 3 then
2942 if i > 1 and i < 3 then 2852 _accum_0[_len_0] = item
2943 _accum_0[_len_0] = item 2853 _len_0 = _len_0 + 1
2944 _len_0 = _len_0 + 1
2945 end
2946 end 2854 end
2947 slice = _accum_0
2948end 2855end
2856slice = _accum_0
2949local doubled 2857local doubled
2950do 2858local _accum_0 = { }
2951 local _accum_0 = { } 2859local _len_0 = 1
2952 local _len_0 = 1 2860local _list_0 = items
2953 local _list_0 = items 2861for _index_0 = 1, #_list_0 do
2954 for _index_0 = 1, #_list_0 do 2862 local item = _list_0[_index_0]
2955 local item = _list_0[_index_0] 2863 _accum_0[_len_0] = item * 2
2956 _accum_0[_len_0] = item * 2 2864 _len_0 = _len_0 + 1
2957 _len_0 = _len_0 + 1
2958 end
2959 doubled = _accum_0
2960end 2865end
2866doubled = _accum_0
2961local x_coords = { 2867local x_coords = {
2962 4, 2868 4,
2963 5, 2869 5,
@@ -2970,57 +2876,49 @@ local y_coords = {
2970 3 2876 3
2971} 2877}
2972local points 2878local points
2973do 2879local _accum_0 = { }
2974 local _accum_0 = { } 2880local _len_0 = 1
2975 local _len_0 = 1 2881for _index_0 = 1, #x_coords do
2976 for _index_0 = 1, #x_coords do 2882 local x = x_coords[_index_0]
2977 local x = x_coords[_index_0] 2883 for _index_1 = 1, #y_coords do
2978 for _index_1 = 1, #y_coords do 2884 local y = y_coords[_index_1]
2979 local y = y_coords[_index_1] 2885 _accum_0[_len_0] = {
2980 _accum_0[_len_0] = { 2886 x,
2981 x, 2887 y
2982 y 2888 }
2983 } 2889 _len_0 = _len_0 + 1
2984 _len_0 = _len_0 + 1
2985 end
2986 end 2890 end
2987 points = _accum_0
2988end 2891end
2892points = _accum_0
2989local evens 2893local evens
2990do 2894local _accum_0 = { }
2991 local _accum_0 = { } 2895local _len_0 = 1
2992 local _len_0 = 1 2896for i = 1, 100 do
2993 for i = 1, 100 do 2897 if i % 2 == 0 then
2994 if i % 2 == 0 then 2898 _accum_0[_len_0] = i
2995 _accum_0[_len_0] = i 2899 _len_0 = _len_0 + 1
2996 _len_0 = _len_0 + 1
2997 end
2998 end 2900 end
2999 evens = _accum_0
3000end 2901end
2902evens = _accum_0
3001local thing = { 2903local thing = {
3002 color = "red", 2904 color = "red",
3003 name = "fast", 2905 name = "fast",
3004 width = 123 2906 width = 123
3005} 2907}
3006local thing_copy 2908local thing_copy
3007do 2909local _tbl_0 = { }
3008 local _tbl_0 = { } 2910for k, v in pairs(thing) do
3009 for k, v in pairs(thing) do 2911 _tbl_0[k] = v
3010 _tbl_0[k] = v
3011 end
3012 thing_copy = _tbl_0
3013end 2912end
2913thing_copy = _tbl_0
3014local no_color 2914local no_color
3015do 2915local _tbl_0 = { }
3016 local _tbl_0 = { } 2916for k, v in pairs(thing) do
3017 for k, v in pairs(thing) do 2917 if k ~= "color" then
3018 if k ~= "color" then 2918 _tbl_0[k] = v
3019 _tbl_0[k] = v
3020 end
3021 end 2919 end
3022 no_color = _tbl_0
3023end 2920end
2921no_color = _tbl_0
3024local numbers = { 2922local numbers = {
3025 1, 2923 1,
3026 2, 2924 2,
@@ -3028,14 +2926,12 @@ local numbers = {
3028 4 2926 4
3029} 2927}
3030local sqrts 2928local sqrts
3031do 2929local _tbl_0 = { }
3032 local _tbl_0 = { } 2930for _index_0 = 1, #numbers do
3033 for _index_0 = 1, #numbers do 2931 local i = numbers[_index_0]
3034 local i = numbers[_index_0] 2932 _tbl_0[i] = math.sqrt(i)
3035 _tbl_0[i] = math.sqrt(i)
3036 end
3037 sqrts = _tbl_0
3038end 2933end
2934sqrts = _tbl_0
3039local tuples = { 2935local tuples = {
3040 { 2936 {
3041 "hello", 2937 "hello",
@@ -3047,52 +2943,44 @@ local tuples = {
3047 } 2943 }
3048} 2944}
3049local tbl 2945local tbl
3050do 2946local _tbl_0 = { }
3051 local _tbl_0 = { } 2947for _index_0 = 1, #tuples do
3052 for _index_0 = 1, #tuples do 2948 local tuple = tuples[_index_0]
3053 local tuple = tuples[_index_0] 2949 local _key_0, _val_0 = unpack(tuple)
3054 local _key_0, _val_0 = unpack(tuple) 2950 _tbl_0[_key_0] = _val_0
3055 _tbl_0[_key_0] = _val_0
3056 end
3057 tbl = _tbl_0
3058end 2951end
2952tbl = _tbl_0
3059local slice 2953local slice
3060do 2954local _accum_0 = { }
3061 local _accum_0 = { } 2955local _len_0 = 1
3062 local _len_0 = 1 2956local _list_0 = items
3063 local _list_0 = items 2957local _max_0 = 5
3064 local _max_0 = 5 2958for _index_0 = 1, _max_0 < 0 and #_list_0 + _max_0 or _max_0 do
3065 for _index_0 = 1, _max_0 < 0 and #_list_0 + _max_0 or _max_0 do 2959 local item = _list_0[_index_0]
3066 local item = _list_0[_index_0] 2960 _accum_0[_len_0] = item
3067 _accum_0[_len_0] = item 2961 _len_0 = _len_0 + 1
3068 _len_0 = _len_0 + 1
3069 end
3070 slice = _accum_0
3071end 2962end
2963slice = _accum_0
3072local slice 2964local slice
3073do 2965local _accum_0 = { }
3074 local _accum_0 = { } 2966local _len_0 = 1
3075 local _len_0 = 1 2967local _list_0 = items
3076 local _list_0 = items 2968for _index_0 = 2, #_list_0 do
3077 for _index_0 = 2, #_list_0 do 2969 local item = _list_0[_index_0]
3078 local item = _list_0[_index_0] 2970 _accum_0[_len_0] = item
3079 _accum_0[_len_0] = item 2971 _len_0 = _len_0 + 1
3080 _len_0 = _len_0 + 1
3081 end
3082 slice = _accum_0
3083end 2972end
2973slice = _accum_0
3084local slice 2974local slice
3085do 2975local _accum_0 = { }
3086 local _accum_0 = { } 2976local _len_0 = 1
3087 local _len_0 = 1 2977local _list_0 = items
3088 local _list_0 = items 2978for _index_0 = 1, #_list_0, 2 do
3089 for _index_0 = 1, #_list_0, 2 do 2979 local item = _list_0[_index_0]
3090 local item = _list_0[_index_0] 2980 _accum_0[_len_0] = item
3091 _accum_0[_len_0] = item 2981 _len_0 = _len_0 + 1
3092 _len_0 = _len_0 + 1
3093 end
3094 slice = _accum_0
3095end 2982end
2983slice = _accum_0
3096for i = 10, 20 do 2984for i = 10, 20 do
3097 print(i) 2985 print(i)
3098end 2986end
@@ -3102,13 +2990,11 @@ end
3102for key, value in pairs(object) do 2990for key, value in pairs(object) do
3103 print(key, value) 2991 print(key, value)
3104end 2992end
3105do 2993local _list_0 = items
3106 local _list_0 = items 2994local _max_0 = 4
3107 local _max_0 = 4 2995for _index_0 = 2, _max_0 < 0 and #_list_0 + _max_0 or _max_0 do
3108 for _index_0 = 2, _max_0 < 0 and #_list_0 + _max_0 or _max_0 do 2996 local item = _list_0[_index_0]
3109 local item = _list_0[_index_0] 2997 print(item)
3110 print(item)
3111 end
3112end 2998end
3113local _list_0 = items 2999local _list_0 = items
3114for _index_0 = 1, #_list_0 do 3000for _index_0 = 1, #_list_0 do
@@ -3119,19 +3005,17 @@ for j = 1, 10, 3 do
3119 print(j) 3005 print(j)
3120end 3006end
3121local doubled_evens 3007local doubled_evens
3122do 3008local _accum_0 = { }
3123 local _accum_0 = { } 3009local _len_0 = 1
3124 local _len_0 = 1 3010for i = 1, 20 do
3125 for i = 1, 20 do 3011 if i % 2 == 0 then
3126 if i % 2 == 0 then 3012 _accum_0[_len_0] = i * 2
3127 _accum_0[_len_0] = i * 2 3013 else
3128 else 3014 _accum_0[_len_0] = i
3129 _accum_0[_len_0] = i
3130 end
3131 _len_0 = _len_0 + 1
3132 end 3015 end
3133 doubled_evens = _accum_0 3016 _len_0 = _len_0 + 1
3134end 3017end
3018doubled_evens = _accum_0
3135local func_a 3019local func_a
3136func_a = function() 3020func_a = function()
3137 for i = 1, 10 do 3021 for i = 1, 10 do
@@ -3189,20 +3073,18 @@ local my_numbers = {
3189 6 3073 6
3190} 3074}
3191local odds 3075local odds
3192do 3076local _accum_0 = { }
3193 local _accum_0 = { } 3077local _len_0 = 1
3194 local _len_0 = 1 3078for _index_0 = 1, #my_numbers do
3195 for _index_0 = 1, #my_numbers do 3079 local x = my_numbers[_index_0]
3196 local x = my_numbers[_index_0] 3080 if x % 2 == 1 then
3197 if x % 2 == 1 then 3081 goto _continue_0
3198 goto _continue_0
3199 end
3200 _accum_0[_len_0] = x
3201 _len_0 = _len_0 + 1
3202 ::_continue_0::
3203 end 3082 end
3204 odds = _accum_0 3083 _accum_0[_len_0] = x
3084 _len_0 = _len_0 + 1
3085 ::_continue_0::
3205end 3086end
3087odds = _accum_0
3206local have_coins = false 3088local have_coins = false
3207if have_coins then 3089if have_coins then
3208 print("有硬å¸") 3090 print("有硬å¸")
@@ -3294,15 +3176,13 @@ else
3294 next_number = error("数字数得太大了ï¼") 3176 next_number = error("数字数得太大了ï¼")
3295end 3177end
3296local msg 3178local msg
3297do 3179local _exp_0 = math.random(1, 5)
3298 local _exp_0 = math.random(1, 5) 3180if 1 == _exp_0 then
3299 if 1 == _exp_0 then 3181 msg = "你很幸è¿"
3300 msg = "你很幸è¿" 3182elseif 2 == _exp_0 then
3301 elseif 2 == _exp_0 then 3183 msg = "你差点很幸è¿"
3302 msg = "你差点很幸è¿" 3184else
3303 else 3185 msg = "ä¸å¤ªå¹¸è¿"
3304 msg = "ä¸å¤ªå¹¸è¿"
3305 end
3306end 3186end
3307do 3187do
3308 local _exp_0 = math.random(1, 5) 3188 local _exp_0 = math.random(1, 5)
@@ -3312,13 +3192,11 @@ do
3312 print("ä¸å¤ªå¹¸è¿") 3192 print("ä¸å¤ªå¹¸è¿")
3313 end 3193 end
3314end 3194end
3315do 3195local _exp_0 = math.random(1, 5)
3316 local _exp_0 = math.random(1, 5) 3196if 1 == _exp_0 then
3317 if 1 == _exp_0 then 3197 print("你很幸è¿")
3318 print("你很幸è¿") 3198else
3319 else 3199 print("ä¸å¤ªå¹¸è¿")
3320 print("ä¸å¤ªå¹¸è¿")
3321 end
3322end 3200end
3323local items = { 3201local items = {
3324 { 3202 {
@@ -3332,25 +3210,23 @@ local items = {
3332} 3210}
3333for _index_0 = 1, #items do 3211for _index_0 = 1, #items do
3334 local item = items[_index_0] 3212 local item = items[_index_0]
3335 do 3213 local _type_0 = type(item)
3336 local _type_0 = type(item) 3214 local _tab_0 = "table" == _type_0 or "userdata" == _type_0
3337 local _tab_0 = "table" == _type_0 or "userdata" == _type_0 3215 local _match_0 = false
3338 local _match_0 = false 3216 if _tab_0 then
3339 if _tab_0 then 3217 local x = item.x
3340 local x = item.x 3218 local y = item.y
3341 local y = item.y 3219 if x ~= nil and y ~= nil then
3342 if x ~= nil and y ~= nil then 3220 _match_0 = true
3343 _match_0 = true 3221 print("Vec2 " .. tostring(x) .. ", " .. tostring(y))
3344 print("Vec2 " .. tostring(x) .. ", " .. tostring(y))
3345 end
3346 end 3222 end
3347 if not _match_0 then 3223 end
3348 if _tab_0 then 3224 if not _match_0 then
3349 local width = item.width 3225 if _tab_0 then
3350 local height = item.height 3226 local width = item.width
3351 if width ~= nil and height ~= nil then 3227 local height = item.height
3352 print("尺寸 " .. tostring(width) .. ", " .. tostring(height)) 3228 if width ~= nil and height ~= nil then
3353 end 3229 print("尺寸 " .. tostring(width) .. ", " .. tostring(height))
3354 end 3230 end
3355 end 3231 end
3356 end 3232 end
@@ -3363,66 +3239,62 @@ end
3363if y == nil then 3239if y == nil then
3364 y = 200 3240 y = 200
3365end 3241end
3366do 3242local _type_0 = type(item)
3367 local _type_0 = type(item) 3243local _tab_0 = "table" == _type_0 or "userdata" == _type_0
3368 local _tab_0 = "table" == _type_0 or "userdata" == _type_0 3244if _tab_0 then
3369 if _tab_0 then 3245 do
3370 do 3246 local _obj_0 = item.pos
3371 local _obj_0 = item.pos 3247 local _type_1 = type(_obj_0)
3372 local _type_1 = type(_obj_0) 3248 if "table" == _type_1 or "userdata" == _type_1 then
3373 if "table" == _type_1 or "userdata" == _type_1 then 3249 x = _obj_0.x
3374 x = _obj_0.x
3375 end
3376 end
3377 do
3378 local _obj_0 = item.pos
3379 local _type_1 = type(_obj_0)
3380 if "table" == _type_1 or "userdata" == _type_1 then
3381 y = _obj_0.y
3382 end
3383 end
3384 if x == nil then
3385 x = 50
3386 end 3250 end
3387 if y == nil then 3251 end
3388 y = 200 3252 do
3253 local _obj_0 = item.pos
3254 local _type_1 = type(_obj_0)
3255 if "table" == _type_1 or "userdata" == _type_1 then
3256 y = _obj_0.y
3389 end 3257 end
3390 print("Vec2 " .. tostring(x) .. ", " .. tostring(y))
3391 end 3258 end
3259 if x == nil then
3260 x = 50
3261 end
3262 if y == nil then
3263 y = 200
3264 end
3265 print("Vec2 " .. tostring(x) .. ", " .. tostring(y))
3392end 3266end
3393local Inventory 3267local Inventory
3394do 3268local _class_0
3395 local _class_0 3269local _base_0 = {
3396 local _base_0 = { 3270 add_item = function(self, name)
3397 add_item = function(self, name) 3271 if self.items[name] then
3398 if self.items[name] then 3272 local _obj_0 = self.items
3399 local _obj_0 = self.items 3273 _obj_0[name] = _obj_0[name] + 1
3400 _obj_0[name] = _obj_0[name] + 1 3274 else
3401 else 3275 self.items[name] = 1
3402 self.items[name] = 1
3403 end
3404 end 3276 end
3405 }
3406 if _base_0.__index == nil then
3407 _base_0.__index = _base_0
3408 end 3277 end
3409 _class_0 = setmetatable({ 3278}
3410 __init = function(self) 3279if _base_0.__index == nil then
3411 self.items = { } 3280 _base_0.__index = _base_0
3412 end,
3413 __base = _base_0,
3414 __name = "Inventory"
3415 }, {
3416 __index = _base_0,
3417 __call = function(cls, ...)
3418 local _self_0 = setmetatable({ }, _base_0)
3419 cls.__init(_self_0, ...)
3420 return _self_0
3421 end
3422 })
3423 _base_0.__class = _class_0
3424 Inventory = _class_0
3425end 3281end
3282_class_0 = setmetatable({
3283 __init = function(self)
3284 self.items = { }
3285 end,
3286 __base = _base_0,
3287 __name = "Inventory"
3288}, {
3289 __index = _base_0,
3290 __call = function(cls, ...)
3291 local _self_0 = setmetatable({ }, _base_0)
3292 cls.__init(_self_0, ...)
3293 return _self_0
3294 end
3295})
3296_base_0.__class = _class_0
3297Inventory = _class_0
3426local inv = Inventory() 3298local inv = Inventory()
3427inv:add_item("t-shirt") 3299inv:add_item("t-shirt")
3428inv:add_item("pants") 3300inv:add_item("pants")
@@ -3463,82 +3335,78 @@ for _index_0 = 1, #_list_0 do
3463 print(item) 3335 print(item)
3464end 3336end
3465local Person 3337local Person
3466do 3338local _class_0
3467 local _class_0 3339local _base_0 = { }
3468 local _base_0 = { } 3340if _base_0.__index == nil then
3469 if _base_0.__index == nil then 3341 _base_0.__index = _base_0
3470 _base_0.__index = _base_0 3342end
3343_class_0 = setmetatable({
3344 __init = function(self)
3345 self.clothes = { }
3346 end,
3347 __base = _base_0,
3348 __name = "Person"
3349}, {
3350 __index = _base_0,
3351 __call = function(cls, ...)
3352 local _self_0 = setmetatable({ }, _base_0)
3353 cls.__init(_self_0, ...)
3354 return _self_0
3471 end 3355 end
3472 _class_0 = setmetatable({ 3356})
3473 __init = function(self) 3357_base_0.__class = _class_0
3474 self.clothes = { } 3358Person = _class_0
3475 end,
3476 __base = _base_0,
3477 __name = "Person"
3478 }, {
3479 __index = _base_0,
3480 __call = function(cls, ...)
3481 local _self_0 = setmetatable({ }, _base_0)
3482 cls.__init(_self_0, ...)
3483 return _self_0
3484 end
3485 })
3486 _base_0.__class = _class_0
3487 Person = _class_0
3488end
3489local BackPack 3359local BackPack
3490do 3360local _class_0
3491 local _class_0 3361local _parent_0 = Inventory
3492 local _parent_0 = Inventory 3362local _base_0 = {
3493 local _base_0 = { 3363 size = 10,
3494 size = 10, 3364 add_item = function(self, name)
3495 add_item = function(self, name) 3365 if #self.items > size then
3496 if #self.items > size then 3366 error("背包已满")
3497 error("背包已满")
3498 end
3499 return _class_0.__parent.__base.add_item(self, name)
3500 end
3501 }
3502 for _key_0, _val_0 in pairs(_parent_0.__base) do
3503 if _base_0[_key_0] == nil and _key_0:match("^__") and not (_key_0 == "__index" and _val_0 == _parent_0.__base) then
3504 _base_0[_key_0] = _val_0
3505 end 3367 end
3368 return _class_0.__parent.__base.add_item(self, name)
3506 end 3369 end
3507 if _base_0.__index == nil then 3370}
3508 _base_0.__index = _base_0 3371for _key_0, _val_0 in pairs(_parent_0.__base) do
3372 if _base_0[_key_0] == nil and _key_0:match("^__") and not (_key_0 == "__index" and _val_0 == _parent_0.__base) then
3373 _base_0[_key_0] = _val_0
3509 end 3374 end
3510 setmetatable(_base_0, _parent_0.__base) 3375end
3511 _class_0 = setmetatable({ 3376if _base_0.__index == nil then
3512 __init = function(self, ...) 3377 _base_0.__index = _base_0
3513 return _class_0.__parent.__init(self, ...) 3378end
3514 end, 3379setmetatable(_base_0, _parent_0.__base)
3515 __base = _base_0, 3380_class_0 = setmetatable({
3516 __name = "BackPack", 3381 __init = function(self, ...)
3517 __parent = _parent_0 3382 return _class_0.__parent.__init(self, ...)
3518 }, { 3383 end,
3519 __index = function(cls, name) 3384 __base = _base_0,
3520 local val = rawget(_base_0, name) 3385 __name = "BackPack",
3521 if val == nil then 3386 __parent = _parent_0
3522 local parent = rawget(cls, "__parent") 3387}, {
3523 if parent then 3388 __index = function(cls, name)
3524 return parent[name] 3389 local val = rawget(_base_0, name)
3525 end 3390 if val == nil then
3526 else 3391 local parent = rawget(cls, "__parent")
3527 return val 3392 if parent then
3393 return parent[name]
3528 end 3394 end
3529 end, 3395 else
3530 __call = function(cls, ...) 3396 return val
3531 local _self_0 = setmetatable({ }, _base_0)
3532 cls.__init(_self_0, ...)
3533 return _self_0
3534 end 3397 end
3535 }) 3398 end,
3536 _base_0.__class = _class_0 3399 __call = function(cls, ...)
3537 if _parent_0.__inherited then 3400 local _self_0 = setmetatable({ }, _base_0)
3538 _parent_0.__inherited(_parent_0, _class_0) 3401 cls.__init(_self_0, ...)
3402 return _self_0
3539 end 3403 end
3540 BackPack = _class_0 3404})
3405_base_0.__class = _class_0
3406if _parent_0.__inherited then
3407 _parent_0.__inherited(_parent_0, _class_0)
3541end 3408end
3409BackPack = _class_0
3542local Shelf 3410local Shelf
3543do 3411do
3544 local _class_0 3412 local _class_0
@@ -3566,102 +3434,98 @@ do
3566 Shelf = _class_0 3434 Shelf = _class_0
3567end 3435end
3568local Cupboard 3436local Cupboard
3569do 3437local _class_0
3570 local _class_0 3438local _parent_0 = Shelf
3571 local _parent_0 = Shelf 3439local _base_0 = { }
3572 local _base_0 = { } 3440for _key_0, _val_0 in pairs(_parent_0.__base) do
3573 for _key_0, _val_0 in pairs(_parent_0.__base) do 3441 if _base_0[_key_0] == nil and _key_0:match("^__") and not (_key_0 == "__index" and _val_0 == _parent_0.__base) then
3574 if _base_0[_key_0] == nil and _key_0:match("^__") and not (_key_0 == "__index" and _val_0 == _parent_0.__base) then 3442 _base_0[_key_0] = _val_0
3575 _base_0[_key_0] = _val_0 3443 end
3576 end 3444end
3577 end 3445if _base_0.__index == nil then
3578 if _base_0.__index == nil then 3446 _base_0.__index = _base_0
3579 _base_0.__index = _base_0 3447end
3580 end 3448setmetatable(_base_0, _parent_0.__base)
3581 setmetatable(_base_0, _parent_0.__base) 3449_class_0 = setmetatable({
3582 _class_0 = setmetatable({ 3450 __init = function(self, ...)
3583 __init = function(self, ...) 3451 return _class_0.__parent.__init(self, ...)
3584 return _class_0.__parent.__init(self, ...) 3452 end,
3585 end, 3453 __base = _base_0,
3586 __base = _base_0, 3454 __name = "Cupboard",
3587 __name = "Cupboard", 3455 __parent = _parent_0
3588 __parent = _parent_0 3456}, {
3589 }, { 3457 __index = function(cls, name)
3590 __index = function(cls, name) 3458 local val = rawget(_base_0, name)
3591 local val = rawget(_base_0, name) 3459 if val == nil then
3592 if val == nil then 3460 local parent = rawget(cls, "__parent")
3593 local parent = rawget(cls, "__parent") 3461 if parent then
3594 if parent then 3462 return parent[name]
3595 return parent[name]
3596 end
3597 else
3598 return val
3599 end 3463 end
3600 end, 3464 else
3601 __call = function(cls, ...) 3465 return val
3602 local _self_0 = setmetatable({ }, _base_0)
3603 cls.__init(_self_0, ...)
3604 return _self_0
3605 end 3466 end
3606 }) 3467 end,
3607 _base_0.__class = _class_0 3468 __call = function(cls, ...)
3608 if _parent_0.__inherited then 3469 local _self_0 = setmetatable({ }, _base_0)
3609 _parent_0.__inherited(_parent_0, _class_0) 3470 cls.__init(_self_0, ...)
3471 return _self_0
3610 end 3472 end
3611 Cupboard = _class_0 3473})
3474_base_0.__class = _class_0
3475if _parent_0.__inherited then
3476 _parent_0.__inherited(_parent_0, _class_0)
3612end 3477end
3478Cupboard = _class_0
3613local MyClass 3479local MyClass
3614do 3480local _class_0
3615 local _class_0 3481local _parent_0 = ParentClass
3616 local _parent_0 = ParentClass 3482local _base_0 = {
3617 local _base_0 = { 3483 a_method = function(self)
3618 a_method = function(self) 3484 _class_0.__parent.__base.a_method(self, "你好", "世界")
3619 _class_0.__parent.__base.a_method(self, "你好", "世界") 3485 _class_0.__parent.a_method(self, "你好", "世界")
3620 _class_0.__parent.a_method(self, "你好", "世界") 3486 _class_0.__parent.a_method(self, "你好", "世界")
3621 _class_0.__parent.a_method(self, "你好", "世界") 3487 return assert(_class_0.__parent == ParentClass)
3622 return assert(_class_0.__parent == ParentClass) 3488 end
3623 end 3489}
3624 } 3490for _key_0, _val_0 in pairs(_parent_0.__base) do
3625 for _key_0, _val_0 in pairs(_parent_0.__base) do 3491 if _base_0[_key_0] == nil and _key_0:match("^__") and not (_key_0 == "__index" and _val_0 == _parent_0.__base) then
3626 if _base_0[_key_0] == nil and _key_0:match("^__") and not (_key_0 == "__index" and _val_0 == _parent_0.__base) then 3492 _base_0[_key_0] = _val_0
3627 _base_0[_key_0] = _val_0 3493 end
3628 end 3494end
3629 end 3495if _base_0.__index == nil then
3630 if _base_0.__index == nil then 3496 _base_0.__index = _base_0
3631 _base_0.__index = _base_0 3497end
3632 end 3498setmetatable(_base_0, _parent_0.__base)
3633 setmetatable(_base_0, _parent_0.__base) 3499_class_0 = setmetatable({
3634 _class_0 = setmetatable({ 3500 __init = function(self, ...)
3635 __init = function(self, ...) 3501 return _class_0.__parent.__init(self, ...)
3636 return _class_0.__parent.__init(self, ...) 3502 end,
3637 end, 3503 __base = _base_0,
3638 __base = _base_0, 3504 __name = "MyClass",
3639 __name = "MyClass", 3505 __parent = _parent_0
3640 __parent = _parent_0 3506}, {
3641 }, { 3507 __index = function(cls, name)
3642 __index = function(cls, name) 3508 local val = rawget(_base_0, name)
3643 local val = rawget(_base_0, name) 3509 if val == nil then
3644 if val == nil then 3510 local parent = rawget(cls, "__parent")
3645 local parent = rawget(cls, "__parent") 3511 if parent then
3646 if parent then 3512 return parent[name]
3647 return parent[name]
3648 end
3649 else
3650 return val
3651 end 3513 end
3652 end, 3514 else
3653 __call = function(cls, ...) 3515 return val
3654 local _self_0 = setmetatable({ }, _base_0)
3655 cls.__init(_self_0, ...)
3656 return _self_0
3657 end 3516 end
3658 }) 3517 end,
3659 _base_0.__class = _class_0 3518 __call = function(cls, ...)
3660 if _parent_0.__inherited then 3519 local _self_0 = setmetatable({ }, _base_0)
3661 _parent_0.__inherited(_parent_0, _class_0) 3520 cls.__init(_self_0, ...)
3521 return _self_0
3662 end 3522 end
3663 MyClass = _class_0 3523})
3524_base_0.__class = _class_0
3525if _parent_0.__inherited then
3526 _parent_0.__inherited(_parent_0, _class_0)
3664end 3527end
3528MyClass = _class_0
3665local b = BackPack() 3529local b = BackPack()
3666assert(b.__class == BackPack) 3530assert(b.__class == BackPack)
3667print(BackPack.size) 3531print(BackPack.size)
@@ -3725,61 +3589,57 @@ Counter()
3725print(Counter.count) 3589print(Counter.count)
3726self.__class:hello(1, 2, 3, 4) 3590self.__class:hello(1, 2, 3, 4)
3727local Things 3591local Things
3728do 3592local _class_0
3729 local _class_0 3593local _base_0 = { }
3730 local _base_0 = { } 3594if _base_0.__index == nil then
3731 if _base_0.__index == nil then 3595 _base_0.__index = _base_0
3732 _base_0.__index = _base_0 3596end
3597_class_0 = setmetatable({
3598 __init = function() end,
3599 __base = _base_0,
3600 __name = "Things"
3601}, {
3602 __index = _base_0,
3603 __call = function(cls, ...)
3604 local _self_0 = setmetatable({ }, _base_0)
3605 cls.__init(_self_0, ...)
3606 return _self_0
3733 end 3607 end
3734 _class_0 = setmetatable({ 3608})
3735 __init = function() end, 3609_base_0.__class = _class_0
3736 __base = _base_0, 3610local self = _class_0;
3737 __name = "Things" 3611self.class_var = "hello world"
3738 }, { 3612Things = _class_0
3739 __index = _base_0,
3740 __call = function(cls, ...)
3741 local _self_0 = setmetatable({ }, _base_0)
3742 cls.__init(_self_0, ...)
3743 return _self_0
3744 end
3745 })
3746 _base_0.__class = _class_0
3747 local self = _class_0;
3748 self.class_var = "hello world"
3749 Things = _class_0
3750end
3751local MoreThings 3613local MoreThings
3752do 3614local _class_0
3753 local _class_0 3615local secret, log
3754 local secret, log 3616local _base_0 = {
3755 local _base_0 = { 3617 some_method = function(self)
3756 some_method = function(self) 3618 return log("hello world: " .. secret)
3757 return log("hello world: " .. secret)
3758 end
3759 }
3760 if _base_0.__index == nil then
3761 _base_0.__index = _base_0
3762 end 3619 end
3763 _class_0 = setmetatable({ 3620}
3764 __init = function() end, 3621if _base_0.__index == nil then
3765 __base = _base_0, 3622 _base_0.__index = _base_0
3766 __name = "MoreThings" 3623end
3767 }, { 3624_class_0 = setmetatable({
3768 __index = _base_0, 3625 __init = function() end,
3769 __call = function(cls, ...) 3626 __base = _base_0,
3770 local _self_0 = setmetatable({ }, _base_0) 3627 __name = "MoreThings"
3771 cls.__init(_self_0, ...) 3628}, {
3772 return _self_0 3629 __index = _base_0,
3773 end 3630 __call = function(cls, ...)
3774 }) 3631 local _self_0 = setmetatable({ }, _base_0)
3775 _base_0.__class = _class_0 3632 cls.__init(_self_0, ...)
3776 local self = _class_0; 3633 return _self_0
3777 secret = 123
3778 log = function(msg)
3779 return print("LOG:", msg)
3780 end 3634 end
3781 MoreThings = _class_0 3635})
3636_base_0.__class = _class_0
3637local self = _class_0;
3638secret = 123
3639log = function(msg)
3640 return print("LOG:", msg)
3782end 3641end
3642MoreThings = _class_0
3783assert(self == self) 3643assert(self == self)
3784assert(self.__class == self.__class) 3644assert(self.__class == self.__class)
3785local some_instance_method 3645local some_instance_method
@@ -3813,32 +3673,30 @@ do
3813 _base_0.__class = _class_0 3673 _base_0.__class = _class_0
3814 Something = _class_0 3674 Something = _class_0
3815end 3675end
3816do 3676local _class_0
3817 local _class_0 3677local _base_0 = { }
3818 local _base_0 = { } 3678if _base_0.__index == nil then
3819 if _base_0.__index == nil then 3679 _base_0.__index = _base_0
3820 _base_0.__index = _base_0 3680end
3681_class_0 = setmetatable({
3682 __init = function(self, foo, bar, biz, baz)
3683 self.foo = foo
3684 self.bar = bar
3685 self.__class.biz = biz
3686 self.__class.baz = baz
3687 end,
3688 __base = _base_0,
3689 __name = "Something"
3690}, {
3691 __index = _base_0,
3692 __call = function(cls, ...)
3693 local _self_0 = setmetatable({ }, _base_0)
3694 cls.__init(_self_0, ...)
3695 return _self_0
3821 end 3696 end
3822 _class_0 = setmetatable({ 3697})
3823 __init = function(self, foo, bar, biz, baz) 3698_base_0.__class = _class_0
3824 self.foo = foo 3699Something = _class_0
3825 self.bar = bar
3826 self.__class.biz = biz
3827 self.__class.baz = baz
3828 end,
3829 __base = _base_0,
3830 __name = "Something"
3831 }, {
3832 __index = _base_0,
3833 __call = function(cls, ...)
3834 local _self_0 = setmetatable({ }, _base_0)
3835 cls.__init(_self_0, ...)
3836 return _self_0
3837 end
3838 })
3839 _base_0.__class = _class_0
3840 Something = _class_0
3841end
3842local new 3700local new
3843new = function(self, fieldA, fieldB) 3701new = function(self, fieldA, fieldB)
3844 self.fieldA = fieldA 3702 self.fieldA = fieldA
@@ -3849,33 +3707,31 @@ local obj = new({ }, 123, "abc")
3849print(obj) 3707print(obj)
3850local x 3708local x
3851local Bucket 3709local Bucket
3852do 3710local _class_0
3853 local _class_0 3711local _base_0 = {
3854 local _base_0 = { 3712 drops = 0,
3855 drops = 0, 3713 add_drop = function(self)
3856 add_drop = function(self) 3714 self.drops = self.drops + 1
3857 self.drops = self.drops + 1
3858 end
3859 }
3860 if _base_0.__index == nil then
3861 _base_0.__index = _base_0
3862 end 3715 end
3863 _class_0 = setmetatable({ 3716}
3864 __init = function() end, 3717if _base_0.__index == nil then
3865 __base = _base_0, 3718 _base_0.__index = _base_0
3866 __name = "Bucket"
3867 }, {
3868 __index = _base_0,
3869 __call = function(cls, ...)
3870 local _self_0 = setmetatable({ }, _base_0)
3871 cls.__init(_self_0, ...)
3872 return _self_0
3873 end
3874 })
3875 _base_0.__class = _class_0
3876 Bucket = _class_0
3877 x = _class_0
3878end 3719end
3720_class_0 = setmetatable({
3721 __init = function() end,
3722 __base = _base_0,
3723 __name = "Bucket"
3724}, {
3725 __index = _base_0,
3726 __call = function(cls, ...)
3727 local _self_0 = setmetatable({ }, _base_0)
3728 cls.__init(_self_0, ...)
3729 return _self_0
3730 end
3731})
3732_base_0.__class = _class_0
3733Bucket = _class_0
3734x = _class_0
3879local BigBucket 3735local BigBucket
3880do 3736do
3881 local _class_0 3737 local _class_0
@@ -3927,27 +3783,25 @@ do
3927end 3783end
3928assert(Bucket.__name == "BigBucket") 3784assert(Bucket.__name == "BigBucket")
3929local x 3785local x
3930do 3786local _class_0
3931 local _class_0 3787local _base_0 = { }
3932 local _base_0 = { } 3788if _base_0.__index == nil then
3933 if _base_0.__index == nil then 3789 _base_0.__index = _base_0
3934 _base_0.__index = _base_0 3790end
3791_class_0 = setmetatable({
3792 __init = function() end,
3793 __base = _base_0,
3794 __name = "x"
3795}, {
3796 __index = _base_0,
3797 __call = function(cls, ...)
3798 local _self_0 = setmetatable({ }, _base_0)
3799 cls.__init(_self_0, ...)
3800 return _self_0
3935 end 3801 end
3936 _class_0 = setmetatable({ 3802})
3937 __init = function() end, 3803_base_0.__class = _class_0
3938 __base = _base_0, 3804x = _class_0
3939 __name = "x"
3940 }, {
3941 __index = _base_0,
3942 __call = function(cls, ...)
3943 local _self_0 = setmetatable({ }, _base_0)
3944 cls.__init(_self_0, ...)
3945 return _self_0
3946 end
3947 })
3948 _base_0.__class = _class_0
3949 x = _class_0
3950end
3951local MyIndex = { 3805local MyIndex = {
3952 __index = { 3806 __index = {
3953 var = 1 3807 var = 1
@@ -4030,19 +3884,15 @@ end
4030local y = Y() 3884local y = Y()
4031y:func() 3885y:func()
4032assert(y.__class.__parent ~= X) 3886assert(y.__class.__parent ~= X)
4033do 3887local _with_0 = Person()
4034 local _with_0 = Person() 3888_with_0.name = "Oswald"
4035 _with_0.name = "Oswald" 3889_with_0:add_relative(my_dad)
4036 _with_0:add_relative(my_dad) 3890_with_0:save()
4037 _with_0:save() 3891print(_with_0.name)
4038 print(_with_0.name)
4039end
4040local file 3892local file
4041do 3893local _with_0 = File("favorite_foods.txt")
4042 local _with_0 = File("favorite_foods.txt") 3894_with_0:set_encoding("utf8")
4043 _with_0:set_encoding("utf8") 3895file = _with_0
4044 file = _with_0
4045end
4046local create_person 3896local create_person
4047create_person = function(name, relatives) 3897create_person = function(name, relatives)
4048 local _with_0 = Person() 3898 local _with_0 = Person()
@@ -4058,22 +3908,18 @@ local me = create_person("Leaf", {
4058 mother, 3908 mother,
4059 sister 3909 sister
4060}) 3910})
4061do 3911local str = "你好"
4062 local str = "你好" 3912print("原始:", str)
4063 print("原始:", str) 3913print("大写:", str:upper())
4064 print("大写:", str:upper()) 3914local _with_0 = tb
4065end 3915_with_0[1] = 1
4066do 3916print(_with_0[2])
4067 local _with_0 = tb 3917do
4068 _with_0[1] = 1 3918 local _with_1 = _with_0[abc]
4069 print(_with_0[2]) 3919 _with_1[3] = _with_1[2]:func()
4070 do 3920 _with_1["key-name"] = value
4071 local _with_1 = _with_0[abc] 3921end
4072 _with_1[3] = _with_1[2]:func() 3922_with_0[#_with_0 + 1] = "abc"
4073 _with_1["key-name"] = value
4074 end
4075 _with_0[#_with_0 + 1] = "abc"
4076end
4077do 3923do
4078 local var = "hello" 3924 local var = "hello"
4079 print(var) 3925 print(var)
diff --git a/spec/outputs/compile_doc.lua b/spec/outputs/compile_doc.lua
index 7597cb8..29f4aeb 100644
--- a/spec/outputs/compile_doc.lua
+++ b/spec/outputs/compile_doc.lua
@@ -19,31 +19,27 @@ for _index_0 = 1, #_list_0 do
19 local text = _with_0:read("*a") 19 local text = _with_0:read("*a")
20 local codes = { } 20 local codes = { }
21 for code in text:gmatch("```moonscript(.-)```") do 21 for code in text:gmatch("```moonscript(.-)```") do
22 do 22 local result, err = to_lua(code, {
23 local result, err = to_lua(code, { 23 implicit_return_root = false,
24 implicit_return_root = false, 24 reserve_line_number = false
25 reserve_line_number = false 25 })
26 }) 26 if result then
27 if result then 27 codes[#codes + 1] = result
28 codes[#codes + 1] = result 28 elseif not err:match("macro exporting module only accepts macro definition") then
29 elseif not err:match("macro exporting module only accepts macro definition") then 29 print(err)
30 print(err) 30 os.exit(1)
31 os.exit(1)
32 end
33 end 31 end
34 end 32 end
35 for code in text:gmatch("<pre>(.-)</pre>") do 33 for code in text:gmatch("<pre>(.-)</pre>") do
36 do 34 local result, err = to_lua(code:gsub("&lt;", "<"):gsub("&gt;", ">"), {
37 local result, err = to_lua(code:gsub("&lt;", "<"):gsub("&gt;", ">"), { 35 implicit_return_root = false,
38 implicit_return_root = false, 36 reserve_line_number = false
39 reserve_line_number = false 37 })
40 }) 38 if result then
41 if result then 39 codes[#codes + 1] = result
42 codes[#codes + 1] = result 40 else
43 else 41 print(err)
44 print(err) 42 os.exit(1)
45 os.exit(1)
46 end
47 end 43 end
48 end 44 end
49 local output <close> = (function() 45 local output <close> = (function()
diff --git a/spec/outputs/cond.lua b/spec/outputs/cond.lua
index acbf644..5a5aae5 100644
--- a/spec/outputs/cond.lua
+++ b/spec/outputs/cond.lua
@@ -113,17 +113,15 @@ local z = false
113if false then 113if false then
114 _ = one 114 _ = one
115else 115else
116 do 116 local x = true
117 local x = true 117 if x then
118 if x then 118 _ = two
119 _ = two 119 else
120 z = true
121 if z then
122 _ = three
120 else 123 else
121 z = true 124 _ = four
122 if z then
123 _ = three
124 else
125 _ = four
126 end
127 end 125 end
128 end 126 end
129end 127end
@@ -131,33 +129,27 @@ local out
131if false then 129if false then
132 out = one 130 out = one
133else 131else
134 do 132 local x = true
135 local x = true 133 if x then
136 if x then 134 out = two
137 out = two 135 else
136 z = true
137 if z then
138 out = three
138 else 139 else
139 z = true 140 out = four
140 if z then
141 out = three
142 else
143 out = four
144 end
145 end 141 end
146 end 142 end
147end 143end
148local kzy 144local kzy
149kzy = function() 145kzy = function()
150 do 146 local something = true
151 local something = true 147 if something then
152 if something then 148 return 1
153 return 1 149 else
154 else 150 local another = false
155 do 151 if another then
156 local another = false 152 return 2
157 if another then
158 return 2
159 end
160 end
161 end 153 end
162 end 154 end
163end 155end
@@ -314,12 +306,10 @@ do
314 end 306 end
315end 307end
316do 308do
317 do 309 local _M = { }
318 local _M = { } 310 if _M then
319 if _M then 311 local Thing = _M.Thing
320 local Thing = _M.Thing 312 a, b = _M.a, _M.b
321 a, b = _M.a, _M.b
322 end
323 end 313 end
324end 314end
325do 315do
diff --git a/spec/outputs/destructure.lua b/spec/outputs/destructure.lua
index 38f21ff..224ed2d 100644
--- a/spec/outputs/destructure.lua
+++ b/spec/outputs/destructure.lua
@@ -131,11 +131,9 @@ do
131 end 131 end
132end 132end
133do 133do
134 do 134 local _with_0 = thing
135 local _with_0 = thing 135 local a, b = _with_0[1], _with_0[2]
136 local a, b = _with_0[1], _with_0[2] 136 print(a, b)
137 print(a, b)
138 end
139end 137end
140do 138do
141 local thing = nil 139 local thing = nil
@@ -314,11 +312,9 @@ do
314 _tmp_0 = _obj_0.func 312 _tmp_0 = _obj_0.func
315 end 313 end
316 if _tmp_0 == nil then 314 if _tmp_0 == nil then
317 do 315 local _obj_0 = item
318 local _obj_0 = item 316 if _obj_0 ~= nil then
319 if _obj_0 ~= nil then 317 _tmp_0 = _obj_0.defVal
320 _tmp_0 = _obj_0.defVal
321 end
322 end 318 end
323 end 319 end
324 a.b(function() 320 a.b(function()
@@ -449,11 +445,9 @@ do
449 end 445 end
450 local y1, y4 446 local y1, y4
451 local y2, y3 447 local y2, y3
452 do 448 local _obj_0, _obj_1 = f2()
453 local _obj_0, _obj_1 = f2() 449 y1, y4 = f1(), _obj_1
454 y1, y4 = f1(), _obj_1 450 y2, y3 = _obj_0.y2, _obj_0.y3
455 y2, y3 = _obj_0.y2, _obj_0.y3
456 end
457end 451end
458do 452do
459 local v1, v2, v3, v4 453 local v1, v2, v3, v4
@@ -483,11 +477,9 @@ do
483end 477end
484do 478do
485 local value, value_meta 479 local value, value_meta
486 do 480 local _obj_0 = tb
487 local _obj_0 = tb 481 value = _obj_0[name]
488 value = _obj_0[name] 482 value_meta = getmetatable(_obj_0)[name]
489 value_meta = getmetatable(_obj_0)[name]
490 end
491end 483end
492do 484do
493 local tostring, add 485 local tostring, add
@@ -500,24 +492,22 @@ do
500 end) 492 end)
501 end 493 end
502 end 494 end
503 do 495 local _exp_0 = tb
504 local _exp_0 = tb 496 local _type_0 = type(_exp_0)
505 local _type_0 = type(_exp_0) 497 local _tab_0 = "table" == _type_0 or "userdata" == _type_0
506 local _tab_0 = "table" == _type_0 or "userdata" == _type_0 498 if _tab_0 then
507 if _tab_0 then 499 local name, meta_field
508 local name, meta_field 500 do
509 do 501 local _obj_0 = getmetatable(_exp_0)
510 local _obj_0 = getmetatable(_exp_0) 502 name = _obj_0.__name
511 name = _obj_0.__name 503 meta_field = _obj_0["123"]
512 meta_field = _obj_0["123"] 504 if name == nil then
513 if name == nil then 505 name = "item"
514 name = "item"
515 end
516 end
517 if meta_field ~= nil then
518 print(name, meta_field)
519 end 506 end
520 end 507 end
508 if meta_field ~= nil then
509 print(name, meta_field)
510 end
521 end 511 end
522end 512end
523do 513do
@@ -599,52 +589,50 @@ do
599 print(add, field) 589 print(add, field)
600 end 590 end
601 end 591 end
602 do 592 local _exp_0 = tb
603 local _exp_0 = tb 593 local _type_0 = type(_exp_0)
604 local _type_0 = type(_exp_0) 594 local _tab_0 = "table" == _type_0 or "userdata" == _type_0
605 local _tab_0 = "table" == _type_0 or "userdata" == _type_0 595 if _tab_0 then
606 if _tab_0 then 596 do
607 do 597 local _obj_0 = _exp_0.c
608 local _obj_0 = _exp_0.c 598 local _type_1 = type(_obj_0)
609 local _type_1 = type(_obj_0) 599 if "table" == _type_1 or "userdata" == _type_1 then
610 if "table" == _type_1 or "userdata" == _type_1 then 600 do
611 do 601 local _obj_1 = getmetatable(_obj_0)
612 local _obj_1 = getmetatable(_obj_0) 602 local _type_2 = type(_obj_1)
613 local _type_2 = type(_obj_1) 603 if "table" == _type_2 or "userdata" == _type_2 then
614 if "table" == _type_2 or "userdata" == _type_2 then 604 meta_field = _obj_1["abc"]
615 meta_field = _obj_1["abc"]
616 end
617 end 605 end
618 end 606 end
619 end 607 end
620 if meta_field == nil then 608 end
621 meta_field = "def" 609 if meta_field == nil then
622 end 610 meta_field = "def"
611 end
612 do
613 local _obj_0 = getmetatable(_exp_0)
623 do 614 do
624 local _obj_0 = getmetatable(_exp_0) 615 local _obj_1 = _obj_0[ [[any string]]]
625 do 616 local _type_1 = type(_obj_1)
626 local _obj_1 = _obj_0[ [[any string]]] 617 if "table" == _type_1 or "userdata" == _type_1 then
627 local _type_1 = type(_obj_1) 618 abc = _obj_1.d
628 if "table" == _type_1 or "userdata" == _type_1 then
629 abc = _obj_1.d
630 end
631 end
632 do
633 local _obj_1 = _obj_0['str']
634 local _type_1 = type(_obj_1)
635 if "table" == _type_1 or "userdata" == _type_1 then
636 def = _obj_1.e
637 end
638 end
639 if abc == nil then
640 abc = 123
641 end 619 end
642 if def == nil then 620 end
643 def = { } 621 do
622 local _obj_1 = _obj_0['str']
623 local _type_1 = type(_obj_1)
624 if "table" == _type_1 or "userdata" == _type_1 then
625 def = _obj_1.e
644 end 626 end
645 end 627 end
646 print(meta_field, abc, def) 628 if abc == nil then
629 abc = 123
630 end
631 if def == nil then
632 def = { }
633 end
647 end 634 end
635 print(meta_field, abc, def)
648 end 636 end
649end 637end
650return nil 638return nil
diff --git a/spec/outputs/funcs.lua b/spec/outputs/funcs.lua
index c07989e..c1735c4 100644
--- a/spec/outputs/funcs.lua
+++ b/spec/outputs/funcs.lua
@@ -224,13 +224,11 @@ do
224 if item.field then 224 if item.field then
225 local value = item.field.get("abc") 225 local value = item.field.get("abc")
226 if value then 226 if value then
227 do 227 local _exp_0 = value:get()
228 local _exp_0 = value:get() 228 if 123 == _exp_0 then
229 if 123 == _exp_0 then 229 return false
230 return false 230 elseif 456 == _exp_0 then
231 elseif 456 == _exp_0 then 231 handle(item)
232 handle(item)
233 end
234 end 232 end
235 end 233 end
236 end 234 end
@@ -240,13 +238,11 @@ do
240 if item.field then 238 if item.field then
241 local value = item.field.get("abc") 239 local value = item.field.get("abc")
242 if value then 240 if value then
243 do 241 local _exp_0 = value:get()
244 local _exp_0 = value:get() 242 if 123 == _exp_0 then
245 if 123 == _exp_0 then 243 return false
246 return false 244 elseif 456 == _exp_0 then
247 elseif 456 == _exp_0 then 245 handle(item)
248 handle(item)
249 end
250 end 246 end
251 end 247 end
252 end 248 end
@@ -261,14 +257,12 @@ do
261 local pwd = req.pwd 257 local pwd = req.pwd
262 if name ~= nil and pwd ~= nil then 258 if name ~= nil and pwd ~= nil then
263 if name ~= "" then 259 if name ~= "" then
264 do 260 local user = DB:queryUser(name, pwd)
265 local user = DB:queryUser(name, pwd) 261 if user then
266 if user then 262 if user.status == "available" then
267 if user.status == "available" then 263 return {
268 return { 264 success = true
269 success = true 265 }
270 }
271 end
272 end 266 end
273 end 267 end
274 end 268 end
diff --git a/spec/outputs/global.lua b/spec/outputs/global.lua
index 930ecf6..7e74387 100644
--- a/spec/outputs/global.lua
+++ b/spec/outputs/global.lua
@@ -3,29 +3,27 @@ do
3 cool = "dad" 3 cool = "dad"
4end 4end
5do 5do
6 do 6 local _class_0
7 local _class_0 7 local _base_0 = {
8 local _base_0 = { 8 umm = "cool"
9 umm = "cool" 9 }
10 } 10 if _base_0.__index == nil then
11 if _base_0.__index == nil then 11 _base_0.__index = _base_0
12 _base_0.__index = _base_0
13 end
14 _class_0 = setmetatable({
15 __init = function() end,
16 __base = _base_0,
17 __name = "Something"
18 }, {
19 __index = _base_0,
20 __call = function(cls, ...)
21 local _self_0 = setmetatable({ }, _base_0)
22 cls.__init(_self_0, ...)
23 return _self_0
24 end
25 })
26 _base_0.__class = _class_0
27 Something = _class_0
28 end 12 end
13 _class_0 = setmetatable({
14 __init = function() end,
15 __base = _base_0,
16 __name = "Something"
17 }, {
18 __index = _base_0,
19 __call = function(cls, ...)
20 local _self_0 = setmetatable({ }, _base_0)
21 cls.__init(_self_0, ...)
22 return _self_0
23 end
24 })
25 _base_0.__class = _class_0
26 Something = _class_0
29end 27end
30do 28do
31 local d 29 local d
diff --git a/spec/outputs/import.lua b/spec/outputs/import.lua
index 270c7b7..ffe688b 100644
--- a/spec/outputs/import.lua
+++ b/spec/outputs/import.lua
@@ -30,16 +30,14 @@ do
30end 30end
31if indent then 31if indent then
32 local okay, well 32 local okay, well
33 do 33 local _obj_1 = tables[100]
34 local _obj_1 = tables[100] 34 okay, well = _obj_1.okay, (function()
35 okay, well = _obj_1.okay, (function() 35 local _base_0 = _obj_1
36 local _base_0 = _obj_1 36 local _fn_0 = _base_0.well
37 local _fn_0 = _base_0.well 37 return _fn_0 and function(...)
38 return _fn_0 and function(...) 38 return _fn_0(_base_0, ...)
39 return _fn_0(_base_0, ...) 39 end
40 end 40 end)()
41 end)()
42 end
43end 41end
44do 42do
45 local a, b, c = z.a, z.b, z.c 43 local a, b, c = z.a, z.b, z.c
@@ -68,16 +66,14 @@ do
68 item = _obj_1.item 66 item = _obj_1.item
69 end 67 end
70 local x1, y1, z1 68 local x1, y1, z1
71 do 69 local _obj_1 = require("mymodule")
72 local _obj_1 = require("mymodule") 70 x1, y1, z1 = _obj_1.x1, _obj_1.y1, (function()
73 x1, y1, z1 = _obj_1.x1, _obj_1.y1, (function() 71 local _base_0 = _obj_1
74 local _base_0 = _obj_1 72 local _fn_0 = _base_0.z1
75 local _fn_0 = _base_0.z1 73 return _fn_0 and function(...)
76 return _fn_0 and function(...) 74 return _fn_0(_base_0, ...)
77 return _fn_0(_base_0, ...) 75 end
78 end 76 end)()
79 end)()
80 end
81end 77end
82do 78do
83 local p 79 local p
@@ -86,16 +82,14 @@ do
86 p = _obj_1.p 82 p = _obj_1.p
87 end 83 end
88 local x1, y1, z1 84 local x1, y1, z1
89 do 85 local _obj_1 = require('mymodule')
90 local _obj_1 = require('mymodule') 86 x1, y1, z1 = _obj_1.x1, _obj_1.y1, (function()
91 x1, y1, z1 = _obj_1.x1, _obj_1.y1, (function() 87 local _base_0 = _obj_1
92 local _base_0 = _obj_1 88 local _fn_0 = _base_0.z1
93 local _fn_0 = _base_0.z1 89 return _fn_0 and function(...)
94 return _fn_0 and function(...) 90 return _fn_0(_base_0, ...)
95 return _fn_0(_base_0, ...) 91 end
96 end 92 end)()
97 end)()
98 end
99end 93end
100do 94do
101 local a, b, c = z.a, z.b, z.c 95 local a, b, c = z.a, z.b, z.c
diff --git a/spec/outputs/local.lua b/spec/outputs/local.lua
index 5004e75..5d215e0 100644
--- a/spec/outputs/local.lua
+++ b/spec/outputs/local.lua
@@ -98,50 +98,46 @@ do
98 Five = 6 98 Five = 6
99 One = _class_0 99 One = _class_0
100 end 100 end
101 do 101 local _class_0
102 local _class_0 102 local No
103 local No 103 local _base_0 = { }
104 local _base_0 = { } 104 if _base_0.__index == nil then
105 if _base_0.__index == nil then 105 _base_0.__index = _base_0
106 _base_0.__index = _base_0 106 end
107 end 107 _class_0 = setmetatable({
108 _class_0 = setmetatable({ 108 __init = function() end,
109 __init = function() end, 109 __base = _base_0,
110 __base = _base_0, 110 __name = "Two"
111 __name = "Two" 111 }, {
112 }, { 112 __index = _base_0,
113 __index = _base_0, 113 __call = function(cls, ...)
114 __call = function(cls, ...) 114 local _self_0 = setmetatable({ }, _base_0)
115 local _self_0 = setmetatable({ }, _base_0) 115 cls.__init(_self_0, ...)
116 cls.__init(_self_0, ...) 116 return _self_0
117 return _self_0
118 end
119 })
120 _base_0.__class = _class_0
121 local self = _class_0;
122 do
123 local _class_1
124 local _base_1 = { }
125 if _base_1.__index == nil then
126 _base_1.__index = _base_1
127 end
128 _class_1 = setmetatable({
129 __init = function() end,
130 __base = _base_1,
131 __name = "No"
132 }, {
133 __index = _base_1,
134 __call = function(cls, ...)
135 local _self_0 = setmetatable({ }, _base_1)
136 cls.__init(_self_0, ...)
137 return _self_0
138 end
139 })
140 _base_1.__class = _class_1
141 No = _class_1
142 end 117 end
143 Two = _class_0 118 })
119 _base_0.__class = _class_0
120 local self = _class_0;
121 local _class_1
122 local _base_1 = { }
123 if _base_1.__index == nil then
124 _base_1.__index = _base_1
144 end 125 end
126 _class_1 = setmetatable({
127 __init = function() end,
128 __base = _base_1,
129 __name = "No"
130 }, {
131 __index = _base_1,
132 __call = function(cls, ...)
133 local _self_0 = setmetatable({ }, _base_1)
134 cls.__init(_self_0, ...)
135 return _self_0
136 end
137 })
138 _base_1.__class = _class_1
139 No = _class_1
140 Two = _class_0
145end 141end
146do 142do
147 local _list_0 = { } 143 local _list_0 = { }
diff --git a/spec/outputs/loops.lua b/spec/outputs/loops.lua
index 79ef789..40e27b9 100644
--- a/spec/outputs/loops.lua
+++ b/spec/outputs/loops.lua
@@ -297,17 +297,15 @@ end
297do 297do
298 for i = 1, 10 do 298 for i = 1, 10 do
299 repeat 299 repeat
300 do 300 local _with_0 = tb
301 local _with_0 = tb 301 if _with_0 ~= nil then
302 if _with_0 ~= nil then 302 _with_0.a = 1
303 _with_0.a = 1 303 if _with_0.b then
304 if _with_0.b then 304 goto _continue_12
305 goto _continue_12 305 end
306 end 306 do
307 do 307 if _with_0.c then
308 if _with_0.c then 308 break
309 break
310 end
311 end 309 end
312 end 310 end
313 end 311 end
diff --git a/spec/outputs/macro.lua b/spec/outputs/macro.lua
index f18baed..2ee3e0a 100644
--- a/spec/outputs/macro.lua
+++ b/spec/outputs/macro.lua
@@ -1,4 +1,6 @@
1assert(item == nil) 1do
2 assert(item == nil)
3end
2local v = (item == nil) 4local v = (item == nil)
3if f1() then 5if f1() then
4 print("OK") 6 print("OK")
@@ -9,86 +11,86 @@ end
9local item 11local item
10do 12do
11 local _src_, _dst_ 13 local _src_, _dst_
12 do 14 _dst_ = {
13 _dst_ = { 15 pos = { },
14 pos = { }, 16 flags = flags:tonumber()
15 flags = flags:tonumber() 17 }
16 } 18 _src_ = self
17 do 19 _dst_.id = _src_.id
18 _src_ = self 20 _dst_.connections = _src_.connections
19 _dst_.id = _src_.id 21 _dst_.pos.x = _src_.pos.x
20 _dst_.connections = _src_.connections 22 _dst_.pos.y = _src_.pos.y
21 _dst_.pos.x = _src_.pos.x 23 _dst_.pos.z = _src_.pos.z
22 _dst_.pos.y = _src_.pos.y 24 item = _dst_
23 _dst_.pos.z = _src_.pos.z
24 end
25 item = _dst_
26 end
27end 25end
28if (x == "Apple" or x == "Pig" or x == "Dog") then 26if (x == "Apple" or x == "Pig" or x == "Dog") then
29 print("exist") 27 print("exist")
30end 28end
31local _list_0 = (function() 29do
32 local _accum_0 = { }
33 local _len_0 = 1
34 local _list_0 = (function() 30 local _list_0 = (function()
35 local _accum_1 = { } 31 local _accum_0 = { }
36 local _len_1 = 1 32 local _len_0 = 1
37 local _list_0 = { 33 local _list_0 = (function()
38 1, 34 local _accum_1 = { }
39 2, 35 local _len_1 = 1
40 3 36 local _list_0 = {
41 } 37 1,
38 2,
39 3
40 }
41 for _index_0 = 1, #_list_0 do
42 local _ = _list_0[_index_0]
43 _accum_1[_len_1] = _ * 2
44 _len_1 = _len_1 + 1
45 end
46 return _accum_1
47 end)()
42 for _index_0 = 1, #_list_0 do 48 for _index_0 = 1, #_list_0 do
43 local _ = _list_0[_index_0] 49 local _ = _list_0[_index_0]
44 _accum_1[_len_1] = _ * 2 50 if _ > 4 then
45 _len_1 = _len_1 + 1 51 _accum_0[_len_0] = _
52 _len_0 = _len_0 + 1
53 end
46 end 54 end
47 return _accum_1 55 return _accum_0
48 end)() 56 end)()
49 for _index_0 = 1, #_list_0 do 57 for _index_0 = 1, #_list_0 do
50 local _ = _list_0[_index_0] 58 local _ = _list_0[_index_0]
51 if _ > 4 then 59 print(_)
52 _accum_0[_len_0] = _
53 _len_0 = _len_0 + 1
54 end
55 end 60 end
56 return _accum_0
57end)()
58for _index_0 = 1, #_list_0 do
59 local _ = _list_0[_index_0]
60 print(_)
61end 61end
62local _list_1 = (function() 62do
63 local _accum_0 = { } 63 local _list_0 = (function()
64 local _len_0 = 1 64 local _accum_0 = { }
65 local _list_1 = (function() 65 local _len_0 = 1
66 local _accum_1 = { } 66 local _list_0 = (function()
67 local _len_1 = 1 67 local _accum_1 = { }
68 local _list_1 = { 68 local _len_1 = 1
69 1, 69 local _list_0 = {
70 2, 70 1,
71 3 71 2,
72 } 72 3
73 for _index_0 = 1, #_list_1 do 73 }
74 local _ = _list_1[_index_0] 74 for _index_0 = 1, #_list_0 do
75 _accum_1[_len_1] = _ * 2 75 local _ = _list_0[_index_0]
76 _len_1 = _len_1 + 1 76 _accum_1[_len_1] = _ * 2
77 _len_1 = _len_1 + 1
78 end
79 return _accum_1
80 end)()
81 for _index_0 = 1, #_list_0 do
82 local _ = _list_0[_index_0]
83 if _ > 4 then
84 _accum_0[_len_0] = _
85 _len_0 = _len_0 + 1
86 end
77 end 87 end
78 return _accum_1 88 return _accum_0
79 end)() 89 end)()
80 for _index_0 = 1, #_list_1 do 90 for _index_0 = 1, #_list_0 do
81 local _ = _list_1[_index_0] 91 local _ = _list_0[_index_0]
82 if _ > 4 then 92 print(_)
83 _accum_0[_len_0] = _
84 _len_0 = _len_0 + 1
85 end
86 end 93 end
87 return _accum_0
88end)()
89for _index_0 = 1, #_list_1 do
90 local _ = _list_1[_index_0]
91 print(_)
92end 94end
93local val 95local val
94do 96do
@@ -96,13 +98,13 @@ do
96 do 98 do
97 local _accum_0 = { } 99 local _accum_0 = { }
98 local _len_0 = 1 100 local _len_0 = 1
99 local _list_2 = { 101 local _list_0 = {
100 1, 102 1,
101 2, 103 2,
102 3 104 3
103 } 105 }
104 for _index_0 = 1, #_list_2 do 106 for _index_0 = 1, #_list_0 do
105 local _ = _list_2[_index_0] 107 local _ = _list_0[_index_0]
106 _accum_0[_len_0] = _ * 2 108 _accum_0[_len_0] = _ * 2
107 _len_0 = _len_0 + 1 109 _len_0 = _len_0 + 1
108 end 110 end
@@ -134,7 +136,9 @@ do
134 end 136 end
135 val = _4 137 val = _4
136end 138end
137(1 + 2):call(123) 139do
140 (1 + 2):call(123)
141end
138local res = (1 + 2) 142local res = (1 + 2)
139local f 143local f
140f = function(x) 144f = function(x)
@@ -210,40 +214,44 @@ local a = ((((_({
210 return self * 2 214 return self * 2
211end)):filter(function(self) 215end)):filter(function(self)
212 return self > 3 216 return self > 3
213end)):value(); 217end)):value()
214((((_({ 218do
215 1, 219 ((((_({
216 2, 220 1,
217 3, 221 2,
218 4, 222 3,
219 -2, 223 4,
220 3 224 -2,
221})):chain()):map(function(self) 225 3
222 return self * 2 226 })):chain()):map(function(self)
223end)):filter(function(self) 227 return self * 2
224 return self > 3 228 end)):filter(function(self)
225end)):each(function(self) 229 return self > 3
226 return print(self) 230 end)):each(function(self)
227end) 231 return print(self)
232 end)
233end
228local result = ((((((origin.transform.root.gameObject:Parents()):Descendants()):SelectEnable()):SelectVisible()):TagEqual("fx")):Where(function(x) 234local result = ((((((origin.transform.root.gameObject:Parents()):Descendants()):SelectEnable()):SelectVisible()):TagEqual("fx")):Where(function(x)
229 return x.name:EndsWith("(Clone)") 235 return x.name:EndsWith("(Clone)")
230end)):Destroy() 236end)):Destroy()
231do 237do
232 local _1 238 do
233 _1 = origin.transform.root.gameObject:Parents() 239 local _1
234 local _2 240 _1 = origin.transform.root.gameObject:Parents()
235 _2 = _1:Descendants() 241 local _2
236 local _3 242 _2 = _1:Descendants()
237 _3 = _2:SelectEnable() 243 local _3
238 local _4 244 _3 = _2:SelectEnable()
239 _4 = _3:SelectVisible() 245 local _4
240 local _5 246 _4 = _3:SelectVisible()
241 _5 = _4:TagEqual("fx") 247 local _5
242 local _6 248 _5 = _4:TagEqual("fx")
243 _6 = _5:Where(function(x) 249 local _6
244 return x.name:EndsWith("(Clone)") 250 _6 = _5:Where(function(x)
245 end) 251 return x.name:EndsWith("(Clone)")
246 _6:Destroy() 252 end)
253 _6:Destroy()
254 end
247end 255end
248origin.transform.root.gameObject:Parents():Descendants():SelectEnable():SelectVisible():TagEqual("fx"):Where(function(x) 256origin.transform.root.gameObject:Parents():Descendants():SelectEnable():SelectVisible():TagEqual("fx"):Where(function(x)
249 return x.name:EndsWith("(Clone)") 257 return x.name:EndsWith("(Clone)")
@@ -278,7 +286,9 @@ print((setmetatable({
278 end 286 end
279})) 287}))
280print("current line: " .. tostring(268)) 288print("current line: " .. tostring(268))
289do
281-- TODO 290-- TODO
291end
282do 292do
283 print(1) 293 print(1)
284end 294end
@@ -293,5 +303,7 @@ _1 = function()
293 end 303 end
294 return _accum_0 304 return _accum_0
295end 305end
296print('abc') 306do
297return 123 307 print('abc')
308 return 123
309end
diff --git a/spec/outputs/metatable.lua b/spec/outputs/metatable.lua
index 9f95787..78de433 100644
--- a/spec/outputs/metatable.lua
+++ b/spec/outputs/metatable.lua
@@ -48,19 +48,17 @@ do
48end 48end
49do 49do
50 local x, new, var, close, closeA, num, add, sub 50 local x, new, var, close, closeA, num, add, sub
51 local _obj_0, _obj_1
52 x, _obj_0, _obj_1 = 123, a.b.c, func()
53 new, var = _obj_0.new, _obj_0.var
51 do 54 do
52 local _obj_0, _obj_1 55 local _obj_2 = getmetatable(_obj_0)
53 x, _obj_0, _obj_1 = 123, a.b.c, func() 56 close, closeA = _obj_2.__close, _obj_2.__close
54 new, var = _obj_0.new, _obj_0.var 57 end
55 do 58 num = _obj_1.num
56 local _obj_2 = getmetatable(_obj_0) 59 do
57 close, closeA = _obj_2.__close, _obj_2.__close 60 local _obj_2 = getmetatable(_obj_1)
58 end 61 add, sub = _obj_2.__add, _obj_2.__sub
59 num = _obj_1.num
60 do
61 local _obj_2 = getmetatable(_obj_1)
62 add, sub = _obj_2.__add, _obj_2.__sub
63 end
64 end 62 end
65end 63end
66setmetatable(a.b, { }) 64setmetatable(a.b, { })
diff --git a/spec/outputs/multiline_chain.lua b/spec/outputs/multiline_chain.lua
index 5edad88..ef64906 100644
--- a/spec/outputs/multiline_chain.lua
+++ b/spec/outputs/multiline_chain.lua
@@ -82,15 +82,13 @@ do
82 _with_0:itemMethodC(i) 82 _with_0:itemMethodC(i)
83 end 83 end
84 if not _with_0.b then 84 if not _with_0.b then
85 do 85 local _accum_0 = { }
86 local _accum_0 = { } 86 local _len_0 = 1
87 local _len_0 = 1 87 while _with_0.itemFieldD do
88 while _with_0.itemFieldD do 88 _accum_0[_len_0] = _with_0:itemNext():get()
89 _accum_0[_len_0] = _with_0:itemNext():get() 89 _len_0 = _len_0 + 1
90 _len_0 = _len_0 + 1
91 end
92 _with_0.c = _accum_0
93 end 90 end
91 _with_0.c = _accum_0
94 end 92 end
95end 93end
96return nil 94return nil
diff --git a/spec/outputs/nil_coalescing.lua b/spec/outputs/nil_coalescing.lua
index e1547df..2279853 100644
--- a/spec/outputs/nil_coalescing.lua
+++ b/spec/outputs/nil_coalescing.lua
@@ -1,23 +1,19 @@
1do 1do
2 local a 2 local a
3 do 3 local _exp_0 = b
4 local _exp_0 = b 4 if _exp_0 ~= nil then
5 if _exp_0 ~= nil then 5 a = _exp_0
6 a = _exp_0 6 else
7 else 7 a = c
8 a = c
9 end
10 end 8 end
11end 9end
12do 10do
13 local a 11 local a
14 do 12 local _exp_0 = b
15 local _exp_0 = b 13 if _exp_0 ~= nil then
16 if _exp_0 ~= nil then 14 a = _exp_0.a
17 a = _exp_0.a 15 else
18 else 16 a = c.a
19 a = c.a
20 end
21 end 17 end
22end 18end
23do 19do
@@ -50,23 +46,21 @@ do
50end 46end
51do 47do
52 local a 48 local a
53 do 49 local _exp_0 = b
54 local _exp_0 = b 50 if _exp_0 ~= nil then
55 if _exp_0 ~= nil then 51 a = _exp_0
56 a = _exp_0 52 else
57 else 53 do
58 do 54 local _exp_1 = c
59 local _exp_1 = c 55 if _exp_1 ~= nil then
60 if _exp_1 ~= nil then 56 a = _exp_1
61 a = _exp_1 57 else
62 else 58 do
63 do 59 local _exp_2 = d
64 local _exp_2 = d 60 if _exp_2 ~= nil then
65 if _exp_2 ~= nil then 61 a = _exp_2
66 a = _exp_2 62 else
67 else 63 a = e
68 a = e
69 end
70 end 64 end
71 end 65 end
72 end 66 end
@@ -84,18 +78,14 @@ do
84 end)()) 78 end)())
85end 79end
86do 80do
87 do 81 local _with_0
88 local _with_0 82 local _exp_0 = funcA()
89 do 83 if _exp_0 ~= nil then
90 local _exp_0 = funcA() 84 _with_0 = _exp_0
91 if _exp_0 ~= nil then 85 else
92 _with_0 = _exp_0 86 _with_0 = funcB()
93 else
94 _with_0 = funcB()
95 end
96 end
97 print(_with_0.field)
98 end 87 end
88 print(_with_0.field)
99end 89end
100do 90do
101 local a = 1 + 2 + (function() 91 local a = 1 + 2 + (function()
@@ -137,18 +127,16 @@ do
137end 127end
138do 128do
139 local a 129 local a
140 do 130 local _exp_0 = 1
141 local _exp_0 = 1 131 if _exp_0 ~= nil then
142 if _exp_0 ~= nil then 132 a = _exp_0
143 a = _exp_0 133 else
144 else 134 do
145 do 135 local _exp_1 = 2
146 local _exp_1 = 2 136 if _exp_1 ~= nil then
147 if _exp_1 ~= nil then 137 a = _exp_1
148 a = _exp_1 138 else
149 else 139 a = 3
150 a = 3
151 end
152 end 140 end
153 end 141 end
154 end 142 end
diff --git a/spec/outputs/stub.lua b/spec/outputs/stub.lua
index ff867ba..a3a27e3 100644
--- a/spec/outputs/stub.lua
+++ b/spec/outputs/stub.lua
@@ -15,12 +15,10 @@ end
15print(fn()) 15print(fn())
16print(x:val()); 16print(x:val());
17(function(...) 17(function(...)
18 do 18 local _base_0 = hello(...)
19 local _base_0 = hello(...) 19 local _fn_0 = _base_0.world
20 local _fn_0 = _base_0.world 20 x = _fn_0 and function(...)
21 x = _fn_0 and function(...) 21 return _fn_0(_base_0, ...)
22 return _fn_0(_base_0, ...)
23 end
24 end 22 end
25end)() 23end)()
26return nil 24return nil
diff --git a/spec/outputs/switch.lua b/spec/outputs/switch.lua
index bbdf794..e4dedc9 100644
--- a/spec/outputs/switch.lua
+++ b/spec/outputs/switch.lua
@@ -45,13 +45,11 @@ do
45end 45end
46do 46do
47 local _with_0 = something 47 local _with_0 = something
48 do 48 local _exp_0 = _with_0:value()
49 local _exp_0 = _with_0:value() 49 if _with_0.okay == _exp_0 then
50 if _with_0.okay == _exp_0 then 50 local _ = "world"
51 local _ = "world" 51 else
52 else 52 local _ = "yesh"
53 local _ = "yesh"
54 end
55 end 53 end
56end 54end
57fix(this) 55fix(this)
@@ -106,66 +104,64 @@ do
106 } 104 }
107 } 105 }
108 } 106 }
109 do 107 local _type_0 = type(dict)
110 local _type_0 = type(dict) 108 local _tab_0 = "table" == _type_0 or "userdata" == _type_0
111 local _tab_0 = "table" == _type_0 or "userdata" == _type_0 109 if _tab_0 then
112 if _tab_0 then 110 local first = dict[1]
113 local first = dict[1] 111 local one
114 local one 112 do
115 do 113 local _obj_0 = dict[2]
116 local _obj_0 = dict[2] 114 local _type_1 = type(_obj_0)
117 local _type_1 = type(_obj_0) 115 if "table" == _type_1 or "userdata" == _type_1 then
118 if "table" == _type_1 or "userdata" == _type_1 then 116 one = _obj_0[1]
119 one = _obj_0[1]
120 end
121 end 117 end
122 local two 118 end
123 do 119 local two
124 local _obj_0 = dict[2] 120 do
125 local _type_1 = type(_obj_0) 121 local _obj_0 = dict[2]
126 if "table" == _type_1 or "userdata" == _type_1 then 122 local _type_1 = type(_obj_0)
127 two = _obj_0[2] 123 if "table" == _type_1 or "userdata" == _type_1 then
128 end 124 two = _obj_0[2]
129 end 125 end
130 local three 126 end
131 do 127 local three
132 local _obj_0 = dict[2] 128 do
133 local _type_1 = type(_obj_0) 129 local _obj_0 = dict[2]
134 if "table" == _type_1 or "userdata" == _type_1 then 130 local _type_1 = type(_obj_0)
135 three = _obj_0[3] 131 if "table" == _type_1 or "userdata" == _type_1 then
136 end 132 three = _obj_0[3]
137 end 133 end
138 local c 134 end
139 do 135 local c
140 local _obj_0 = dict.a 136 do
141 local _type_1 = type(_obj_0) 137 local _obj_0 = dict.a
142 if "table" == _type_1 or "userdata" == _type_1 then 138 local _type_1 = type(_obj_0)
143 do 139 if "table" == _type_1 or "userdata" == _type_1 then
144 local _obj_1 = _obj_0.b 140 do
145 local _type_2 = type(_obj_1) 141 local _obj_1 = _obj_0.b
146 if "table" == _type_2 or "userdata" == _type_2 then 142 local _type_2 = type(_obj_1)
147 c = _obj_1.c 143 if "table" == _type_2 or "userdata" == _type_2 then
148 end 144 c = _obj_1.c
149 end 145 end
150 end 146 end
151 end 147 end
152 local z 148 end
153 do 149 local z
154 local _obj_0 = dict.x 150 do
155 local _type_1 = type(_obj_0) 151 local _obj_0 = dict.x
156 if "table" == _type_1 or "userdata" == _type_1 then 152 local _type_1 = type(_obj_0)
157 do 153 if "table" == _type_1 or "userdata" == _type_1 then
158 local _obj_1 = _obj_0.y 154 do
159 local _type_2 = type(_obj_1) 155 local _obj_1 = _obj_0.y
160 if "table" == _type_2 or "userdata" == _type_2 then 156 local _type_2 = type(_obj_1)
161 z = _obj_1.z 157 if "table" == _type_2 or "userdata" == _type_2 then
162 end 158 z = _obj_1.z
163 end 159 end
164 end 160 end
165 end 161 end
166 if first ~= nil and one ~= nil and two ~= nil and three ~= nil and c ~= nil and z ~= nil then 162 end
167 print(first, one, two, three, c, z) 163 if first ~= nil and one ~= nil and two ~= nil and three ~= nil and c ~= nil and z ~= nil then
168 end 164 print(first, one, two, three, c, z)
169 end 165 end
170 end 166 end
171end 167end
@@ -183,56 +179,54 @@ do
183 } 179 }
184 for _index_0 = 1, #items do 180 for _index_0 = 1, #items do
185 local item = items[_index_0] 181 local item = items[_index_0]
186 do 182 local _type_0 = type(item)
187 local _type_0 = type(item) 183 local _tab_0 = "table" == _type_0 or "userdata" == _type_0
188 local _tab_0 = "table" == _type_0 or "userdata" == _type_0 184 local _match_0 = false
189 local _match_0 = false 185 if _tab_0 then
186 local x = item.x
187 local y = item.y
188 if x ~= nil and y ~= nil then
189 _match_0 = true
190 print("Vec2 " .. tostring(x) .. ", " .. tostring(y))
191 end
192 end
193 if not _match_0 then
194 local _match_1 = false
190 if _tab_0 then 195 if _tab_0 then
191 local x = item.x 196 local width = item.width
192 local y = item.y 197 local height = item.height
193 if x ~= nil and y ~= nil then 198 if width ~= nil and height ~= nil then
194 _match_0 = true 199 _match_1 = true
195 print("Vec2 " .. tostring(x) .. ", " .. tostring(y)) 200 print("Size " .. tostring(width) .. ", " .. tostring(height))
196 end 201 end
197 end 202 end
198 if not _match_0 then 203 if not _match_1 then
199 local _match_1 = false 204 if false == item then
200 if _tab_0 then 205 print("None")
201 local width = item.width 206 else
202 local height = item.height 207 local _match_2 = false
203 if width ~= nil and height ~= nil then 208 if _tab_0 then
204 _match_1 = true 209 local cls = item.__class
205 print("Size " .. tostring(width) .. ", " .. tostring(height)) 210 if cls ~= nil then
211 _match_2 = true
212 if ClassA == cls then
213 print("Object A")
214 elseif ClassB == cls then
215 print("Object B")
216 end
217 end
206 end 218 end
207 end 219 if not _match_2 then
208 if not _match_1 then 220 local _match_3 = false
209 if false == item then
210 print("None")
211 else
212 local _match_2 = false
213 if _tab_0 then 221 if _tab_0 then
214 local cls = item.__class 222 local mt = getmetatable(item)
215 if cls ~= nil then 223 if mt ~= nil then
216 _match_2 = true 224 _match_3 = true
217 if ClassA == cls then 225 print("A table with metatable")
218 print("Object A")
219 elseif ClassB == cls then
220 print("Object B")
221 end
222 end 226 end
223 end 227 end
224 if not _match_2 then 228 if not _match_3 then
225 local _match_3 = false 229 print("item not accepted!")
226 if _tab_0 then
227 local mt = getmetatable(item)
228 if mt ~= nil then
229 _match_3 = true
230 print("A table with metatable")
231 end
232 end
233 if not _match_3 then
234 print("item not accepted!")
235 end
236 end 230 end
237 end 231 end
238 end 232 end
@@ -271,72 +265,66 @@ do
271 end 265 end
272 end 266 end
273 end 267 end
274 do 268 local _type_0 = type(tb)
275 local _type_0 = type(tb) 269 local _tab_0 = "table" == _type_0 or "userdata" == _type_0
276 local _tab_0 = "table" == _type_0 or "userdata" == _type_0 270 local _match_0 = false
277 local _match_0 = false 271 if _tab_0 then
278 if _tab_0 then 272 local a = tb.a
279 local a = tb.a 273 local b = tb.b
280 local b = tb.b 274 if a ~= nil and b ~= nil then
281 if a ~= nil and b ~= nil then 275 _match_0 = true
282 _match_0 = true 276 print(a, b)
283 print(a, b)
284 end
285 end
286 if not _match_0 then
287 print("not matched")
288 end 277 end
289 end 278 end
279 if not _match_0 then
280 print("not matched")
281 end
290end 282end
291do 283do
292 local tb = { 284 local tb = {
293 x = "abc" 285 x = "abc"
294 } 286 }
295 do 287 local _type_0 = type(tb)
296 local _type_0 = type(tb) 288 local _tab_0 = "table" == _type_0 or "userdata" == _type_0
297 local _tab_0 = "table" == _type_0 or "userdata" == _type_0 289 local _match_0 = false
298 local _match_0 = false 290 if _tab_0 then
291 local x = tb.x
292 local y = tb.y
293 if x ~= nil and y ~= nil then
294 _match_0 = true
295 print("x: " .. tostring(x) .. " with y: " .. tostring(y))
296 end
297 end
298 if not _match_0 then
299 if _tab_0 then 299 if _tab_0 then
300 local x = tb.x 300 local x = tb.x
301 local y = tb.y 301 if x ~= nil then
302 if x ~= nil and y ~= nil then 302 print("x: " .. tostring(x) .. " only")
303 _match_0 = true
304 print("x: " .. tostring(x) .. " with y: " .. tostring(y))
305 end
306 end
307 if not _match_0 then
308 if _tab_0 then
309 local x = tb.x
310 if x ~= nil then
311 print("x: " .. tostring(x) .. " only")
312 end
313 end 303 end
314 end 304 end
315 end 305 end
316end 306end
317do 307do
318 local matched 308 local matched
319 do 309 local _exp_0 = tb
320 local _exp_0 = tb 310 if 1 == _exp_0 then
321 if 1 == _exp_0 then 311 matched = "1"
322 matched = "1" 312 else
323 else 313 local _type_0 = type(_exp_0)
324 local _type_0 = type(_exp_0) 314 local _tab_0 = "table" == _type_0 or "userdata" == _type_0
325 local _tab_0 = "table" == _type_0 or "userdata" == _type_0 315 local _match_0 = false
326 local _match_0 = false 316 if _tab_0 then
327 if _tab_0 then 317 local x = _exp_0.x
328 local x = _exp_0.x 318 if x ~= nil then
329 if x ~= nil then 319 _match_0 = true
330 _match_0 = true 320 matched = x
331 matched = x
332 end
333 end 321 end
334 if not _match_0 then 322 end
335 if false == _exp_0 then 323 if not _match_0 then
336 matched = "false" 324 if false == _exp_0 then
337 else 325 matched = "false"
338 matched = nil 326 else
339 end 327 matched = nil
340 end 328 end
341 end 329 end
342 end 330 end
@@ -346,90 +334,84 @@ do
346 if nil == _exp_0 then 334 if nil == _exp_0 then
347 return "invalid" 335 return "invalid"
348 else 336 else
349 do 337 local _type_0 = type(_exp_0)
350 local _type_0 = type(_exp_0) 338 local _tab_0 = "table" == _type_0 or "userdata" == _type_0
351 local _tab_0 = "table" == _type_0 or "userdata" == _type_0 339 local _match_0 = false
352 local _match_0 = false 340 if _tab_0 then
353 if _tab_0 then 341 local a = _exp_0.a
354 local a = _exp_0.a 342 local b = _exp_0.b
355 local b = _exp_0.b 343 if a ~= nil and b ~= nil then
356 if a ~= nil and b ~= nil then 344 _match_0 = true
357 _match_0 = true 345 return tostring(a + b)
358 return tostring(a + b)
359 end
360 end 346 end
361 if not _match_0 then 347 end
362 if 1 == _exp_0 or 2 == _exp_0 or 3 == _exp_0 or 4 == _exp_0 or 5 == _exp_0 then 348 if not _match_0 then
363 return "number 1 - 5" 349 if 1 == _exp_0 or 2 == _exp_0 or 3 == _exp_0 or 4 == _exp_0 or 5 == _exp_0 then
364 else 350 return "number 1 - 5"
365 local _match_1 = false 351 else
366 if _tab_0 then 352 local _match_1 = false
367 local matchAnyTable = _exp_0.matchAnyTable 353 if _tab_0 then
368 if matchAnyTable == nil then 354 local matchAnyTable = _exp_0.matchAnyTable
369 matchAnyTable = "fallback" 355 if matchAnyTable == nil then
370 end 356 matchAnyTable = "fallback"
371 _match_1 = true
372 return matchAnyTable
373 end
374 if not _match_1 then
375 return "should not reach here unless it is not a table"
376 end 357 end
358 _match_1 = true
359 return matchAnyTable
360 end
361 if not _match_1 then
362 return "should not reach here unless it is not a table"
377 end 363 end
378 end 364 end
379 end 365 end
380 end 366 end
381end 367end
382do 368do
383 do 369 local _exp_0 = y
384 local _exp_0 = y 370 local _type_0 = type(_exp_0)
385 local _type_0 = type(_exp_0) 371 local _tab_0 = "table" == _type_0 or "userdata" == _type_0
386 local _tab_0 = "table" == _type_0 or "userdata" == _type_0 372 if _tab_0 then
387 if _tab_0 then 373 local mt = (function()
388 local mt = (function() 374 local _obj_0 = _exp_0.x
389 local _obj_0 = _exp_0.x 375 if _obj_0 ~= nil then
390 if _obj_0 ~= nil then 376 return getmetatable(_obj_0)
391 return getmetatable(_obj_0)
392 end
393 return nil
394 end)()
395 if mt ~= nil then
396 print(mt)
397 end 377 end
378 return nil
379 end)()
380 if mt ~= nil then
381 print(mt)
398 end 382 end
399 end 383 end
400end 384end
401do 385do
402 do 386 local _exp_0 = tb
403 local _exp_0 = tb 387 local _type_0 = type(_exp_0)
404 local _type_0 = type(_exp_0) 388 local _tab_0 = "table" == _type_0 or "userdata" == _type_0
405 local _tab_0 = "table" == _type_0 or "userdata" == _type_0 389 local _match_0 = false
406 local _match_0 = false 390 if _tab_0 then
407 if _tab_0 then 391 local item
408 local item 392 do
409 do 393 local _obj_0 = _exp_0[1]
410 local _obj_0 = _exp_0[1] 394 local _type_1 = type(_obj_0)
411 local _type_1 = type(_obj_0) 395 if "table" == _type_1 or "userdata" == _type_1 then
412 if "table" == _type_1 or "userdata" == _type_1 then 396 item = _obj_0[1]
413 item = _obj_0[1]
414 end
415 end
416 if item ~= nil then
417 _match_0 = true
418 print(item)
419 end 397 end
420 end 398 end
421 if not _match_0 then 399 if item ~= nil then
422 if _tab_0 then 400 _match_0 = true
423 local a = _exp_0[1] 401 print(item)
424 local b = _exp_0[2] 402 end
425 if a == nil then 403 end
426 a = 1 404 if not _match_0 then
427 end 405 if _tab_0 then
428 if b == nil then 406 local a = _exp_0[1]
429 b = "abc" 407 local b = _exp_0[2]
430 end 408 if a == nil then
431 print(a, b) 409 a = 1
410 end
411 if b == nil then
412 b = "abc"
432 end 413 end
414 print(a, b)
433 end 415 end
434 end 416 end
435end 417end
diff --git a/spec/outputs/syntax.lua b/spec/outputs/syntax.lua
index 20b8469..cfe63eb 100644
--- a/spec/outputs/syntax.lua
+++ b/spec/outputs/syntax.lua
@@ -217,15 +217,11 @@ else
217end 217end
218do 218do
219 local _with_0 = tb 219 local _with_0 = tb
220 do 220 local _obj_2 = _with_0.b.c
221 local _obj_2 = _with_0.b.c 221 local _with_1 = vec
222 do 222 _with_1.x = 1
223 local _with_1 = vec 223 _with_1.y = 2
224 _with_1.x = 1 224 _obj_2[#_obj_2 + 1] = _with_1
225 _with_1.y = 2
226 _obj_2[#_obj_2 + 1] = _with_1
227 end
228 end
229end 225end
230do 226do
231 local _obj_2 = a.b.c.d:f().g 227 local _obj_2 = a.b.c.d:f().g
diff --git a/spec/outputs/tables.lua b/spec/outputs/tables.lua
index 911f677..f358811 100644
--- a/spec/outputs/tables.lua
+++ b/spec/outputs/tables.lua
@@ -430,157 +430,141 @@ do
430end 430end
431do 431do
432 local tbMixA 432 local tbMixA
433 do 433 local _tab_0 = { }
434 local _tab_0 = { } 434 local _obj_0
435 local _obj_0 435 local _accum_0 = { }
436 do 436 local _len_0 = 1
437 local _accum_0 = { } 437 for i = 1, 10 do
438 local _len_0 = 1 438 _accum_0[_len_0] = i
439 for i = 1, 10 do 439 _len_0 = _len_0 + 1
440 _accum_0[_len_0] = i 440 end
441 _len_0 = _len_0 + 1 441 _obj_0 = _accum_0
442 end 442 local _idx_0 = 1
443 _obj_0 = _accum_0 443 for _key_0, _value_0 in pairs(_obj_0) do
444 end 444 if _idx_0 == _key_0 then
445 local _idx_0 = 1 445 _tab_0[#_tab_0 + 1] = _value_0
446 for _key_0, _value_0 in pairs(_obj_0) do 446 _idx_0 = _idx_0 + 1
447 if _idx_0 == _key_0 then 447 else
448 _tab_0[#_tab_0 + 1] = _value_0 448 _tab_0[_key_0] = _value_0
449 _idx_0 = _idx_0 + 1
450 else
451 _tab_0[_key_0] = _value_0
452 end
453 end 449 end
454 _tab_0[#_tab_0 + 1] = 11
455 tbMixA = _tab_0
456 end 450 end
451 _tab_0[#_tab_0 + 1] = 11
452 tbMixA = _tab_0
457end 453end
458do 454do
459 local tbMixA 455 local tbMixA
460 do 456 local _tab_0 = { }
461 local _tab_0 = { } 457 local _obj_0
462 local _obj_0 458 local _accum_0 = { }
463 do 459 local _len_0 = 1
464 local _accum_0 = { } 460 for i = 1, 10 do
465 local _len_0 = 1 461 _accum_0[_len_0] = i
466 for i = 1, 10 do 462 _len_0 = _len_0 + 1
467 _accum_0[_len_0] = i 463 end
468 _len_0 = _len_0 + 1 464 _obj_0 = _accum_0
469 end 465 local _idx_0 = #_tab_0 + 1
470 _obj_0 = _accum_0 466 for _index_0 = 1, #_obj_0 do
471 end 467 local _value_0 = _obj_0[_index_0]
472 local _idx_0 = #_tab_0 + 1 468 _tab_0[_idx_0] = _value_0
473 for _index_0 = 1, #_obj_0 do 469 _idx_0 = _idx_0 + 1
474 local _value_0 = _obj_0[_index_0]
475 _tab_0[_idx_0] = _value_0
476 _idx_0 = _idx_0 + 1
477 end
478 _tab_0[#_tab_0 + 1] = 11
479 tbMixA = _tab_0
480 end 470 end
471 _tab_0[#_tab_0 + 1] = 11
472 tbMixA = _tab_0
481end 473end
482do 474do
483 local tbMixB 475 local tbMixB
484 do 476 local _tab_0 = { }
485 local _tab_0 = { } 477 local _obj_0 = ...
486 local _obj_0 = ... 478 local _idx_0 = 1
487 local _idx_0 = 1 479 for _key_0, _value_0 in pairs(_obj_0) do
488 for _key_0, _value_0 in pairs(_obj_0) do 480 if _idx_0 == _key_0 then
489 if _idx_0 == _key_0 then 481 _tab_0[#_tab_0 + 1] = _value_0
490 _tab_0[#_tab_0 + 1] = _value_0 482 _idx_0 = _idx_0 + 1
491 _idx_0 = _idx_0 + 1 483 else
492 else 484 _tab_0[_key_0] = _value_0
493 _tab_0[_key_0] = _value_0
494 end
495 end 485 end
496 local _obj_1 = { 486 end
497 ... 487 local _obj_1 = {
498 } 488 ...
499 local _idx_1 = 1 489 }
500 for _key_0, _value_0 in pairs(_obj_1) do 490 local _idx_1 = 1
501 if _idx_1 == _key_0 then 491 for _key_0, _value_0 in pairs(_obj_1) do
502 _tab_0[#_tab_0 + 1] = _value_0 492 if _idx_1 == _key_0 then
503 _idx_1 = _idx_1 + 1 493 _tab_0[#_tab_0 + 1] = _value_0
504 else 494 _idx_1 = _idx_1 + 1
505 _tab_0[_key_0] = _value_0 495 else
506 end 496 _tab_0[_key_0] = _value_0
507 end 497 end
508 local _obj_2 498 end
509 do 499 local _obj_2
510 local _tab_1 = { } 500 local _tab_1 = { }
511 local _obj_3 = ... 501 local _obj_3 = ...
512 local _idx_2 = 1 502 local _idx_2 = 1
513 for _key_0, _value_0 in pairs(_obj_3) do 503 for _key_0, _value_0 in pairs(_obj_3) do
514 if _idx_2 == _key_0 then 504 if _idx_2 == _key_0 then
515 _tab_1[#_tab_1 + 1] = _value_0 505 _tab_1[#_tab_1 + 1] = _value_0
516 _idx_2 = _idx_2 + 1 506 _idx_2 = _idx_2 + 1
517 else 507 else
518 _tab_1[_key_0] = _value_0 508 _tab_1[_key_0] = _value_0
519 end
520 end
521 _obj_2 = _tab_1
522 end 509 end
523 local _idx_2 = 1 510 end
524 for _key_0, _value_0 in pairs(_obj_2) do 511 _obj_2 = _tab_1
525 if _idx_2 == _key_0 then 512 local _idx_2 = 1
526 _tab_0[#_tab_0 + 1] = _value_0 513 for _key_0, _value_0 in pairs(_obj_2) do
527 _idx_2 = _idx_2 + 1 514 if _idx_2 == _key_0 then
528 else 515 _tab_0[#_tab_0 + 1] = _value_0
529 _tab_0[_key_0] = _value_0 516 _idx_2 = _idx_2 + 1
530 end 517 else
518 _tab_0[_key_0] = _value_0
531 end 519 end
532 _tab_0[#_tab_0 + 1] = 1
533 _tab_0[#_tab_0 + 1] = 2
534 _tab_0[#_tab_0 + 1] = 3
535 tbMixB = _tab_0
536 end 520 end
521 _tab_0[#_tab_0 + 1] = 1
522 _tab_0[#_tab_0 + 1] = 2
523 _tab_0[#_tab_0 + 1] = 3
524 tbMixB = _tab_0
537end 525end
538do 526do
539 local tbMixB 527 local tbMixB
540 do 528 local _tab_0 = { }
541 local _tab_0 = { } 529 local _obj_0 = ...
542 local _obj_0 = ... 530 local _idx_0 = #_tab_0 + 1
543 local _idx_0 = #_tab_0 + 1 531 for _index_0 = 1, #_obj_0 do
544 for _index_0 = 1, #_obj_0 do 532 local _value_0 = _obj_0[_index_0]
545 local _value_0 = _obj_0[_index_0] 533 _tab_0[_idx_0] = _value_0
546 _tab_0[_idx_0] = _value_0 534 _idx_0 = _idx_0 + 1
547 _idx_0 = _idx_0 + 1 535 end
548 end 536 local _obj_1 = {
549 local _obj_1 = { 537 ...
550 ... 538 }
551 } 539 local _idx_1 = #_tab_0 + 1
552 local _idx_1 = #_tab_0 + 1 540 for _index_0 = 1, #_obj_1 do
553 for _index_0 = 1, #_obj_1 do 541 local _value_0 = _obj_1[_index_0]
554 local _value_0 = _obj_1[_index_0] 542 _tab_0[_idx_1] = _value_0
555 _tab_0[_idx_1] = _value_0 543 _idx_1 = _idx_1 + 1
556 _idx_1 = _idx_1 + 1 544 end
557 end 545 local _obj_2
558 local _obj_2 546 local _tab_1 = { }
559 do 547 local _obj_3 = ...
560 local _tab_1 = { } 548 local _idx_2 = 1
561 local _obj_3 = ... 549 for _key_0, _value_0 in pairs(_obj_3) do
562 local _idx_2 = 1 550 if _idx_2 == _key_0 then
563 for _key_0, _value_0 in pairs(_obj_3) do 551 _tab_1[#_tab_1 + 1] = _value_0
564 if _idx_2 == _key_0 then
565 _tab_1[#_tab_1 + 1] = _value_0
566 _idx_2 = _idx_2 + 1
567 else
568 _tab_1[_key_0] = _value_0
569 end
570 end
571 _obj_2 = _tab_1
572 end
573 local _idx_2 = #_tab_0 + 1
574 for _index_0 = 1, #_obj_2 do
575 local _value_0 = _obj_2[_index_0]
576 _tab_0[_idx_2] = _value_0
577 _idx_2 = _idx_2 + 1 552 _idx_2 = _idx_2 + 1
553 else
554 _tab_1[_key_0] = _value_0
578 end 555 end
579 _tab_0[#_tab_0 + 1] = 1
580 _tab_0[#_tab_0 + 1] = 2
581 _tab_0[#_tab_0 + 1] = 3
582 tbMixB = _tab_0
583 end 556 end
557 _obj_2 = _tab_1
558 local _idx_2 = #_tab_0 + 1
559 for _index_0 = 1, #_obj_2 do
560 local _value_0 = _obj_2[_index_0]
561 _tab_0[_idx_2] = _value_0
562 _idx_2 = _idx_2 + 1
563 end
564 _tab_0[#_tab_0 + 1] = 1
565 _tab_0[#_tab_0 + 1] = 2
566 _tab_0[#_tab_0 + 1] = 3
567 tbMixB = _tab_0
584end 568end
585local template <const> = { 569local template <const> = {
586 foo = "Hello", 570 foo = "Hello",
diff --git a/spec/outputs/test/format_spec.lua b/spec/outputs/test/format_spec.lua
index 33a85f2..ed0fbee 100644
--- a/spec/outputs/test/format_spec.lua
+++ b/spec/outputs/test/format_spec.lua
@@ -101,16 +101,14 @@ rewriteLineCol = function(item)
101 item[2] = 0 101 item[2] = 0
102 item[3] = 0 102 item[3] = 0
103 for i = 4, #item do 103 for i = 4, #item do
104 do 104 local _exp_0 = type(item[i])
105 local _exp_0 = type(item[i]) 105 if "table" == _exp_0 then
106 if "table" == _exp_0 then 106 if item[i][1] == "comment" then
107 if item[i][1] == "comment" then 107 table.remove(item, i)
108 table.remove(item, i) 108 rewriteLineCol(item)
109 rewriteLineCol(item) 109 return
110 return
111 end
112 rewriteLineCol(item[i])
113 end 110 end
111 rewriteLineCol(item[i])
114 end 112 end
115 end 113 end
116end 114end
diff --git a/spec/outputs/unicode/ambiguous.lua b/spec/outputs/unicode/ambiguous.lua
index 3783026..ac90016 100644
--- a/spec/outputs/unicode/ambiguous.lua
+++ b/spec/outputs/unicode/ambiguous.lua
@@ -13,11 +13,17 @@ _u53d8_u91cfa, _u53d8_u91cfb = _u53d8_u91cfc, _u53d8_u91cfd;
13(_u53d8_u91cfd(_u53d8_u91cfa))(_u53d8_u91cfc) 13(_u53d8_u91cfd(_u53d8_u91cfa))(_u53d8_u91cfc)
14for _u8ba1_u6570 = 1, 10 do 14for _u8ba1_u6570 = 1, 10 do
15 _u53d8_u91cfa = function() end 15 _u53d8_u91cfa = function() end
16 (_u6253_u5370)(1) 16 do
17 _u53d8_u91cfa = _u53d8_u91cff; 17 (_u6253_u5370)(1)
18 (_u6253_u5370)(2) 18 end
19 _u53d8_u91cfa = _u53d8_u91cff
20 do
21 (_u6253_u5370)(2)
22 end
19 if _u6761_u4ef6 then 23 if _u6761_u4ef6 then
20 (_u6253_u5370)(3) 24 do
25 (_u6253_u5370)(3)
26 end
21 end 27 end
22 ::_u8df3_u8f6c_u4f4d_u7f6e::; 28 ::_u8df3_u8f6c_u4f4d_u7f6e::;
23 (_u6253_u5370)(4) 29 (_u6253_u5370)(4)
@@ -40,7 +46,9 @@ do
40 end) 46 end)
41end 47end
42do 48do
43 _u6253_u5370(123) 49 do
50 _u6253_u5370(123)
51 end
44end 52end
45do 53do
46 _u51fd_u6570f({ 54 _u51fd_u6570f({
@@ -97,18 +105,16 @@ do
97 _u6570_u5b57_u6570_u7ec4 = _accum_0 105 _u6570_u5b57_u6570_u7ec4 = _accum_0
98 end 106 end
99 local _u5bf9_u8c61_u6570_u7ec4 107 local _u5bf9_u8c61_u6570_u7ec4
100 do 108 local _accum_0 = { }
101 local _accum_0 = { } 109 local _len_0 = 1
102 local _len_0 = 1 110 local _list_0 = _u7269_u4ef6_u6570_u7ec4
103 local _list_0 = _u7269_u4ef6_u6570_u7ec4 111 for _index_0 = 1, #_list_0 do
104 for _index_0 = 1, #_list_0 do 112 local _u7269_u4ef6 = _list_0[_index_0]
105 local _u7269_u4ef6 = _list_0[_index_0] 113 _accum_0[_len_0] = {
106 _accum_0[_len_0] = { 114 ["å称"] = _u7269_u4ef6
107 ["å称"] = _u7269_u4ef6 115 }
108 } 116 _len_0 = _len_0 + 1
109 _len_0 = _len_0 + 1
110 end
111 _u5bf9_u8c61_u6570_u7ec4 = _accum_0
112 end 117 end
118 _u5bf9_u8c61_u6570_u7ec4 = _accum_0
113end 119end
114return nil 120return nil
diff --git a/spec/outputs/unicode/assign.lua b/spec/outputs/unicode/assign.lua
index 290b248..16ece1a 100644
--- a/spec/outputs/unicode/assign.lua
+++ b/spec/outputs/unicode/assign.lua
@@ -52,18 +52,16 @@ return __u65e0_u6548_u53d8_u91cf(function()
52 setmetatable(a_u53d8_u91cf, _anon_func_0(_u6253_u5370)) 52 setmetatable(a_u53d8_u91cf, _anon_func_0(_u6253_u5370))
53 do 53 do
54 local _u5143_u7d20a, _u5143_u7d20b 54 local _u5143_u7d20a, _u5143_u7d20b
55 do 55 local _exp_0 = _u5bf9_u8c61c
56 local _exp_0 = _u5bf9_u8c61c 56 if "a" == _exp_0 then
57 if "a" == _exp_0 then 57 do
58 do 58 local _obj_0 = _u5b57_u5178
59 local _obj_0 = _u5b57_u5178 59 _u5143_u7d20a, _u5143_u7d20b = _obj_0[1], _obj_0[2]
60 _u5143_u7d20a, _u5143_u7d20b = _obj_0[1], _obj_0[2] 60 end
61 end 61 elseif "b" == _exp_0 then
62 elseif "b" == _exp_0 then 62 do
63 do 63 local _obj_0 = _u51fd_u6570()
64 local _obj_0 = _u51fd_u6570() 64 _u5143_u7d20a, _u5143_u7d20b = _obj_0[1], _obj_0[2]
65 _u5143_u7d20a, _u5143_u7d20b = _obj_0[1], _obj_0[2]
66 end
67 end 65 end
68 end 66 end
69 end 67 end
@@ -78,15 +76,11 @@ return __u65e0_u6548_u53d8_u91cf(function()
78 do 76 do
79 local _u53d8_u91cfa 77 local _u53d8_u91cfa
80 if x_u6761_u4ef6 then 78 if x_u6761_u4ef6 then
81 do 79 local _exp_0 = _u5bf9_u8c61y
82 local _exp_0 = _u5bf9_u8c61y 80 if 1 == _exp_0 then
83 if 1 == _exp_0 then 81 local _obj_0, _obj_1 = _u51fd_u6570()
84 do 82 _u53d8_u91cfb[#_u53d8_u91cfb + 1] = _obj_1
85 local _obj_0, _obj_1 = _u51fd_u6570() 83 _u53d8_u91cfa = _obj_0
86 _u53d8_u91cfb[#_u53d8_u91cfb + 1] = _obj_1
87 _u53d8_u91cfa = _obj_0
88 end
89 end
90 end 84 end
91 end 85 end
92 end 86 end
@@ -94,11 +88,9 @@ return __u65e0_u6548_u53d8_u91cf(function()
94 local _u53d8_u91cfa 88 local _u53d8_u91cfa
95 local _u5143_u7d20b 89 local _u5143_u7d20b
96 if x_u6761_u4ef6 then 90 if x_u6761_u4ef6 then
97 do 91 local _obj_0, _obj_1 = _u51fd_u6570()
98 local _obj_0, _obj_1 = _u51fd_u6570() 92 _u53d8_u91cfa = _obj_0
99 _u53d8_u91cfa = _obj_0 93 _u5143_u7d20b = _obj_1[1]
100 _u5143_u7d20b = _obj_1[1]
101 end
102 else 94 else
103 _u53d8_u91cfa = 123 95 _u53d8_u91cfa = 123
104 _u5143_u7d20b = _u8868[1] 96 _u5143_u7d20b = _u8868[1]
@@ -107,42 +99,28 @@ return __u65e0_u6548_u53d8_u91cf(function()
107 do 99 do
108 local _u53d8_u91cfa, _u5bf9_u8c61c 100 local _u53d8_u91cfa, _u5bf9_u8c61c
109 if _u6761_u4ef6x then 101 if _u6761_u4ef6x then
110 do 102 local _exp_0 = _u5bf9_u8c61y
111 local _exp_0 = _u5bf9_u8c61y 103 if 1 == _exp_0 then
112 if 1 == _exp_0 then 104 local _obj_0, _obj_1, _obj_2, _obj_3 = _u51fd_u6570()
113 do 105 local _obj_4 = _u6570_u7ec4b
114 local _obj_0, _obj_1, _obj_2, _obj_3 = _u51fd_u6570() 106 _obj_4[#_obj_4 + 1] = _obj_1
115 do 107 _u53d8_u91cfa, _u5bf9_u8c61c, getmetatable(_u5bf9_u8c61d).__add = _obj_0, _obj_2, _obj_3
116 local _obj_4 = _u6570_u7ec4b
117 _obj_4[#_obj_4 + 1] = _obj_1
118 end
119 _u53d8_u91cfa, _u5bf9_u8c61c, getmetatable(_u5bf9_u8c61d).__add = _obj_0, _obj_2, _obj_3
120 end
121 end
122 end 108 end
123 elseif _u6761_u4ef6x2 then 109 elseif _u6761_u4ef6x2 then
124 if _u6761_u4ef6y2 then 110 if _u6761_u4ef6y2 then
125 do 111 local _obj_0, _obj_1, _obj_2, _obj_3 = _u51fd_u65701()
126 local _obj_0, _obj_1, _obj_2, _obj_3 = _u51fd_u65701() 112 local _obj_4 = _u6570_u7ec4b
127 do 113 _obj_4[#_obj_4 + 1] = _obj_1
128 local _obj_4 = _u6570_u7ec4b 114 _u53d8_u91cfa, _u5bf9_u8c61c, getmetatable(_u5bf9_u8c61d).__add = _obj_0, _obj_2, _obj_3
129 _obj_4[#_obj_4 + 1] = _obj_1
130 end
131 _u53d8_u91cfa, _u5bf9_u8c61c, getmetatable(_u5bf9_u8c61d).__add = _obj_0, _obj_2, _obj_3
132 end
133 end 115 end
134 else 116 else
135 _u6253_u5370("hello") 117 _u6253_u5370("hello")
136 do 118 do
137 _u6253_u5370(123) 119 _u6253_u5370(123)
138 do 120 local _obj_0, _obj_1, _obj_2 = _u51fd_u65702()
139 local _obj_0, _obj_1, _obj_2 = _u51fd_u65702() 121 local _obj_3 = _u6570_u7ec4b
140 do 122 _obj_3[#_obj_3 + 1] = _obj_0
141 local _obj_3 = _u6570_u7ec4b 123 _u53d8_u91cfa, _u5bf9_u8c61c, getmetatable(_u5bf9_u8c61d).__add = 1, _obj_1, _obj_2
142 _obj_3[#_obj_3 + 1] = _obj_0
143 end
144 _u53d8_u91cfa, _u5bf9_u8c61c, getmetatable(_u5bf9_u8c61d).__add = 1, _obj_1, _obj_2
145 end
146 end 124 end
147 end 125 end
148 end 126 end
diff --git a/spec/outputs/unicode/attrib.lua b/spec/outputs/unicode/attrib.lua
index 0f60451..58ad4b2 100644
--- a/spec/outputs/unicode/attrib.lua
+++ b/spec/outputs/unicode/attrib.lua
@@ -14,20 +14,16 @@ end
14do 14do
15 local _u5e38_u91cfa <const> = _u51fd_u6570() 15 local _u5e38_u91cfa <const> = _u51fd_u6570()
16 local _u5143_u7d20b, _u5143_u7d20c, _u5143_u7d20d 16 local _u5143_u7d20b, _u5143_u7d20c, _u5143_u7d20d
17 do 17 local _obj_0, _obj_1 = _u51fd_u65701()
18 local _obj_0, _obj_1 = _u51fd_u65701() 18 _u5143_u7d20b, _u5143_u7d20c = _obj_0[1], _obj_0[2]
19 _u5143_u7d20b, _u5143_u7d20c = _obj_0[1], _obj_0[2] 19 _u5143_u7d20d = _obj_1[1]
20 _u5143_u7d20d = _obj_1[1]
21 end
22end 20end
23do 21do
24 local _u5e38_u91cfa, _u5143_u7d20b, _u5143_u7d20c, _u5143_u7d20d 22 local _u5e38_u91cfa, _u5143_u7d20b, _u5143_u7d20c, _u5143_u7d20d
25 do 23 local _obj_0, _obj_1, _obj_2 = _u51fd_u6570()
26 local _obj_0, _obj_1, _obj_2 = _u51fd_u6570() 24 _u5e38_u91cfa = _obj_0
27 _u5e38_u91cfa = _obj_0 25 _u5143_u7d20b, _u5143_u7d20c = _obj_1[1], _obj_1[2]
28 _u5143_u7d20b, _u5143_u7d20c = _obj_1[1], _obj_1[2] 26 _u5143_u7d20d = _obj_2[1]
29 _u5143_u7d20d = _obj_2[1]
30 end
31end 27end
32do 28do
33 local _u5173_u95ed_u53d8_u91cfv <close> = (function() 29 local _u5173_u95ed_u53d8_u91cfv <close> = (function()
diff --git a/spec/outputs/unicode/backcall.lua b/spec/outputs/unicode/backcall.lua
index 91dfdff..f4bd5a3 100644
--- a/spec/outputs/unicode/backcall.lua
+++ b/spec/outputs/unicode/backcall.lua
@@ -31,21 +31,19 @@ do
31 end)()) 31 end)())
32end 32end
33do 33do
34 do 34 local _obj_0 = _u7f51_u7edc
35 local _obj_0 = _u7f51_u7edc 35 if _obj_0 ~= nil then
36 if _obj_0 ~= nil then 36 _obj_0["获å–"]("测试地å€", function(_u6570_u636e)
37 _obj_0["获å–"]("测试地å€", function(_u6570_u636e) 37 local _call_0 = _u7f51_u9875_u4f53[".结果"]
38 local _call_0 = _u7f51_u9875_u4f53[".结果"] 38 _call_0["网页"](_call_0, _u6570_u636e)
39 _call_0["网页"](_call_0, _u6570_u636e) 39 return _u7f51_u7edc["请求"]("测试地å€", _u6570_u636e, function(_u662f_u5426_u5904_u7406_u6210_u529f)
40 return _u7f51_u7edc["请求"]("测试地å€", _u6570_u636e, function(_u662f_u5426_u5904_u7406_u6210_u529f) 40 local _call_1 = _u7f51_u9875_u4f53[".结果"]
41 local _call_1 = _u7f51_u9875_u4f53[".结果"] 41 _call_1["添加"](_call_1, _u662f_u5426_u5904_u7406_u6210_u679c)
42 _call_1["添加"](_call_1, _u662f_u5426_u5904_u7406_u6210_u679c) 42 return _u8bbe_u7f6e_u8d85_u65f6_u56de_u8c03(1000, function()
43 return _u8bbe_u7f6e_u8d85_u65f6_u56de_u8c03(1000, function() 43 return _u6253_u5370("完æˆ")
44 return _u6253_u5370("完æˆ")
45 end)
46 end) 44 end)
47 end) 45 end)
48 end 46 end)
49 end 47 end
50end 48end
51do 49do
diff --git a/spec/outputs/unicode/bubbling.lua b/spec/outputs/unicode/bubbling.lua
index cb8750d..55666ba 100644
--- a/spec/outputs/unicode/bubbling.lua
+++ b/spec/outputs/unicode/bubbling.lua
@@ -109,15 +109,13 @@ __u65e0_u6548_u53d8_u91cf = function(...)
109 _u6570_u7ec4a = _accum_0 109 _u6570_u7ec4a = _accum_0
110 end 110 end
111 local _u6570_u7ec4b 111 local _u6570_u7ec4b
112 do 112 local _accum_0 = { }
113 local _accum_0 = { } 113 local _len_0 = 1
114 local _len_0 = 1 114 for _u8ba1_u6570 = 1, 10 do
115 for _u8ba1_u6570 = 1, 10 do 115 _accum_0[_len_0] = function(...)
116 _accum_0[_len_0] = function(...) 116 return _u6253_u5370(...)
117 return _u6253_u5370(...)
118 end
119 _len_0 = _len_0 + 1
120 end 117 end
121 _u6570_u7ec4b = _accum_0 118 _len_0 = _len_0 + 1
122 end 119 end
120 _u6570_u7ec4b = _accum_0
123end 121end
diff --git a/spec/outputs/unicode/class.lua b/spec/outputs/unicode/class.lua
index 4d309e3..23fc8f4 100644
--- a/spec/outputs/unicode/class.lua
+++ b/spec/outputs/unicode/class.lua
@@ -497,30 +497,28 @@ _u6253_u5370("你好")
497local _u53d8_u91cfyyy 497local _u53d8_u91cfyyy
498_u53d8_u91cfyyy = function() 498_u53d8_u91cfyyy = function()
499 local _u9177 499 local _u9177
500 do 500 local _class_0
501 local _class_0 501 local _base_0 = { }
502 local _base_0 = { } 502 if _base_0.__index == nil then
503 if _base_0.__index == nil then 503 _base_0.__index = _base_0
504 _base_0.__index = _base_0
505 end
506 _class_0 = setmetatable({
507 __init = function() end,
508 __base = _base_0,
509 __name = "é…·"
510 }, {
511 __index = _base_0,
512 __call = function(cls, ...)
513 local _self_0 = setmetatable({ }, _base_0)
514 cls.__init(_self_0, ...)
515 return _self_0
516 end
517 })
518 _base_0.__class = _class_0
519 local self = _class_0;
520 _ = nil
521 _u9177 = _class_0
522 return _class_0
523 end 504 end
505 _class_0 = setmetatable({
506 __init = function() end,
507 __base = _base_0,
508 __name = "é…·"
509 }, {
510 __index = _base_0,
511 __call = function(cls, ...)
512 local _self_0 = setmetatable({ }, _base_0)
513 cls.__init(_self_0, ...)
514 return _self_0
515 end
516 })
517 _base_0.__class = _class_0
518 local self = _class_0;
519 _ = nil
520 _u9177 = _class_0
521 return _class_0
524end 522end
525do 523do
526 local _class_0 524 local _class_0
diff --git a/spec/outputs/unicode/cond.lua b/spec/outputs/unicode/cond.lua
index ed5d274..2b5af8a 100644
--- a/spec/outputs/unicode/cond.lua
+++ b/spec/outputs/unicode/cond.lua
@@ -113,19 +113,15 @@ local z_u53d8_u91cf = false
113if false then 113if false then
114 __u65e0_u6548_u53d8_u91cf = _u4e00 114 __u65e0_u6548_u53d8_u91cf = _u4e00
115else 115else
116 do 116 local _u6761_u4ef6x = true
117 local _u6761_u4ef6x = true 117 if _u6761_u4ef6x then
118 if _u6761_u4ef6x then 118 __u65e0_u6548_u53d8_u91cf = _u4e8c
119 __u65e0_u6548_u53d8_u91cf = _u4e8c 119 else
120 local _u6761_u4ef6z = true
121 if _u6761_u4ef6z then
122 __u65e0_u6548_u53d8_u91cf = _u4e09
120 else 123 else
121 do 124 __u65e0_u6548_u53d8_u91cf = _u56db
122 local _u6761_u4ef6z = true
123 if _u6761_u4ef6z then
124 __u65e0_u6548_u53d8_u91cf = _u4e09
125 else
126 __u65e0_u6548_u53d8_u91cf = _u56db
127 end
128 end
129 end 125 end
130 end 126 end
131end 127end
@@ -133,35 +129,27 @@ local _u8f93_u51fa
133if false then 129if false then
134 _u8f93_u51fa = _u4e00 130 _u8f93_u51fa = _u4e00
135else 131else
136 do 132 local _u6761_u4ef6x = true
137 local _u6761_u4ef6x = true 133 if _u6761_u4ef6x then
138 if _u6761_u4ef6x then 134 _u8f93_u51fa = _u4e8c
139 _u8f93_u51fa = _u4e8c 135 else
136 local _u6761_u4ef6z = true
137 if _u6761_u4ef6z then
138 _u8f93_u51fa = _u4e09
140 else 139 else
141 do 140 _u8f93_u51fa = _u56db
142 local _u6761_u4ef6z = true
143 if _u6761_u4ef6z then
144 _u8f93_u51fa = _u4e09
145 else
146 _u8f93_u51fa = _u56db
147 end
148 end
149 end 141 end
150 end 142 end
151end 143end
152local _u53d8_u91cf 144local _u53d8_u91cf
153_u53d8_u91cf = function() 145_u53d8_u91cf = function()
154 do 146 local _u67d0_u4e1c_u897f = true
155 local _u67d0_u4e1c_u897f = true 147 if _u67d0_u4e1c_u897f then
156 if _u67d0_u4e1c_u897f then 148 return 1
157 return 1 149 else
158 else 150 local _u53e6_u4e00_u4e2a = false
159 do 151 if _u53e6_u4e00_u4e2a then
160 local _u53e6_u4e00_u4e2a = false 152 return 2
161 if _u53e6_u4e00_u4e2a then
162 return 2
163 end
164 end
165 end 153 end
166 end 154 end
167end 155end
@@ -319,12 +307,10 @@ do
319 end 307 end
320end 308end
321do 309do
322 do 310 local __u6a21_u5757 = { }
323 local __u6a21_u5757 = { } 311 if __u6a21_u5757 then
324 if __u6a21_u5757 then 312 local _u4e1c_u897f = __u6a21_u5757["东西"]
325 local _u4e1c_u897f = __u6a21_u5757["东西"] 313 local a_u529f_u80fd, b_u529f_u80fd = __u6a21_u5757["a功能"], __u6a21_u5757["b功能"]
326 local a_u529f_u80fd, b_u529f_u80fd = __u6a21_u5757["a功能"], __u6a21_u5757["b功能"]
327 end
328 end 314 end
329end 315end
330do 316do
diff --git a/spec/outputs/unicode/destructure.lua b/spec/outputs/unicode/destructure.lua
index 002c4b0..7263d49 100644
--- a/spec/outputs/unicode/destructure.lua
+++ b/spec/outputs/unicode/destructure.lua
@@ -127,11 +127,9 @@ do
127 end 127 end
128end 128end
129do 129do
130 do 130 local _with_0 = _u4e1c_u897f
131 local _with_0 = _u4e1c_u897f 131 local _u5143_u7d20a, _u5143_u7d20b = _with_0[1], _with_0[2]
132 local _u5143_u7d20a, _u5143_u7d20b = _with_0[1], _with_0[2] 132 _u6253_u5370(_u5143_u7d20a, _u5143_u7d20b)
133 _u6253_u5370(_u5143_u7d20a, _u5143_u7d20b)
134 end
135end 133end
136do 134do
137 local _u4e1c_u897f = nil 135 local _u4e1c_u897f = nil
@@ -320,11 +318,9 @@ do
320 _tmp_0 = _obj_0["函数"] 318 _tmp_0 = _obj_0["函数"]
321 end 319 end
322 if _tmp_0 == nil then 320 if _tmp_0 == nil then
323 do 321 local _obj_0 = _u9879_u76ee
324 local _obj_0 = _u9879_u76ee 322 if _obj_0 ~= nil then
325 if _obj_0 ~= nil then 323 _tmp_0 = _obj_0["默认值"]
326 _tmp_0 = _obj_0["默认值"]
327 end
328 end 324 end
329 end 325 end
330 a_u5bf9_u8c61["b字段"](function() 326 a_u5bf9_u8c61["b字段"](function()
@@ -436,11 +432,9 @@ do
436 end 432 end
437 local _u53d8_u91cfy1, _u53d8_u91cfy4 433 local _u53d8_u91cfy1, _u53d8_u91cfy4
438 local _u5b57_u6bb5y2, _u5b57_u6bb5y3 434 local _u5b57_u6bb5y2, _u5b57_u6bb5y3
439 do 435 local _obj_0, _obj_1 = _u51fd_u65702()
440 local _obj_0, _obj_1 = _u51fd_u65702() 436 _u53d8_u91cfy1, _u53d8_u91cfy4 = _u51fd_u65701(), _obj_1
441 _u53d8_u91cfy1, _u53d8_u91cfy4 = _u51fd_u65701(), _obj_1 437 _u5b57_u6bb5y2, _u5b57_u6bb5y3 = _obj_0["字段y2"], _obj_0["字段y3"]
442 _u5b57_u6bb5y2, _u5b57_u6bb5y3 = _obj_0["字段y2"], _obj_0["字段y3"]
443 end
444end 438end
445do 439do
446 local _u53d8_u91cfv1, _u53d8_u91cfv2, _u53d8_u91cfv3, _u53d8_u91cfv4 440 local _u53d8_u91cfv1, _u53d8_u91cfv2, _u53d8_u91cfv3, _u53d8_u91cfv4
@@ -470,11 +464,9 @@ do
470end 464end
471do 465do
472 local _u503c, _u5143_u503c 466 local _u503c, _u5143_u503c
473 do 467 local _obj_0 = _u5bf9_u8c61tb
474 local _obj_0 = _u5bf9_u8c61tb 468 _u503c = _obj_0[_u540d_u79f0]
475 _u503c = _obj_0[_u540d_u79f0] 469 _u5143_u503c = getmetatable(_obj_0)[_u540d_u79f0]
476 _u5143_u503c = getmetatable(_obj_0)[_u540d_u79f0]
477 end
478end 470end
479do 471do
480 local tostring, add 472 local tostring, add
@@ -487,24 +479,22 @@ do
487 end) 479 end)
488 end 480 end
489 end 481 end
490 do 482 local _exp_0 = _u5bf9_u8c61tb
491 local _exp_0 = _u5bf9_u8c61tb 483 local _type_0 = type(_exp_0)
492 local _type_0 = type(_exp_0) 484 local _tab_0 = "table" == _type_0 or "userdata" == _type_0
493 local _tab_0 = "table" == _type_0 or "userdata" == _type_0 485 if _tab_0 then
494 if _tab_0 then 486 local name, _u5143_u5b57_u6bb5
495 local name, _u5143_u5b57_u6bb5 487 do
496 do 488 local _obj_0 = getmetatable(_exp_0)
497 local _obj_0 = getmetatable(_exp_0) 489 name = _obj_0.__name
498 name = _obj_0.__name 490 _u5143_u5b57_u6bb5 = _obj_0["123"]
499 _u5143_u5b57_u6bb5 = _obj_0["123"] 491 if name == nil then
500 if name == nil then 492 name = "项目"
501 name = "项目"
502 end
503 end
504 if _u5143_u5b57_u6bb5 ~= nil then
505 _u6253_u5370(name, _u5143_u5b57_u6bb5)
506 end 493 end
507 end 494 end
495 if _u5143_u5b57_u6bb5 ~= nil then
496 _u6253_u5370(name, _u5143_u5b57_u6bb5)
497 end
508 end 498 end
509end 499end
510do 500do
@@ -586,52 +576,50 @@ do
586 _u6253_u5370(add, _u5b57_u6bb5) 576 _u6253_u5370(add, _u5b57_u6bb5)
587 end 577 end
588 end 578 end
589 do 579 local _exp_0 = tb
590 local _exp_0 = tb 580 local _type_0 = type(_exp_0)
591 local _type_0 = type(_exp_0) 581 local _tab_0 = "table" == _type_0 or "userdata" == _type_0
592 local _tab_0 = "table" == _type_0 or "userdata" == _type_0 582 if _tab_0 then
593 if _tab_0 then 583 do
594 do 584 local _obj_0 = _exp_0["字段c"]
595 local _obj_0 = _exp_0["字段c"] 585 local _type_1 = type(_obj_0)
596 local _type_1 = type(_obj_0) 586 if "table" == _type_1 or "userdata" == _type_1 then
597 if "table" == _type_1 or "userdata" == _type_1 then 587 do
598 do 588 local _obj_1 = getmetatable(_obj_0)
599 local _obj_1 = getmetatable(_obj_0) 589 local _type_2 = type(_obj_1)
600 local _type_2 = type(_obj_1) 590 if "table" == _type_2 or "userdata" == _type_2 then
601 if "table" == _type_2 or "userdata" == _type_2 then 591 _u5143_u5b57_u6bb5 = _obj_1["字段abc"]
602 _u5143_u5b57_u6bb5 = _obj_1["字段abc"]
603 end
604 end 592 end
605 end 593 end
606 end 594 end
607 if _u5143_u5b57_u6bb5 == nil then 595 end
608 _u5143_u5b57_u6bb5 = "默认值" 596 if _u5143_u5b57_u6bb5 == nil then
609 end 597 _u5143_u5b57_u6bb5 = "默认值"
598 end
599 do
600 local _obj_0 = getmetatable(_exp_0)
610 do 601 do
611 local _obj_0 = getmetatable(_exp_0) 602 local _obj_1 = _obj_0[ [[any string]]]
612 do 603 local _type_1 = type(_obj_1)
613 local _obj_1 = _obj_0[ [[any string]]] 604 if "table" == _type_1 or "userdata" == _type_1 then
614 local _type_1 = type(_obj_1) 605 _u53d8_u91cfabc = _obj_1["字段d"]
615 if "table" == _type_1 or "userdata" == _type_1 then
616 _u53d8_u91cfabc = _obj_1["字段d"]
617 end
618 end
619 do
620 local _obj_1 = _obj_0['字符串']
621 local _type_1 = type(_obj_1)
622 if "table" == _type_1 or "userdata" == _type_1 then
623 _u6709_u9ed8_u8ba4_u503c = _obj_1["字段e"]
624 end
625 end
626 if _u53d8_u91cfabc == nil then
627 _u53d8_u91cfabc = 123
628 end 606 end
629 if _u6709_u9ed8_u8ba4_u503c == nil then 607 end
630 _u6709_u9ed8_u8ba4_u503c = { } 608 do
609 local _obj_1 = _obj_0['字符串']
610 local _type_1 = type(_obj_1)
611 if "table" == _type_1 or "userdata" == _type_1 then
612 _u6709_u9ed8_u8ba4_u503c = _obj_1["字段e"]
631 end 613 end
632 end 614 end
633 _u6253_u5370(_u5143_u5b57_u6bb5, _u53d8_u91cfabc, _u6709_u9ed8_u8ba4_u503c) 615 if _u53d8_u91cfabc == nil then
616 _u53d8_u91cfabc = 123
617 end
618 if _u6709_u9ed8_u8ba4_u503c == nil then
619 _u6709_u9ed8_u8ba4_u503c = { }
620 end
634 end 621 end
622 _u6253_u5370(_u5143_u5b57_u6bb5, _u53d8_u91cfabc, _u6709_u9ed8_u8ba4_u503c)
635 end 623 end
636end 624end
637return nil 625return nil
diff --git a/spec/outputs/unicode/global.lua b/spec/outputs/unicode/global.lua
index c91db52..a34ce6d 100644
--- a/spec/outputs/unicode/global.lua
+++ b/spec/outputs/unicode/global.lua
@@ -3,29 +3,27 @@ do
3 _u9177 = "📉" 3 _u9177 = "📉"
4end 4end
5do 5do
6 do 6 local _class_0
7 local _class_0 7 local _base_0 = {
8 local _base_0 = { 8 ["嗯"] = "🆒"
9 ["嗯"] = "🆒" 9 }
10 } 10 if _base_0.__index == nil then
11 if _base_0.__index == nil then 11 _base_0.__index = _base_0
12 _base_0.__index = _base_0
13 end
14 _class_0 = setmetatable({
15 __init = function() end,
16 __base = _base_0,
17 __name = "全局类"
18 }, {
19 __index = _base_0,
20 __call = function(cls, ...)
21 local _self_0 = setmetatable({ }, _base_0)
22 cls.__init(_self_0, ...)
23 return _self_0
24 end
25 })
26 _base_0.__class = _class_0
27 _u5168_u5c40_u7c7b = _class_0
28 end 12 end
13 _class_0 = setmetatable({
14 __init = function() end,
15 __base = _base_0,
16 __name = "全局类"
17 }, {
18 __index = _base_0,
19 __call = function(cls, ...)
20 local _self_0 = setmetatable({ }, _base_0)
21 cls.__init(_self_0, ...)
22 return _self_0
23 end
24 })
25 _base_0.__class = _class_0
26 _u5168_u5c40_u7c7b = _class_0
29end 27end
30do 28do
31 local _u53d8_u91cfc, _u53d8_u91cfd 29 local _u53d8_u91cfc, _u53d8_u91cfd
diff --git a/spec/outputs/unicode/import.lua b/spec/outputs/unicode/import.lua
index 3499295..e4aec89 100644
--- a/spec/outputs/unicode/import.lua
+++ b/spec/outputs/unicode/import.lua
@@ -30,16 +30,14 @@ do
30end 30end
31if _u7f29_u8fdb then 31if _u7f29_u8fdb then
32 local _u597d_u5427, _u5f88_u597d 32 local _u597d_u5427, _u5f88_u597d
33 do 33 local _obj_1 = _u5f88_u591a_u8868[100]
34 local _obj_1 = _u5f88_u591a_u8868[100] 34 _u597d_u5427, _u5f88_u597d = _obj_1["好å§"], (function()
35 _u597d_u5427, _u5f88_u597d = _obj_1["好å§"], (function() 35 local _base_0 = _obj_1
36 local _base_0 = _obj_1 36 local _fn_0 = _base_0["很好"]
37 local _fn_0 = _base_0["很好"] 37 return _fn_0 and function(...)
38 return _fn_0 and function(...) 38 return _fn_0(_base_0, ...)
39 return _fn_0(_base_0, ...) 39 end
40 end 40 end)()
41 end)()
42 end
43end 41end
44do 42do
45 local _u5b57_u6bb5a, _u5b57_u6bb5b, _u5b57_u6bb5c = _u5bf9_u8c61z["字段a"], _u5bf9_u8c61z["字段b"], _u5bf9_u8c61z["字段c"] 43 local _u5b57_u6bb5a, _u5b57_u6bb5b, _u5b57_u6bb5c = _u5bf9_u8c61z["字段a"], _u5bf9_u8c61z["字段b"], _u5bf9_u8c61z["字段c"]
diff --git a/spec/outputs/unicode/in_expression.lua b/spec/outputs/unicode/in_expression.lua
index 2f47b1f..4b8f711 100644
--- a/spec/outputs/unicode/in_expression.lua
+++ b/spec/outputs/unicode/in_expression.lua
@@ -173,10 +173,8 @@ do
173 _u51fd_u65704 = function() 173 _u51fd_u65704 = function()
174 local _u53d8_u91cfa = 2 174 local _u53d8_u91cfa = 2
175 local _u53d8_u91cfb 175 local _u53d8_u91cfb
176 do 176 local _val_0 = a
177 local _val_0 = a 177 _u53d8_u91cfb = 1 == _val_0 or 2 == _val_0 or 3 == _val_0 or 4 == _val_0
178 _u53d8_u91cfb = 1 == _val_0 or 2 == _val_0 or 3 == _val_0 or 4 == _val_0
179 end
180 end 178 end
181 local _u51fd_u65705 179 local _u51fd_u65705
182 _u51fd_u65705 = function() 180 _u51fd_u65705 = function()
diff --git a/spec/outputs/unicode/local.lua b/spec/outputs/unicode/local.lua
index 170144b..4b4b366 100644
--- a/spec/outputs/unicode/local.lua
+++ b/spec/outputs/unicode/local.lua
@@ -98,50 +98,46 @@ do
98 F_u4e94 = 6 98 F_u4e94 = 6
99 O_u4e00 = _class_0 99 O_u4e00 = _class_0
100 end 100 end
101 do 101 local _class_0
102 local _class_0 102 local N_u65e0
103 local N_u65e0 103 local _base_0 = { }
104 local _base_0 = { } 104 if _base_0.__index == nil then
105 if _base_0.__index == nil then 105 _base_0.__index = _base_0
106 _base_0.__index = _base_0 106 end
107 end 107 _class_0 = setmetatable({
108 _class_0 = setmetatable({ 108 __init = function() end,
109 __init = function() end, 109 __base = _base_0,
110 __base = _base_0, 110 __name = "T二"
111 __name = "T二" 111 }, {
112 }, { 112 __index = _base_0,
113 __index = _base_0, 113 __call = function(cls, ...)
114 __call = function(cls, ...) 114 local _self_0 = setmetatable({ }, _base_0)
115 local _self_0 = setmetatable({ }, _base_0) 115 cls.__init(_self_0, ...)
116 cls.__init(_self_0, ...) 116 return _self_0
117 return _self_0
118 end
119 })
120 _base_0.__class = _class_0
121 local self = _class_0;
122 do
123 local _class_1
124 local _base_1 = { }
125 if _base_1.__index == nil then
126 _base_1.__index = _base_1
127 end
128 _class_1 = setmetatable({
129 __init = function() end,
130 __base = _base_1,
131 __name = "Næ— "
132 }, {
133 __index = _base_1,
134 __call = function(cls, ...)
135 local _self_0 = setmetatable({ }, _base_1)
136 cls.__init(_self_0, ...)
137 return _self_0
138 end
139 })
140 _base_1.__class = _class_1
141 N_u65e0 = _class_1
142 end 117 end
143 T_u4e8c = _class_0 118 })
119 _base_0.__class = _class_0
120 local self = _class_0;
121 local _class_1
122 local _base_1 = { }
123 if _base_1.__index == nil then
124 _base_1.__index = _base_1
144 end 125 end
126 _class_1 = setmetatable({
127 __init = function() end,
128 __base = _base_1,
129 __name = "Næ— "
130 }, {
131 __index = _base_1,
132 __call = function(cls, ...)
133 local _self_0 = setmetatable({ }, _base_1)
134 cls.__init(_self_0, ...)
135 return _self_0
136 end
137 })
138 _base_1.__class = _class_1
139 N_u65e0 = _class_1
140 T_u4e8c = _class_0
145end 141end
146do 142do
147 local _list_0 = { } 143 local _list_0 = { }
diff --git a/spec/outputs/unicode/loops.lua b/spec/outputs/unicode/loops.lua
index d630343..8379993 100644
--- a/spec/outputs/unicode/loops.lua
+++ b/spec/outputs/unicode/loops.lua
@@ -297,17 +297,15 @@ end
297do 297do
298 for _u53d8_u91cfi = 1, 10 do 298 for _u53d8_u91cfi = 1, 10 do
299 repeat 299 repeat
300 do 300 local _with_0 = _u5bf9_u8c61tb
301 local _with_0 = _u5bf9_u8c61tb 301 if _with_0 ~= nil then
302 if _with_0 ~= nil then 302 _with_0["字段a"] = 1
303 _with_0["字段a"] = 1 303 if _with_0["字段b"] then
304 if _with_0["字段b"] then 304 goto _continue_12
305 goto _continue_12 305 end
306 end 306 do
307 do 307 if _with_0["字段c"] then
308 if _with_0["字段c"] then 308 break
309 break
310 end
311 end 309 end
312 end 310 end
313 end 311 end
diff --git a/spec/outputs/unicode/macro.lua b/spec/outputs/unicode/macro.lua
index 88f6de7..069f429 100644
--- a/spec/outputs/unicode/macro.lua
+++ b/spec/outputs/unicode/macro.lua
@@ -1,4 +1,6 @@
1assert(_u5bf9_u8c61 == nil) 1do
2 assert(_u5bf9_u8c61 == nil)
3end
2local _u7ed3_u679c = (_u5bf9_u8c61 == nil) 4local _u7ed3_u679c = (_u5bf9_u8c61 == nil)
3if _u51fd_u65701() then 5if _u51fd_u65701() then
4 _u6253_u5370("没问题") 6 _u6253_u5370("没问题")
@@ -9,89 +11,89 @@ end
9local _u5bf9_u8c61 11local _u5bf9_u8c61
10do 12do
11 local __u6e90_, __u76ee_u6807_ 13 local __u6e90_, __u76ee_u6807_
12 do 14 __u76ee_u6807_ = {
13 __u76ee_u6807_ = { 15 ["ä½ç½®"] = { },
14 ["ä½ç½®"] = { }, 16 ["标签"] = (function()
15 ["标签"] = (function() 17 local _call_0 = _u6807_u7b7e
16 local _call_0 = _u6807_u7b7e 18 return _call_0["转数字"](_call_0)
17 return _call_0["转数字"](_call_0) 19 end)()
18 end)() 20 }
19 } 21 __u6e90_ = self
20 do 22 __u76ee_u6807_["标识"] = __u6e90_["标识"]
21 __u6e90_ = self 23 __u76ee_u6807_["连接们"] = __u6e90_["连接们"]
22 __u76ee_u6807_["标识"] = __u6e90_["标识"] 24 __u76ee_u6807_["ä½ç½®"]["xåæ ‡"] = __u6e90_["ä½ç½®"]["xåæ ‡"]
23 __u76ee_u6807_["连接们"] = __u6e90_["连接们"] 25 __u76ee_u6807_["ä½ç½®"]["yåæ ‡"] = __u6e90_["ä½ç½®"]["yåæ ‡"]
24 __u76ee_u6807_["ä½ç½®"]["xåæ ‡"] = __u6e90_["ä½ç½®"]["xåæ ‡"] 26 __u76ee_u6807_["ä½ç½®"]["zåæ ‡"] = __u6e90_["ä½ç½®"]["zåæ ‡"]
25 __u76ee_u6807_["ä½ç½®"]["yåæ ‡"] = __u6e90_["ä½ç½®"]["yåæ ‡"] 27 _u5bf9_u8c61 = __u76ee_u6807_
26 __u76ee_u6807_["ä½ç½®"]["zåæ ‡"] = __u6e90_["ä½ç½®"]["zåæ ‡"]
27 end
28 _u5bf9_u8c61 = __u76ee_u6807_
29 end
30end 28end
31if (_u53d8_u91cfx == "ðŸŽ" or _u53d8_u91cfx == "ðŸ·" or _u53d8_u91cfx == "ðŸ¶") then 29if (_u53d8_u91cfx == "ðŸŽ" or _u53d8_u91cfx == "ðŸ·" or _u53d8_u91cfx == "ðŸ¶") then
32 _u6253_u5370("存在") 30 _u6253_u5370("存在")
33end 31end
34local _list_0 = (function() 32do
35 local _accum_0 = { }
36 local _len_0 = 1
37 local _list_0 = (function() 33 local _list_0 = (function()
38 local _accum_1 = { } 34 local _accum_0 = { }
39 local _len_1 = 1 35 local _len_0 = 1
40 local _list_0 = { 36 local _list_0 = (function()
41 1, 37 local _accum_1 = { }
42 2, 38 local _len_1 = 1
43 3 39 local _list_0 = {
44 } 40 1,
41 2,
42 3
43 }
44 for _index_0 = 1, #_list_0 do
45 local _ = _list_0[_index_0]
46 _accum_1[_len_1] = _ * 2
47 _len_1 = _len_1 + 1
48 end
49 return _accum_1
50 end)()
45 for _index_0 = 1, #_list_0 do 51 for _index_0 = 1, #_list_0 do
46 local _ = _list_0[_index_0] 52 local _ = _list_0[_index_0]
47 _accum_1[_len_1] = _ * 2 53 if _ > 4 then
48 _len_1 = _len_1 + 1 54 _accum_0[_len_0] = _
55 _len_0 = _len_0 + 1
56 end
49 end 57 end
50 return _accum_1 58 return _accum_0
51 end)() 59 end)()
52 for _index_0 = 1, #_list_0 do 60 for _index_0 = 1, #_list_0 do
53 local _ = _list_0[_index_0] 61 local _ = _list_0[_index_0]
54 if _ > 4 then 62 _u6253_u5370(_)
55 _accum_0[_len_0] = _
56 _len_0 = _len_0 + 1
57 end
58 end 63 end
59 return _accum_0
60end)()
61for _index_0 = 1, #_list_0 do
62 local _ = _list_0[_index_0]
63 _u6253_u5370(_)
64end 64end
65local _list_1 = (function() 65do
66 local _accum_0 = { } 66 local _list_0 = (function()
67 local _len_0 = 1 67 local _accum_0 = { }
68 local _list_1 = (function() 68 local _len_0 = 1
69 local _accum_1 = { } 69 local _list_0 = (function()
70 local _len_1 = 1 70 local _accum_1 = { }
71 local _list_1 = { 71 local _len_1 = 1
72 1, 72 local _list_0 = {
73 2, 73 1,
74 3 74 2,
75 } 75 3
76 for _index_0 = 1, #_list_1 do 76 }
77 local _ = _list_1[_index_0] 77 for _index_0 = 1, #_list_0 do
78 _accum_1[_len_1] = _ * 2 78 local _ = _list_0[_index_0]
79 _len_1 = _len_1 + 1 79 _accum_1[_len_1] = _ * 2
80 _len_1 = _len_1 + 1
81 end
82 return _accum_1
83 end)()
84 for _index_0 = 1, #_list_0 do
85 local _ = _list_0[_index_0]
86 if _ > 4 then
87 _accum_0[_len_0] = _
88 _len_0 = _len_0 + 1
89 end
80 end 90 end
81 return _accum_1 91 return _accum_0
82 end)() 92 end)()
83 for _index_0 = 1, #_list_1 do 93 for _index_0 = 1, #_list_0 do
84 local _ = _list_1[_index_0] 94 local _ = _list_0[_index_0]
85 if _ > 4 then 95 _u6253_u5370(_)
86 _accum_0[_len_0] = _
87 _len_0 = _len_0 + 1
88 end
89 end 96 end
90 return _accum_0
91end)()
92for _index_0 = 1, #_list_1 do
93 local _ = _list_1[_index_0]
94 _u6253_u5370(_)
95end 97end
96local _u503c 98local _u503c
97do 99do
@@ -99,13 +101,13 @@ do
99 do 101 do
100 local _accum_0 = { } 102 local _accum_0 = { }
101 local _len_0 = 1 103 local _len_0 = 1
102 local _list_2 = { 104 local _list_0 = {
103 1, 105 1,
104 2, 106 2,
105 3 107 3
106 } 108 }
107 for _index_0 = 1, #_list_2 do 109 for _index_0 = 1, #_list_0 do
108 local _ = _list_2[_index_0] 110 local _ = _list_0[_index_0]
109 _accum_0[_len_0] = _ * 2 111 _accum_0[_len_0] = _ * 2
110 _len_0 = _len_0 + 1 112 _len_0 = _len_0 + 1
111 end 113 end
@@ -137,8 +139,10 @@ do
137 end 139 end
138 _u503c = _4 140 _u503c = _4
139end 141end
140local _call_0 = (1 + 2) 142do
141_call_0["调用"](_call_0, 123) 143 local _call_0 = (1 + 2)
144 _call_0["调用"](_call_0, 123)
145end
142_u7ed3_u679c = (1 + 2) 146_u7ed3_u679c = (1 + 2)
143local f 147local f
144f = function(_u53c2_u6570x) 148f = function(_u53c2_u6570x)
@@ -203,7 +207,7 @@ local function dummy()
203end 207end
204-- 这有个注释 208-- 这有个注释
205local _ = require('下划线') 209local _ = require('下划线')
206local _call_1 = (_({ 210local _call_0 = (_({
207 1, 211 1,
208 2, 212 2,
209 3, 213 3,
@@ -211,61 +215,65 @@ local _call_1 = (_({
211 -2, 215 -2,
212 3 216 3
213})) 217}))
214_call_1 = _call_1["链"](_call_1) 218_call_0 = _call_0["链"](_call_0)
215_call_1 = _call_1["映射"](_call_1, function(self) 219_call_0 = _call_0["映射"](_call_0, function(self)
216 return self * 2 220 return self * 2
217end) 221end)
218_call_1 = _call_1["过滤"](_call_1, function(self) 222_call_0 = _call_0["过滤"](_call_0, function(self)
219 return self > 3 223 return self > 3
220end) 224end)
221local _u7ed3_u679ca = _call_1["å–值"](_call_1) 225local _u7ed3_u679ca = _call_0["å–值"](_call_0)
222local _call_2 = (_({
223 1,
224 2,
225 3,
226 4,
227 -2,
228 3
229}))
230_call_2 = _call_2["链"](_call_2)
231_call_2 = _call_2["映射"](_call_2, function(self)
232 return self * 2
233end)
234_call_2 = _call_2["过滤"](_call_2, function(self)
235 return self > 3
236end)
237_call_2["æ¯ä¸€ä¸ª"](_call_2, function(self)
238 return _u6253_u5370(self)
239end)
240local _call_3 = _u539f_u70b9["å˜æ¢"]["根节点"]["游æˆå¯¹è±¡"]
241_call_3 = _call_3["父节点"](_call_3)
242_call_3 = _call_3["åŽä»£"](_call_3)
243_call_3 = _call_3["选择å¯ç”¨"](_call_3)
244_call_3 = _call_3["选择å¯è§"](_call_3)
245_call_3 = _call_3["标签等于"](_call_3, "fx")
246_call_3 = _call_3["其中"](_call_3, function(x)
247 local _call_4 = x["å称"]
248 return _call_4["结尾为"](_call_4, "(克隆)")
249end)
250_u7ed3_u679c = _call_3["摧æ¯"](_call_3)
251do 226do
252 local _1 227 local _call_1 = (_({
253 local _call_4 = _u539f_u70b9["å˜æ¢"]["根节点"]["游æˆå¯¹è±¡"] 228 1,
254 _1 = _call_4["父节点"](_call_4) 229 2,
255 local _2 230 3,
256 _2 = _1["åŽä»£"](_1) 231 4,
257 local _3 232 -2,
258 _3 = _2["选择å¯ç”¨"](_2) 233 3
259 local _4 234 }))
260 _4 = _3["选择å¯è§"](_3) 235 _call_1 = _call_1["链"](_call_1)
261 local _5 236 _call_1 = _call_1["映射"](_call_1, function(self)
262 _5 = _4["标签等于"](_4, "fx") 237 return self * 2
263 local _6 238 end)
264 _6 = _5["其中"](_5, function(x) 239 _call_1 = _call_1["过滤"](_call_1, function(self)
265 local _call_5 = x["å称"] 240 return self > 3
266 return _call_5["结尾为"](_call_5, "(克隆)") 241 end)
242 _call_1["æ¯ä¸€ä¸ª"](_call_1, function(self)
243 return _u6253_u5370(self)
267 end) 244 end)
268 _6["摧æ¯"](_6) 245end
246local _call_1 = _u539f_u70b9["å˜æ¢"]["根节点"]["游æˆå¯¹è±¡"]
247_call_1 = _call_1["父节点"](_call_1)
248_call_1 = _call_1["åŽä»£"](_call_1)
249_call_1 = _call_1["选择å¯ç”¨"](_call_1)
250_call_1 = _call_1["选择å¯è§"](_call_1)
251_call_1 = _call_1["标签等于"](_call_1, "fx")
252_call_1 = _call_1["其中"](_call_1, function(x)
253 local _call_2 = x["å称"]
254 return _call_2["结尾为"](_call_2, "(克隆)")
255end)
256_u7ed3_u679c = _call_1["摧æ¯"](_call_1)
257do
258 do
259 local _1
260 local _call_2 = _u539f_u70b9["å˜æ¢"]["根节点"]["游æˆå¯¹è±¡"]
261 _1 = _call_2["父节点"](_call_2)
262 local _2
263 _2 = _1["åŽä»£"](_1)
264 local _3
265 _3 = _2["选择å¯ç”¨"](_2)
266 local _4
267 _4 = _3["选择å¯è§"](_3)
268 local _5
269 _5 = _4["标签等于"](_4, "fx")
270 local _6
271 _6 = _5["其中"](_5, function(x)
272 local _call_3 = x["å称"]
273 return _call_3["结尾为"](_call_3, "(克隆)")
274 end)
275 _6["摧æ¯"](_6)
276 end
269end 277end
270local _call_0 = _u539f_u70b9["å˜æ¢"]["根节点"]["游æˆå¯¹è±¡"] 278local _call_0 = _u539f_u70b9["å˜æ¢"]["根节点"]["游æˆå¯¹è±¡"]
271_call_0["父节点"](_call_0):_u540e_u4ee3():_u9009_u62e9_u542f_u7528():_u9009_u62e9_u53ef_u89c1():_u6807_u7b7e_u7b49_u4e8e("fx"):_u5176_u4e2d(function(x) 279_call_0["父节点"](_call_0):_u540e_u4ee3():_u9009_u62e9_u542f_u7528():_u9009_u62e9_u53ef_u89c1():_u6807_u7b7e_u7b49_u4e8e("fx"):_u5176_u4e2d(function(x)
@@ -302,7 +310,9 @@ _u6253_u5370((setmetatable({
302 end 310 end
303})) 311}))
304_u6253_u5370("当å‰ä»£ç è¡Œæ•°: " .. tostring(268)) 312_u6253_u5370("当å‰ä»£ç è¡Œæ•°: " .. tostring(268))
313do
305-- 待实现 314-- 待实现
315end
306do 316do
307 _u6253_u5370(1) 317 _u6253_u5370(1)
308end 318end
@@ -317,5 +327,7 @@ _1 = function()
317 end 327 end
318 return _accum_0 328 return _accum_0
319end 329end
320_u6253_u5370('abc') 330do
321return 123 331 _u6253_u5370('abc')
332 return 123
333end
diff --git a/spec/outputs/unicode/metatable.lua b/spec/outputs/unicode/metatable.lua
index b6ee48a..c7c8730 100644
--- a/spec/outputs/unicode/metatable.lua
+++ b/spec/outputs/unicode/metatable.lua
@@ -48,19 +48,17 @@ do
48end 48end
49do 49do
50 local _u53d8_u91cfx, _u65b0, _u53d8_u91cf, close, _u5173_u95edA, num, add, sub 50 local _u53d8_u91cfx, _u65b0, _u53d8_u91cf, close, _u5173_u95edA, num, add, sub
51 local _obj_0, _obj_1
52 _u53d8_u91cfx, _obj_0, _obj_1 = 123, _u53d8_u91cfa["å˜é‡b"]["å˜é‡c"], _u51fd_u6570()
53 _u65b0, _u53d8_u91cf = _obj_0["æ–°"], _obj_0["å˜é‡"]
51 do 54 do
52 local _obj_0, _obj_1 55 local _obj_2 = getmetatable(_obj_0)
53 _u53d8_u91cfx, _obj_0, _obj_1 = 123, _u53d8_u91cfa["å˜é‡b"]["å˜é‡c"], _u51fd_u6570() 56 close, _u5173_u95edA = _obj_2.__close, _obj_2.__close
54 _u65b0, _u53d8_u91cf = _obj_0["æ–°"], _obj_0["å˜é‡"] 57 end
55 do 58 num = _obj_1.num
56 local _obj_2 = getmetatable(_obj_0) 59 do
57 close, _u5173_u95edA = _obj_2.__close, _obj_2.__close 60 local _obj_2 = getmetatable(_obj_1)
58 end 61 add, sub = _obj_2.__add, _obj_2.__sub
59 num = _obj_1.num
60 do
61 local _obj_2 = getmetatable(_obj_1)
62 add, sub = _obj_2.__add, _obj_2.__sub
63 end
64 end 62 end
65end 63end
66setmetatable(_u53d8_u91cfa["å˜é‡b"], { }) 64setmetatable(_u53d8_u91cfa["å˜é‡b"], { })
diff --git a/spec/outputs/unicode/multiline_chain.lua b/spec/outputs/unicode/multiline_chain.lua
index f45e71f..c1da13f 100644
--- a/spec/outputs/unicode/multiline_chain.lua
+++ b/spec/outputs/unicode/multiline_chain.lua
@@ -127,16 +127,14 @@ do
127 _with_0["项目方法C"](_with_0, _u53d8_u91cfi) 127 _with_0["项目方法C"](_with_0, _u53d8_u91cfi)
128 end 128 end
129 if not _with_0["å˜é‡b"] then 129 if not _with_0["å˜é‡b"] then
130 do 130 local _accum_0 = { }
131 local _accum_0 = { } 131 local _len_0 = 1
132 local _len_0 = 1 132 while _with_0["项目字段D"] do
133 while _with_0["项目字段D"] do 133 local _call_17 = _with_0["下一个项目"](_with_0)
134 local _call_17 = _with_0["下一个项目"](_with_0) 134 _accum_0[_len_0] = _call_17["å–å¾—"](_call_17)
135 _accum_0[_len_0] = _call_17["å–å¾—"](_call_17) 135 _len_0 = _len_0 + 1
136 _len_0 = _len_0 + 1
137 end
138 _with_0["å˜é‡c"] = _accum_0
139 end 136 end
137 _with_0["å˜é‡c"] = _accum_0
140 end 138 end
141end 139end
142return nil 140return nil
diff --git a/spec/outputs/unicode/nil_coalescing.lua b/spec/outputs/unicode/nil_coalescing.lua
index 90fd097..53e3711 100644
--- a/spec/outputs/unicode/nil_coalescing.lua
+++ b/spec/outputs/unicode/nil_coalescing.lua
@@ -1,23 +1,19 @@
1do 1do
2 local _u53d8_u91cfa 2 local _u53d8_u91cfa
3 do 3 local _exp_0 = _u53d8_u91cfb
4 local _exp_0 = _u53d8_u91cfb 4 if _exp_0 ~= nil then
5 if _exp_0 ~= nil then 5 _u53d8_u91cfa = _exp_0
6 _u53d8_u91cfa = _exp_0 6 else
7 else 7 _u53d8_u91cfa = _u53d8_u91cfc
8 _u53d8_u91cfa = _u53d8_u91cfc
9 end
10 end 8 end
11end 9end
12do 10do
13 local _u5b57_u6bb5a 11 local _u5b57_u6bb5a
14 do 12 local _exp_0 = _u53d8_u91cfb
15 local _exp_0 = _u53d8_u91cfb 13 if _exp_0 ~= nil then
16 if _exp_0 ~= nil then 14 _u5b57_u6bb5a = _exp_0["字段a"]
17 _u5b57_u6bb5a = _exp_0["字段a"] 15 else
18 else 16 _u5b57_u6bb5a = _u53d8_u91cfc["字段a"]
19 _u5b57_u6bb5a = _u53d8_u91cfc["字段a"]
20 end
21 end 17 end
22end 18end
23do 19do
@@ -50,23 +46,21 @@ do
50end 46end
51do 47do
52 local _u53d8_u91cfa 48 local _u53d8_u91cfa
53 do 49 local _exp_0 = _u53d8_u91cfb
54 local _exp_0 = _u53d8_u91cfb 50 if _exp_0 ~= nil then
55 if _exp_0 ~= nil then 51 _u53d8_u91cfa = _exp_0
56 _u53d8_u91cfa = _exp_0 52 else
57 else 53 do
58 do 54 local _exp_1 = _u53d8_u91cfc
59 local _exp_1 = _u53d8_u91cfc 55 if _exp_1 ~= nil then
60 if _exp_1 ~= nil then 56 _u53d8_u91cfa = _exp_1
61 _u53d8_u91cfa = _exp_1 57 else
62 else 58 do
63 do 59 local _exp_2 = _u53d8_u91cfd
64 local _exp_2 = _u53d8_u91cfd 60 if _exp_2 ~= nil then
65 if _exp_2 ~= nil then 61 _u53d8_u91cfa = _exp_2
66 _u53d8_u91cfa = _exp_2 62 else
67 else 63 _u53d8_u91cfa = _u53d8_u91cfe
68 _u53d8_u91cfa = _u53d8_u91cfe
69 end
70 end 64 end
71 end 65 end
72 end 66 end
@@ -84,18 +78,14 @@ do
84 end)()) 78 end)())
85end 79end
86do 80do
87 do 81 local _with_0
88 local _with_0 82 local _exp_0 = _u51fd_u6570A()
89 do 83 if _exp_0 ~= nil then
90 local _exp_0 = _u51fd_u6570A() 84 _with_0 = _exp_0
91 if _exp_0 ~= nil then 85 else
92 _with_0 = _exp_0 86 _with_0 = _u51fd_u6570B()
93 else
94 _with_0 = _u51fd_u6570B()
95 end
96 end
97 _u6253_u5370(_with_0["字段"])
98 end 87 end
88 _u6253_u5370(_with_0["字段"])
99end 89end
100do 90do
101 local _u53d8_u91cfa = 1 + 2 + (function() 91 local _u53d8_u91cfa = 1 + 2 + (function()
@@ -138,18 +128,16 @@ do
138end 128end
139do 129do
140 local _u53d8_u91cfa 130 local _u53d8_u91cfa
141 do 131 local _exp_0 = 1
142 local _exp_0 = 1 132 if _exp_0 ~= nil then
143 if _exp_0 ~= nil then 133 _u53d8_u91cfa = _exp_0
144 _u53d8_u91cfa = _exp_0 134 else
145 else 135 do
146 do 136 local _exp_1 = 2
147 local _exp_1 = 2 137 if _exp_1 ~= nil then
148 if _exp_1 ~= nil then 138 _u53d8_u91cfa = _exp_1
149 _u53d8_u91cfa = _exp_1 139 else
150 else 140 _u53d8_u91cfa = 3
151 _u53d8_u91cfa = 3
152 end
153 end 141 end
154 end 142 end
155 end 143 end
diff --git a/spec/outputs/unicode/stub.lua b/spec/outputs/unicode/stub.lua
index 5f183a1..426967b 100644
--- a/spec/outputs/unicode/stub.lua
+++ b/spec/outputs/unicode/stub.lua
@@ -15,12 +15,10 @@ end
15_u6253_u5370(_u51fd_u6570()) 15_u6253_u5370(_u51fd_u6570())
16_u6253_u5370(_u53d8_u91cfx["值"](_u53d8_u91cfx)); 16_u6253_u5370(_u53d8_u91cfx["值"](_u53d8_u91cfx));
17(function(...) 17(function(...)
18 do 18 local _base_0 = _u4f60_u597d(...)
19 local _base_0 = _u4f60_u597d(...) 19 local _fn_0 = _base_0["世界"]
20 local _fn_0 = _base_0["世界"] 20 _u53d8_u91cfx = _fn_0 and function(...)
21 _u53d8_u91cfx = _fn_0 and function(...) 21 return _fn_0(_base_0, ...)
22 return _fn_0(_base_0, ...)
23 end
24 end 22 end
25end)() 23end)()
26return nil 24return nil
diff --git a/spec/outputs/unicode/switch.lua b/spec/outputs/unicode/switch.lua
index 6b8bbdc..76c078c 100644
--- a/spec/outputs/unicode/switch.lua
+++ b/spec/outputs/unicode/switch.lua
@@ -45,13 +45,11 @@ do
45end 45end
46do 46do
47 local _with_0 = _u4e1c_u897f 47 local _with_0 = _u4e1c_u897f
48 do 48 local _exp_0 = _with_0["值"](_with_0)
49 local _exp_0 = _with_0["值"](_with_0) 49 if _with_0["确定"] == _exp_0 then
50 if _with_0["确定"] == _exp_0 then 50 local _u53d8_u91cf_ = "世界"
51 local _u53d8_u91cf_ = "世界" 51 else
52 else 52 local _u53d8_u91cf_ = "是的"
53 local _u53d8_u91cf_ = "是的"
54 end
55 end 53 end
56end 54end
57_u4fee_u590d(_u8fd9_u4e2a) 55_u4fee_u590d(_u8fd9_u4e2a)
@@ -106,66 +104,64 @@ do
106 } 104 }
107 } 105 }
108 } 106 }
109 do 107 local _type_0 = type(_u5b57_u5178)
110 local _type_0 = type(_u5b57_u5178) 108 local _tab_0 = "table" == _type_0 or "userdata" == _type_0
111 local _tab_0 = "table" == _type_0 or "userdata" == _type_0 109 if _tab_0 then
112 if _tab_0 then 110 local _u7b2c_u4e00 = _u5b57_u5178[1]
113 local _u7b2c_u4e00 = _u5b57_u5178[1] 111 local _u4e00_u4e2a
114 local _u4e00_u4e2a 112 do
115 do 113 local _obj_0 = _u5b57_u5178[2]
116 local _obj_0 = _u5b57_u5178[2] 114 local _type_1 = type(_obj_0)
117 local _type_1 = type(_obj_0) 115 if "table" == _type_1 or "userdata" == _type_1 then
118 if "table" == _type_1 or "userdata" == _type_1 then 116 _u4e00_u4e2a = _obj_0[1]
119 _u4e00_u4e2a = _obj_0[1]
120 end
121 end 117 end
122 local _u4e24_u4e2a 118 end
123 do 119 local _u4e24_u4e2a
124 local _obj_0 = _u5b57_u5178[2] 120 do
125 local _type_1 = type(_obj_0) 121 local _obj_0 = _u5b57_u5178[2]
126 if "table" == _type_1 or "userdata" == _type_1 then 122 local _type_1 = type(_obj_0)
127 _u4e24_u4e2a = _obj_0[2] 123 if "table" == _type_1 or "userdata" == _type_1 then
128 end 124 _u4e24_u4e2a = _obj_0[2]
129 end 125 end
130 local _u4e09_u4e2a 126 end
131 do 127 local _u4e09_u4e2a
132 local _obj_0 = _u5b57_u5178[2] 128 do
133 local _type_1 = type(_obj_0) 129 local _obj_0 = _u5b57_u5178[2]
134 if "table" == _type_1 or "userdata" == _type_1 then 130 local _type_1 = type(_obj_0)
135 _u4e09_u4e2a = _obj_0[3] 131 if "table" == _type_1 or "userdata" == _type_1 then
136 end 132 _u4e09_u4e2a = _obj_0[3]
137 end 133 end
138 local _u53d8_u91cfc 134 end
139 do 135 local _u53d8_u91cfc
140 local _obj_0 = _u5b57_u5178["å˜é‡a"] 136 do
141 local _type_1 = type(_obj_0) 137 local _obj_0 = _u5b57_u5178["å˜é‡a"]
142 if "table" == _type_1 or "userdata" == _type_1 then 138 local _type_1 = type(_obj_0)
143 do 139 if "table" == _type_1 or "userdata" == _type_1 then
144 local _obj_1 = _obj_0["å˜é‡b"] 140 do
145 local _type_2 = type(_obj_1) 141 local _obj_1 = _obj_0["å˜é‡b"]
146 if "table" == _type_2 or "userdata" == _type_2 then 142 local _type_2 = type(_obj_1)
147 _u53d8_u91cfc = _obj_1["å˜é‡c"] 143 if "table" == _type_2 or "userdata" == _type_2 then
148 end 144 _u53d8_u91cfc = _obj_1["å˜é‡c"]
149 end 145 end
150 end 146 end
151 end 147 end
152 local _u53d8_u91cfz 148 end
153 do 149 local _u53d8_u91cfz
154 local _obj_0 = _u5b57_u5178["å˜é‡x"] 150 do
155 local _type_1 = type(_obj_0) 151 local _obj_0 = _u5b57_u5178["å˜é‡x"]
156 if "table" == _type_1 or "userdata" == _type_1 then 152 local _type_1 = type(_obj_0)
157 do 153 if "table" == _type_1 or "userdata" == _type_1 then
158 local _obj_1 = _obj_0["å˜é‡y"] 154 do
159 local _type_2 = type(_obj_1) 155 local _obj_1 = _obj_0["å˜é‡y"]
160 if "table" == _type_2 or "userdata" == _type_2 then 156 local _type_2 = type(_obj_1)
161 _u53d8_u91cfz = _obj_1["å˜é‡z"] 157 if "table" == _type_2 or "userdata" == _type_2 then
162 end 158 _u53d8_u91cfz = _obj_1["å˜é‡z"]
163 end 159 end
164 end 160 end
165 end 161 end
166 if _u7b2c_u4e00 ~= nil and _u4e00_u4e2a ~= nil and _u4e24_u4e2a ~= nil and _u4e09_u4e2a ~= nil and _u53d8_u91cfc ~= nil and _u53d8_u91cfz ~= nil then 162 end
167 _u6253_u5370(_u7b2c_u4e00, _u4e00_u4e2a, _u4e24_u4e2a, _u4e09_u4e2a, _u53d8_u91cfc, _u53d8_u91cfz) 163 if _u7b2c_u4e00 ~= nil and _u4e00_u4e2a ~= nil and _u4e24_u4e2a ~= nil and _u4e09_u4e2a ~= nil and _u53d8_u91cfc ~= nil and _u53d8_u91cfz ~= nil then
168 end 164 _u6253_u5370(_u7b2c_u4e00, _u4e00_u4e2a, _u4e24_u4e2a, _u4e09_u4e2a, _u53d8_u91cfc, _u53d8_u91cfz)
169 end 165 end
170 end 166 end
171end 167end
@@ -183,56 +179,54 @@ do
183 } 179 }
184 for _index_0 = 1, #_u7269_u54c1 do 180 for _index_0 = 1, #_u7269_u54c1 do
185 local _u7269 = _u7269_u54c1[_index_0] 181 local _u7269 = _u7269_u54c1[_index_0]
186 do 182 local _type_0 = type(_u7269)
187 local _type_0 = type(_u7269) 183 local _tab_0 = "table" == _type_0 or "userdata" == _type_0
188 local _tab_0 = "table" == _type_0 or "userdata" == _type_0 184 local _match_0 = false
189 local _match_0 = false 185 if _tab_0 then
186 local _u53d8_u91cfx = _u7269["å˜é‡x"]
187 local _u53d8_u91cfy = _u7269["å˜é‡y"]
188 if _u53d8_u91cfx ~= nil and _u53d8_u91cfy ~= nil then
189 _match_0 = true
190 _u6253_u5370("Vec2 " .. tostring(_u53d8_u91cfx) .. ", " .. tostring(_u53d8_u91cfy))
191 end
192 end
193 if not _match_0 then
194 local _match_1 = false
190 if _tab_0 then 195 if _tab_0 then
191 local _u53d8_u91cfx = _u7269["å˜é‡x"] 196 local _u5bbd_u5ea6 = _u7269["宽度"]
192 local _u53d8_u91cfy = _u7269["å˜é‡y"] 197 local _u9ad8_u5ea6 = _u7269["高度"]
193 if _u53d8_u91cfx ~= nil and _u53d8_u91cfy ~= nil then 198 if _u5bbd_u5ea6 ~= nil and _u9ad8_u5ea6 ~= nil then
194 _match_0 = true 199 _match_1 = true
195 _u6253_u5370("Vec2 " .. tostring(_u53d8_u91cfx) .. ", " .. tostring(_u53d8_u91cfy)) 200 _u6253_u5370("Size " .. tostring(_u5bbd_u5ea6) .. ", " .. tostring(_u9ad8_u5ea6))
196 end 201 end
197 end 202 end
198 if not _match_0 then 203 if not _match_1 then
199 local _match_1 = false 204 if false == _u7269 then
200 if _tab_0 then 205 _u6253_u5370("没有")
201 local _u5bbd_u5ea6 = _u7269["宽度"] 206 else
202 local _u9ad8_u5ea6 = _u7269["高度"] 207 local _match_2 = false
203 if _u5bbd_u5ea6 ~= nil and _u9ad8_u5ea6 ~= nil then 208 if _tab_0 then
204 _match_1 = true 209 local _u7c7b = _u7269["__ç±»"]
205 _u6253_u5370("Size " .. tostring(_u5bbd_u5ea6) .. ", " .. tostring(_u9ad8_u5ea6)) 210 if _u7c7b ~= nil then
211 _match_2 = true
212 if _u7c7b_u522bA == _u7c7b then
213 _u6253_u5370("对象 A")
214 elseif _u7c7b_u522bB == _u7c7b then
215 _u6253_u5370("对象 B")
216 end
217 end
206 end 218 end
207 end 219 if not _match_2 then
208 if not _match_1 then 220 local _match_3 = false
209 if false == _u7269 then
210 _u6253_u5370("没有")
211 else
212 local _match_2 = false
213 if _tab_0 then 221 if _tab_0 then
214 local _u7c7b = _u7269["__ç±»"] 222 local _u8868 = getmetatable(_u7269)
215 if _u7c7b ~= nil then 223 if _u8868 ~= nil then
216 _match_2 = true 224 _match_3 = true
217 if _u7c7b_u522bA == _u7c7b then 225 _u6253_u5370("带有元表的表")
218 _u6253_u5370("对象 A")
219 elseif _u7c7b_u522bB == _u7c7b then
220 _u6253_u5370("对象 B")
221 end
222 end 226 end
223 end 227 end
224 if not _match_2 then 228 if not _match_3 then
225 local _match_3 = false 229 _u6253_u5370("物å“ä¸è¢«æŽ¥å—ï¼")
226 if _tab_0 then
227 local _u8868 = getmetatable(_u7269)
228 if _u8868 ~= nil then
229 _match_3 = true
230 _u6253_u5370("带有元表的表")
231 end
232 end
233 if not _match_3 then
234 _u6253_u5370("物å“ä¸è¢«æŽ¥å—ï¼")
235 end
236 end 230 end
237 end 231 end
238 end 232 end
@@ -271,72 +265,66 @@ do
271 end 265 end
272 end 266 end
273 end 267 end
274 do 268 local _type_0 = type(_u8868_u683c)
275 local _type_0 = type(_u8868_u683c) 269 local _tab_0 = "table" == _type_0 or "userdata" == _type_0
276 local _tab_0 = "table" == _type_0 or "userdata" == _type_0 270 local _match_0 = false
277 local _match_0 = false 271 if _tab_0 then
278 if _tab_0 then 272 local _u53d8_u91cfa = _u8868_u683c["å˜é‡a"]
279 local _u53d8_u91cfa = _u8868_u683c["å˜é‡a"] 273 local _u53d8_u91cfb = _u8868_u683c["å˜é‡b"]
280 local _u53d8_u91cfb = _u8868_u683c["å˜é‡b"] 274 if _u53d8_u91cfa ~= nil and _u53d8_u91cfb ~= nil then
281 if _u53d8_u91cfa ~= nil and _u53d8_u91cfb ~= nil then 275 _match_0 = true
282 _match_0 = true 276 _u6253_u5370(_u53d8_u91cfa, _u53d8_u91cfb)
283 _u6253_u5370(_u53d8_u91cfa, _u53d8_u91cfb)
284 end
285 end
286 if not _match_0 then
287 _u6253_u5370("没有匹é…")
288 end 277 end
289 end 278 end
279 if not _match_0 then
280 _u6253_u5370("没有匹é…")
281 end
290end 282end
291do 283do
292 local _u8868_u683c = { 284 local _u8868_u683c = {
293 ["å˜é‡x"] = "abc" 285 ["å˜é‡x"] = "abc"
294 } 286 }
295 do 287 local _type_0 = type(_u8868_u683c)
296 local _type_0 = type(_u8868_u683c) 288 local _tab_0 = "table" == _type_0 or "userdata" == _type_0
297 local _tab_0 = "table" == _type_0 or "userdata" == _type_0 289 local _match_0 = false
298 local _match_0 = false 290 if _tab_0 then
291 local _u53d8_u91cfx = _u8868_u683c["å˜é‡x"]
292 local _u53d8_u91cfy = _u8868_u683c["å˜é‡y"]
293 if _u53d8_u91cfx ~= nil and _u53d8_u91cfy ~= nil then
294 _match_0 = true
295 _u6253_u5370("å˜é‡x: " .. tostring(_u53d8_u91cfx) .. " å’Œ å˜é‡y: " .. tostring(_u53d8_u91cfy))
296 end
297 end
298 if not _match_0 then
299 if _tab_0 then 299 if _tab_0 then
300 local _u53d8_u91cfx = _u8868_u683c["å˜é‡x"] 300 local _u53d8_u91cfx = _u8868_u683c["å˜é‡x"]
301 local _u53d8_u91cfy = _u8868_u683c["å˜é‡y"] 301 if _u53d8_u91cfx ~= nil then
302 if _u53d8_u91cfx ~= nil and _u53d8_u91cfy ~= nil then 302 _u6253_u5370("åªæœ‰ å˜é‡x: " .. tostring(_u53d8_u91cfx))
303 _match_0 = true
304 _u6253_u5370("å˜é‡x: " .. tostring(_u53d8_u91cfx) .. " å’Œ å˜é‡y: " .. tostring(_u53d8_u91cfy))
305 end
306 end
307 if not _match_0 then
308 if _tab_0 then
309 local _u53d8_u91cfx = _u8868_u683c["å˜é‡x"]
310 if _u53d8_u91cfx ~= nil then
311 _u6253_u5370("åªæœ‰ å˜é‡x: " .. tostring(_u53d8_u91cfx))
312 end
313 end 303 end
314 end 304 end
315 end 305 end
316end 306end
317do 307do
318 local _u5339_u914d 308 local _u5339_u914d
319 do 309 local _exp_0 = _u8868_u683c
320 local _exp_0 = _u8868_u683c 310 if 1 == _exp_0 then
321 if 1 == _exp_0 then 311 _u5339_u914d = "1"
322 _u5339_u914d = "1" 312 else
323 else 313 local _type_0 = type(_exp_0)
324 local _type_0 = type(_exp_0) 314 local _tab_0 = "table" == _type_0 or "userdata" == _type_0
325 local _tab_0 = "table" == _type_0 or "userdata" == _type_0 315 local _match_0 = false
326 local _match_0 = false 316 if _tab_0 then
327 if _tab_0 then 317 local _u53d8_u91cfx = _exp_0["å˜é‡x"]
328 local _u53d8_u91cfx = _exp_0["å˜é‡x"] 318 if _u53d8_u91cfx ~= nil then
329 if _u53d8_u91cfx ~= nil then 319 _match_0 = true
330 _match_0 = true 320 _u5339_u914d = _u53d8_u91cfx
331 _u5339_u914d = _u53d8_u91cfx
332 end
333 end 321 end
334 if not _match_0 then 322 end
335 if false == _exp_0 then 323 if not _match_0 then
336 _u5339_u914d = "false" 324 if false == _exp_0 then
337 else 325 _u5339_u914d = "false"
338 _u5339_u914d = nil 326 else
339 end 327 _u5339_u914d = nil
340 end 328 end
341 end 329 end
342 end 330 end
@@ -346,55 +334,51 @@ do
346 if nil == _exp_0 then 334 if nil == _exp_0 then
347 return "无效" 335 return "无效"
348 else 336 else
349 do 337 local _type_0 = type(_exp_0)
350 local _type_0 = type(_exp_0) 338 local _tab_0 = "table" == _type_0 or "userdata" == _type_0
351 local _tab_0 = "table" == _type_0 or "userdata" == _type_0 339 local _match_0 = false
352 local _match_0 = false 340 if _tab_0 then
353 if _tab_0 then 341 local _u53d8_u91cfa = _exp_0["å˜é‡a"]
354 local _u53d8_u91cfa = _exp_0["å˜é‡a"] 342 local _u53d8_u91cfb = _exp_0["å˜é‡b"]
355 local _u53d8_u91cfb = _exp_0["å˜é‡b"] 343 if _u53d8_u91cfa ~= nil and _u53d8_u91cfb ~= nil then
356 if _u53d8_u91cfa ~= nil and _u53d8_u91cfb ~= nil then 344 _match_0 = true
357 _match_0 = true 345 return tostring(_u53d8_u91cfa + _u53d8_u91cfb)
358 return tostring(_u53d8_u91cfa + _u53d8_u91cfb)
359 end
360 end 346 end
361 if not _match_0 then 347 end
362 if 1 == _exp_0 or 2 == _exp_0 or 3 == _exp_0 or 4 == _exp_0 or 5 == _exp_0 then 348 if not _match_0 then
363 return "æ•°å­— 1 - 5" 349 if 1 == _exp_0 or 2 == _exp_0 or 3 == _exp_0 or 4 == _exp_0 or 5 == _exp_0 then
364 else 350 return "æ•°å­— 1 - 5"
365 local _match_1 = false 351 else
366 if _tab_0 then 352 local _match_1 = false
367 local _u5339_u914d_u4efb_u4f55_u8868_u683c = _exp_0["匹é…任何表格"] 353 if _tab_0 then
368 if _u5339_u914d_u4efb_u4f55_u8868_u683c == nil then 354 local _u5339_u914d_u4efb_u4f55_u8868_u683c = _exp_0["匹é…任何表格"]
369 _u5339_u914d_u4efb_u4f55_u8868_u683c = "åŽå¤‡" 355 if _u5339_u914d_u4efb_u4f55_u8868_u683c == nil then
370 end 356 _u5339_u914d_u4efb_u4f55_u8868_u683c = "åŽå¤‡"
371 _match_1 = true
372 return _u5339_u914d_u4efb_u4f55_u8868_u683c
373 end
374 if not _match_1 then
375 return "除éžå®ƒä¸æ˜¯ä¸€ä¸ªè¡¨æ ¼ï¼Œå¦åˆ™ä¸åº”到达这里"
376 end 357 end
358 _match_1 = true
359 return _u5339_u914d_u4efb_u4f55_u8868_u683c
360 end
361 if not _match_1 then
362 return "除éžå®ƒä¸æ˜¯ä¸€ä¸ªè¡¨æ ¼ï¼Œå¦åˆ™ä¸åº”到达这里"
377 end 363 end
378 end 364 end
379 end 365 end
380 end 366 end
381end 367end
382do 368do
383 do 369 local _exp_0 = _u53d8_u91cfy
384 local _exp_0 = _u53d8_u91cfy 370 local _type_0 = type(_exp_0)
385 local _type_0 = type(_exp_0) 371 local _tab_0 = "table" == _type_0 or "userdata" == _type_0
386 local _tab_0 = "table" == _type_0 or "userdata" == _type_0 372 if _tab_0 then
387 if _tab_0 then 373 local _u8868 = (function()
388 local _u8868 = (function() 374 local _obj_0 = _exp_0["å˜é‡x"]
389 local _obj_0 = _exp_0["å˜é‡x"] 375 if _obj_0 ~= nil then
390 if _obj_0 ~= nil then 376 return getmetatable(_obj_0)
391 return getmetatable(_obj_0)
392 end
393 return nil
394 end)()
395 if _u8868 ~= nil then
396 _u6253_u5370(_u8868)
397 end 377 end
378 return nil
379 end)()
380 if _u8868 ~= nil then
381 _u6253_u5370(_u8868)
398 end 382 end
399 end 383 end
400end 384end
diff --git a/spec/outputs/unicode/syntax.lua b/spec/outputs/unicode/syntax.lua
index f086db6..9ea8f68 100644
--- a/spec/outputs/unicode/syntax.lua
+++ b/spec/outputs/unicode/syntax.lua
@@ -235,15 +235,11 @@ else
235end 235end
236do 236do
237 local _with_0 = _u8868 237 local _with_0 = _u8868
238 do 238 local _obj_2 = _with_0["å˜é‡b"]["å˜é‡c"]
239 local _obj_2 = _with_0["å˜é‡b"]["å˜é‡c"] 239 local _with_1 = _u5411_u91cf
240 do 240 _with_1["字段x"] = 1
241 local _with_1 = _u5411_u91cf 241 _with_1["字段y"] = 2
242 _with_1["字段x"] = 1 242 _obj_2[#_obj_2 + 1] = _with_1
243 _with_1["字段y"] = 2
244 _obj_2[#_obj_2 + 1] = _with_1
245 end
246 end
247end 243end
248do 244do
249 local _call_8 = _u5bf9_u8c61a["å˜é‡b"]["å˜é‡c"]["å˜é‡d"] 245 local _call_8 = _u5bf9_u8c61a["å˜é‡b"]["å˜é‡c"]["å˜é‡d"]
diff --git a/spec/outputs/unicode/tables.lua b/spec/outputs/unicode/tables.lua
index 28ad6e2..82ca299 100644
--- a/spec/outputs/unicode/tables.lua
+++ b/spec/outputs/unicode/tables.lua
@@ -392,11 +392,9 @@ do
392 _tab_0[#_tab_0 + 1] = "b" 392 _tab_0[#_tab_0 + 1] = "b"
393 _tab_0[#_tab_0 + 1] = "c" 393 _tab_0[#_tab_0 + 1] = "c"
394 local _obj_1 394 local _obj_1
395 do 395 local _obj_2 = _u51fd_u6570
396 local _obj_2 = _u51fd_u6570 396 if _obj_2 ~= nil then
397 if _obj_2 ~= nil then 397 _obj_1 = _obj_2()
398 _obj_1 = _obj_2()
399 end
400 end 398 end
401 local _idx_1 = 1 399 local _idx_1 = 1
402 for _key_0, _value_0 in pairs(_obj_1) do 400 for _key_0, _value_0 in pairs(_obj_1) do
diff --git a/spec/outputs/unicode/vararg.lua b/spec/outputs/unicode/vararg.lua
index 4acb6cc..b837006 100644
--- a/spec/outputs/unicode/vararg.lua
+++ b/spec/outputs/unicode/vararg.lua
@@ -46,57 +46,53 @@ local _anon_func_5 = function(_u9879_u76ee, ...)
46end 46end
47local _anon_func_6 = function(_u51fd_u6570, setmetatable) 47local _anon_func_6 = function(_u51fd_u6570, setmetatable)
48 local _u53d8_u91cfA 48 local _u53d8_u91cfA
49 do 49 local _class_0
50 local _class_0 50 local _base_0 = { }
51 local _base_0 = { } 51 if _base_0.__index == nil then
52 if _base_0.__index == nil then 52 _base_0.__index = _base_0
53 _base_0.__index = _base_0 53 end
54 _class_0 = setmetatable({
55 __init = function() end,
56 __base = _base_0,
57 __name = "å˜é‡A"
58 }, {
59 __index = _base_0,
60 __call = function(cls, ...)
61 local _self_0 = setmetatable({ }, _base_0)
62 cls.__init(_self_0, ...)
63 return _self_0
54 end 64 end
55 _class_0 = setmetatable({ 65 })
56 __init = function() end, 66 _base_0.__class = _class_0
57 __base = _base_0, 67 local self = _class_0;
58 __name = "å˜é‡A" 68 _u51fd_u6570()
59 }, { 69 _u53d8_u91cfA = _class_0
60 __index = _base_0, 70 return _class_0
61 __call = function(cls, ...)
62 local _self_0 = setmetatable({ }, _base_0)
63 cls.__init(_self_0, ...)
64 return _self_0
65 end
66 })
67 _base_0.__class = _class_0
68 local self = _class_0;
69 _u51fd_u6570()
70 _u53d8_u91cfA = _class_0
71 return _class_0
72 end
73end 71end
74local _anon_func_7 = function(_u51fd_u6570, setmetatable, ...) 72local _anon_func_7 = function(_u51fd_u6570, setmetatable, ...)
75 local _u53d8_u91cfA 73 local _u53d8_u91cfA
76 do 74 local _class_0
77 local _class_0 75 local _base_0 = { }
78 local _base_0 = { } 76 if _base_0.__index == nil then
79 if _base_0.__index == nil then 77 _base_0.__index = _base_0
80 _base_0.__index = _base_0 78 end
79 _class_0 = setmetatable({
80 __init = function() end,
81 __base = _base_0,
82 __name = "å˜é‡A"
83 }, {
84 __index = _base_0,
85 __call = function(cls, ...)
86 local _self_0 = setmetatable({ }, _base_0)
87 cls.__init(_self_0, ...)
88 return _self_0
81 end 89 end
82 _class_0 = setmetatable({ 90 })
83 __init = function() end, 91 _base_0.__class = _class_0
84 __base = _base_0, 92 local self = _class_0;
85 __name = "å˜é‡A" 93 _u51fd_u6570(...)
86 }, { 94 _u53d8_u91cfA = _class_0
87 __index = _base_0, 95 return _class_0
88 __call = function(cls, ...)
89 local _self_0 = setmetatable({ }, _base_0)
90 cls.__init(_self_0, ...)
91 return _self_0
92 end
93 })
94 _base_0.__class = _class_0
95 local self = _class_0;
96 _u51fd_u6570(...)
97 _u53d8_u91cfA = _class_0
98 return _class_0
99 end
100end 96end
101local _anon_func_8 = function(_u8868, pairs) 97local _anon_func_8 = function(_u8868, pairs)
102 local _tbl_0 = { } 98 local _tbl_0 = { }
diff --git a/spec/outputs/unicode/with.lua b/spec/outputs/unicode/with.lua
index 0dcd4a7..7a5ba00 100644
--- a/spec/outputs/unicode/with.lua
+++ b/spec/outputs/unicode/with.lua
@@ -9,24 +9,20 @@ do
9 end 9 end
10end 10end
11do 11do
12 do 12 local _with_0 = _u53f6_u5b50
13 local _with_0 = _u53f6_u5b50 13 _with_0["世界"]()
14 _with_0["世界"]() 14 _with_0["世界"](1, 2, 3)
15 _with_0["世界"](1, 2, 3) 15 local _u53d8_u91cfg = _with_0["什么"]["是"]["这"]
16 local _u53d8_u91cfg = _with_0["什么"]["是"]["这"] 16 _with_0["你好"](1, 2, 3)
17 _with_0["你好"](1, 2, 3) 17 _with_0["你好"](_with_0, 1, 2)["世界"](2323)
18 _with_0["你好"](_with_0, 1, 2)["世界"](2323) 18 _with_0["你好"](_with_0, "是的", "伙计")
19 _with_0["你好"](_with_0, "是的", "伙计") 19 _with_0["世界"] = 200
20 _with_0["世界"] = 200
21 end
22end 20end
23do 21do
24 local _u6ecb_u6ecb_u6ecb 22 local _u6ecb_u6ecb_u6ecb
25 do 23 local _with_0 = _u4e1c_u897f
26 local _with_0 = _u4e1c_u897f 24 _with_0["设置状æ€"]("你好 世界")
27 _with_0["设置状æ€"]("你好 世界") 25 _u6ecb_u6ecb_u6ecb = _with_0
28 _u6ecb_u6ecb_u6ecb = _with_0
29 end
30end 26end
31do 27do
32 local _u53d8_u91cfx = 5 + (function() 28 local _u53d8_u91cfx = 5 + (function()
@@ -45,14 +41,12 @@ do
45 } 41 }
46end 42end
47do 43do
48 do 44 local _with_0 = _u4e1c_u897f
49 local _with_0 = _u4e1c_u897f 45 local _ = _with_0["属性"](_with_0, "æŸç‰©")["你好"]
50 local _ = _with_0["属性"](_with_0, "æŸç‰©")["你好"] 46 local _call_0 = _with_0["属性"]
51 local _call_0 = _with_0["属性"] 47 _call_0["å‘é€"](_call_0, _u4e00_u4e2a)
52 _call_0["å‘é€"](_call_0, _u4e00_u4e2a) 48 local _call_1 = _with_0["属性"]
53 local _call_1 = _with_0["属性"] 49 _call_1["å‘é€"](_call_1, _u4e00_u4e2a)
54 _call_1["å‘é€"](_call_1, _u4e00_u4e2a)
55 end
56end 50end
57do 51do
58 do 52 do
@@ -81,69 +75,49 @@ do
81 return _u53d8_u91cfa 75 return _u53d8_u91cfa
82 end)()) 76 end)())
83 local p 77 local p
84 do 78 local _with_0 = 1
85 local _with_0 = 1 79 _u4f60_u597d()["字段x"], _u4e16_u754c()["字段y"] = _with_0, 2
86 _u4f60_u597d()["字段x"], _u4e16_u754c()["字段y"] = _with_0, 2 80 _u6253_u5370(_u53d8_u91cfa + _u53d8_u91cfb)
87 _u6253_u5370(_u53d8_u91cfa + _u53d8_u91cfb) 81 p = _with_0
88 p = _with_0
89 end
90end 82end
91do 83do
92 local _u53d8_u91cfx = "你好" 84 local _u53d8_u91cfx = "你好"
93 _u53d8_u91cfx["大写"](_u53d8_u91cfx) 85 _u53d8_u91cfx["大写"](_u53d8_u91cfx)
94end 86end
95do 87do
96 do 88 local _u53d8_u91cfk = "ä¹”"
97 local _u53d8_u91cfk = "乔" 89 _u6253_u5370(_u53d8_u91cfk["大写"](_u53d8_u91cfk))
98 _u6253_u5370(_u53d8_u91cfk["大写"](_u53d8_u91cfk))
99 end
100end 90end
101do 91do
102 do 92 local _u53d8_u91cfa, _u53d8_u91cfb, _u53d8_u91cfc = "", "", ""
103 local _u53d8_u91cfa, _u53d8_u91cfb, _u53d8_u91cfc = "", "", "" 93 _u6253_u5370(_u53d8_u91cfa["大写"](_u53d8_u91cfa))
104 _u6253_u5370(_u53d8_u91cfa["大写"](_u53d8_u91cfa))
105 end
106end 94end
107do 95do
108 local _u53d8_u91cfa = "床铺" 96 local _u53d8_u91cfa = "床铺"
109 do 97 local _u53d8_u91cfb, _u53d8_u91cfc
110 local _u53d8_u91cfb, _u53d8_u91cfc 98 _u53d8_u91cfa, _u53d8_u91cfb, _u53d8_u91cfc = "", "", ""
111 _u53d8_u91cfa, _u53d8_u91cfb, _u53d8_u91cfc = "", "", "" 99 _u6253_u5370(_u53d8_u91cfa["大写"](_u53d8_u91cfa))
112 _u6253_u5370(_u53d8_u91cfa["大写"](_u53d8_u91cfa))
113 end
114end 100end
115do 101do
116 do 102 local _with_0 = _u53d8_u91cfj
117 local _with_0 = _u53d8_u91cfj 103 _u6253_u5370(_with_0["大写"](_with_0))
118 _u6253_u5370(_with_0["大写"](_with_0))
119 end
120end 104end
121do 105do
122 do 106 local _with_0 = "ä¹”"
123 local _with_0 = "ä¹”" 107 _u53d8_u91cfk["å˜é‡j"] = _with_0
124 _u53d8_u91cfk["å˜é‡j"] = _with_0 108 _u6253_u5370(_with_0["大写"](_with_0))
125 _u6253_u5370(_with_0["大写"](_with_0))
126 end
127end 109end
128do 110do
129 do 111 local _with_0 = _u53d8_u91cfa
130 local _with_0 = _u53d8_u91cfa 112 _u6253_u5370(_with_0.b)
131 _u6253_u5370(_with_0.b) 113 local _with_1 = _with_0.c
132 do 114 _u6253_u5370(_with_1.d)
133 local _with_1 = _with_0.c
134 _u6253_u5370(_with_1.d)
135 end
136 end
137end 115end
138do 116do
139 do 117 local _with_0 = _u53d8_u91cfa
140 local _with_0 = _u53d8_u91cfa 118 local _with_1 = 2
141 do 119 _with_0.b = _with_1
142 local _with_1 = 2 120 _u6253_u5370(_with_1.c)
143 _with_0.b = _with_1
144 _u6253_u5370(_with_1.c)
145 end
146 end
147end 121end
148do 122do
149 local _ 123 local _
@@ -153,44 +127,38 @@ do
153 end 127 end
154end 128end
155do 129do
156 do 130 local _with_0 = _u8868_u683c
157 local _with_0 = _u8868_u683c 131 local _call_0 = _u9879_u76ee["字段"]
158 local _call_0 = _u9879_u76ee["字段"] 132 _with_0.x = _call_0["函数"](_call_0, 123)
159 _with_0.x = _call_0["函数"](_call_0, 123)
160 end
161end 133end
162do 134do
163 do 135 local _with_0 = _u7238_u7238
164 local _with_0 = _u7238_u7238 136 _with_0["如果"]("是的")
165 _with_0["如果"]("是的") 137 local _u53d8_u91cfy = _with_0["结æŸ"]["函数"]
166 local _u53d8_u91cfy = _with_0["结æŸ"]["函数"]
167 end
168end 138end
169do 139do
140 local _with_0 = _u8868_u683c
170 do 141 do
171 local _with_0 = _u8868_u683c 142 local _obj_0 = _with_0[2]
172 do 143 if _obj_0 ~= nil then
173 local _obj_0 = _with_0[2] 144 _with_0[1] = _obj_0["函数"](_obj_0)
174 if _obj_0 ~= nil then
175 _with_0[1] = _obj_0["函数"](_obj_0)
176 end
177 end
178 _with_0["%a-b-c%"] = 123
179 _with_0[ [[x y z]]] = _with_0[_u53d8_u91cf]
180 _u6253_u5370(_with_0[_with_0[3]])
181 do
182 local _with_1 = _with_0[4]
183 _with_1[1] = 1
184 end 145 end
185 _with_0[#_with_0 + 1] = "abc"
186 _with_0[#_with_0 + 1] = {
187 ["类型"] = "你好",
188 {
189 ["åå­—"] = "xyz",
190 ["值"] = 998
191 }
192 }
193 end 146 end
147 _with_0["%a-b-c%"] = 123
148 _with_0[ [[x y z]]] = _with_0[_u53d8_u91cf]
149 _u6253_u5370(_with_0[_with_0[3]])
150 do
151 local _with_1 = _with_0[4]
152 _with_1[1] = 1
153 end
154 _with_0[#_with_0 + 1] = "abc"
155 _with_0[#_with_0 + 1] = {
156 ["类型"] = "你好",
157 {
158 ["åå­—"] = "xyz",
159 ["值"] = 998
160 }
161 }
194end 162end
195do 163do
196 do 164 do
@@ -207,16 +175,14 @@ do
207 end 175 end
208end 176end
209do 177do
210 do 178 local _u63a9_u7801 = _u5b9e_u5fc3_u77e9_u5f62({
211 local _u63a9_u7801 = _u5b9e_u5fc3_u77e9_u5f62({ 179 ["宽"] = w,
212 ["宽"] = w, 180 ["高"] = h,
213 ["高"] = h, 181 ["颜色"] = 0x66000000
214 ["颜色"] = 0x66000000 182 })
215 }) 183 if _u63a9_u7801 ~= nil then
216 if _u63a9_u7801 ~= nil then 184 _u63a9_u7801["触摸å¯ç”¨"] = true
217 _u63a9_u7801["触摸å¯ç”¨"] = true 185 _u63a9_u7801["åžå™¬è§¦æ‘¸"] = true
218 _u63a9_u7801["åžå™¬è§¦æ‘¸"] = true
219 end
220 end 186 end
221end 187end
222return nil 188return nil
diff --git a/spec/outputs/upvalue_func.lua b/spec/outputs/upvalue_func.lua
index 5768d2d..14fe400 100644
--- a/spec/outputs/upvalue_func.lua
+++ b/spec/outputs/upvalue_func.lua
@@ -320,28 +320,26 @@ local _anon_func_13 = function(pairs, tb)
320 return _accum_0 320 return _accum_0
321end 321end
322local _anon_func_14 = function(setmetatable) 322local _anon_func_14 = function(setmetatable)
323 do 323 local _class_0
324 local _class_0 324 local _base_0 = { }
325 local _base_0 = { } 325 if _base_0.__index == nil then
326 if _base_0.__index == nil then 326 _base_0.__index = _base_0
327 _base_0.__index = _base_0 327 end
328 _class_0 = setmetatable({
329 __init = function(self)
330 self.value = 1
331 end,
332 __base = _base_0
333 }, {
334 __index = _base_0,
335 __call = function(cls, ...)
336 local _self_0 = setmetatable({ }, _base_0)
337 cls.__init(_self_0, ...)
338 return _self_0
328 end 339 end
329 _class_0 = setmetatable({ 340 })
330 __init = function(self) 341 _base_0.__class = _class_0
331 self.value = 1 342 return _class_0
332 end,
333 __base = _base_0
334 }, {
335 __index = _base_0,
336 __call = function(cls, ...)
337 local _self_0 = setmetatable({ }, _base_0)
338 cls.__init(_self_0, ...)
339 return _self_0
340 end
341 })
342 _base_0.__class = _class_0
343 return _class_0
344 end
345end 343end
346local _anon_func_15 = function(tb) 344local _anon_func_15 = function(tb)
347 tb.field = 1 345 tb.field = 1
diff --git a/spec/outputs/vararg.lua b/spec/outputs/vararg.lua
index 27918e9..dabba44 100644
--- a/spec/outputs/vararg.lua
+++ b/spec/outputs/vararg.lua
@@ -46,57 +46,53 @@ local _anon_func_5 = function(items, ...)
46end 46end
47local _anon_func_6 = function(func, setmetatable) 47local _anon_func_6 = function(func, setmetatable)
48 local A 48 local A
49 do 49 local _class_0
50 local _class_0 50 local _base_0 = { }
51 local _base_0 = { } 51 if _base_0.__index == nil then
52 if _base_0.__index == nil then 52 _base_0.__index = _base_0
53 _base_0.__index = _base_0 53 end
54 _class_0 = setmetatable({
55 __init = function() end,
56 __base = _base_0,
57 __name = "A"
58 }, {
59 __index = _base_0,
60 __call = function(cls, ...)
61 local _self_0 = setmetatable({ }, _base_0)
62 cls.__init(_self_0, ...)
63 return _self_0
54 end 64 end
55 _class_0 = setmetatable({ 65 })
56 __init = function() end, 66 _base_0.__class = _class_0
57 __base = _base_0, 67 local self = _class_0;
58 __name = "A" 68 func()
59 }, { 69 A = _class_0
60 __index = _base_0, 70 return _class_0
61 __call = function(cls, ...)
62 local _self_0 = setmetatable({ }, _base_0)
63 cls.__init(_self_0, ...)
64 return _self_0
65 end
66 })
67 _base_0.__class = _class_0
68 local self = _class_0;
69 func()
70 A = _class_0
71 return _class_0
72 end
73end 71end
74local _anon_func_7 = function(func, setmetatable, ...) 72local _anon_func_7 = function(func, setmetatable, ...)
75 local A 73 local A
76 do 74 local _class_0
77 local _class_0 75 local _base_0 = { }
78 local _base_0 = { } 76 if _base_0.__index == nil then
79 if _base_0.__index == nil then 77 _base_0.__index = _base_0
80 _base_0.__index = _base_0 78 end
79 _class_0 = setmetatable({
80 __init = function() end,
81 __base = _base_0,
82 __name = "A"
83 }, {
84 __index = _base_0,
85 __call = function(cls, ...)
86 local _self_0 = setmetatable({ }, _base_0)
87 cls.__init(_self_0, ...)
88 return _self_0
81 end 89 end
82 _class_0 = setmetatable({ 90 })
83 __init = function() end, 91 _base_0.__class = _class_0
84 __base = _base_0, 92 local self = _class_0;
85 __name = "A" 93 func(...)
86 }, { 94 A = _class_0
87 __index = _base_0, 95 return _class_0
88 __call = function(cls, ...)
89 local _self_0 = setmetatable({ }, _base_0)
90 cls.__init(_self_0, ...)
91 return _self_0
92 end
93 })
94 _base_0.__class = _class_0
95 local self = _class_0;
96 func(...)
97 A = _class_0
98 return _class_0
99 end
100end 96end
101local _anon_func_8 = function(pairs, tb) 97local _anon_func_8 = function(pairs, tb)
102 local _tbl_0 = { } 98 local _tbl_0 = { }
diff --git a/spec/outputs/with.lua b/spec/outputs/with.lua
index 304d26e..b2a1c3b 100644
--- a/spec/outputs/with.lua
+++ b/spec/outputs/with.lua
@@ -9,24 +9,20 @@ do
9 end 9 end
10end 10end
11do 11do
12 do 12 local _with_0 = leaf
13 local _with_0 = leaf 13 _with_0.world()
14 _with_0.world() 14 _with_0.world(1, 2, 3)
15 _with_0.world(1, 2, 3) 15 local g = _with_0.what.is.this
16 local g = _with_0.what.is.this 16 _with_0.hi(1, 2, 3)
17 _with_0.hi(1, 2, 3) 17 _with_0:hi(1, 2).world(2323)
18 _with_0:hi(1, 2).world(2323) 18 _with_0:hi("yeah", "man")
19 _with_0:hi("yeah", "man") 19 _with_0.world = 200
20 _with_0.world = 200
21 end
22end 20end
23do 21do
24 local zyzyzy 22 local zyzyzy
25 do 23 local _with_0 = something
26 local _with_0 = something 24 _with_0.set_state("hello world")
27 _with_0.set_state("hello world") 25 zyzyzy = _with_0
28 zyzyzy = _with_0
29 end
30end 26end
31do 27do
32 local x = 5 + (function() 28 local x = 5 + (function()
@@ -45,12 +41,10 @@ do
45 } 41 }
46end 42end
47do 43do
48 do 44 local _with_0 = foo
49 local _with_0 = foo 45 local _ = _with_0:prop("something").hello
50 local _ = _with_0:prop("something").hello 46 _with_0.prop:send(one)
51 _with_0.prop:send(one) 47 _with_0.prop:send(one)
52 _with_0.prop:send(one)
53 end
54end 48end
55do 49do
56 do 50 do
@@ -79,69 +73,49 @@ do
79 return a 73 return a
80 end)()) 74 end)())
81 local p 75 local p
82 do 76 local _with_0 = 1
83 local _with_0 = 1 77 hello().x, world().y = _with_0, 2
84 hello().x, world().y = _with_0, 2 78 print(a + b)
85 print(a + b) 79 p = _with_0
86 p = _with_0
87 end
88end 80end
89do 81do
90 local x = "hello" 82 local x = "hello"
91 x:upper() 83 x:upper()
92end 84end
93do 85do
94 do 86 local k = "jo"
95 local k = "jo" 87 print(k:upper())
96 print(k:upper())
97 end
98end 88end
99do 89do
100 do 90 local a, b, c = "", "", ""
101 local a, b, c = "", "", "" 91 print(a:upper())
102 print(a:upper())
103 end
104end 92end
105do 93do
106 local a = "bunk" 94 local a = "bunk"
107 do 95 local b, c
108 local b, c 96 a, b, c = "", "", ""
109 a, b, c = "", "", "" 97 print(a:upper())
110 print(a:upper())
111 end
112end 98end
113do 99do
114 do 100 local _with_0 = j
115 local _with_0 = j 101 print(_with_0:upper())
116 print(_with_0:upper())
117 end
118end 102end
119do 103do
120 do 104 local _with_0 = "jo"
121 local _with_0 = "jo" 105 k.j = _with_0
122 k.j = _with_0 106 print(_with_0:upper())
123 print(_with_0:upper())
124 end
125end 107end
126do 108do
127 do 109 local _with_0 = a
128 local _with_0 = a 110 print(_with_0.b)
129 print(_with_0.b) 111 local _with_1 = _with_0.c
130 do 112 print(_with_1.d)
131 local _with_1 = _with_0.c
132 print(_with_1.d)
133 end
134 end
135end 113end
136do 114do
137 do 115 local _with_0 = a
138 local _with_0 = a 116 local _with_1 = 2
139 do 117 _with_0.b = _with_1
140 local _with_1 = 2 118 print(_with_1.c)
141 _with_0.b = _with_1
142 print(_with_1.c)
143 end
144 end
145end 119end
146do 120do
147 local _ 121 local _
@@ -151,43 +125,37 @@ do
151 end 125 end
152end 126end
153do 127do
154 do 128 local _with_0 = tb
155 local _with_0 = tb 129 _with_0.x = item.field:func(123)
156 _with_0.x = item.field:func(123)
157 end
158end 130end
159do 131do
160 do 132 local _with_0 = dad
161 local _with_0 = dad 133 _with_0["if"]("yes")
162 _with_0["if"]("yes") 134 local y = _with_0["end"].of["function"]
163 local y = _with_0["end"].of["function"]
164 end
165end 135end
166do 136do
137 local _with_0 = tb
167 do 138 do
168 local _with_0 = tb 139 local _obj_0 = _with_0[2]
169 do 140 if _obj_0 ~= nil then
170 local _obj_0 = _with_0[2] 141 _with_0[1] = _obj_0:func()
171 if _obj_0 ~= nil then
172 _with_0[1] = _obj_0:func()
173 end
174 end
175 _with_0["%a-b-c%"] = 123
176 _with_0[ [[x y z]]] = _with_0[var]
177 print(_with_0[_with_0[3]])
178 do
179 local _with_1 = _with_0[4]
180 _with_1[1] = 1
181 end 142 end
182 _with_0[#_with_0 + 1] = "abc"
183 _with_0[#_with_0 + 1] = {
184 type = "hello",
185 {
186 name = "xyz",
187 value = 998
188 }
189 }
190 end 143 end
144 _with_0["%a-b-c%"] = 123
145 _with_0[ [[x y z]]] = _with_0[var]
146 print(_with_0[_with_0[3]])
147 do
148 local _with_1 = _with_0[4]
149 _with_1[1] = 1
150 end
151 _with_0[#_with_0 + 1] = "abc"
152 _with_0[#_with_0 + 1] = {
153 type = "hello",
154 {
155 name = "xyz",
156 value = 998
157 }
158 }
191end 159end
192do 160do
193 do 161 do
@@ -204,16 +172,14 @@ do
204 end 172 end
205end 173end
206do 174do
207 do 175 local mask = SolidRect({
208 local mask = SolidRect({ 176 width = w,
209 width = w, 177 height = h,
210 height = h, 178 color = 0x66000000
211 color = 0x66000000 179 })
212 }) 180 if mask ~= nil then
213 if mask ~= nil then 181 mask.touchEnabled = true
214 mask.touchEnabled = true 182 mask.swallowTouches = true
215 mask.swallowTouches = true
216 end
217 end 183 end
218end 184end
219return nil 185return nil