diff options
54 files changed, 4013 insertions, 4534 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 | |||
| 25 | do | 25 | do |
| 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 | ||
| 33 | end | 31 | end |
| 34 | do | 32 | do |
| 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 | ||
| 42 | end | 38 | end |
| 43 | do | 39 | do |
| 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) |
| 14 | for i = 1, 10 do | 14 | for 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) |
| 41 | end | 47 | end |
| 42 | do | 48 | do |
| 43 | print(123) | 49 | do |
| 50 | print(123) | ||
| 51 | end | ||
| 44 | end | 52 | end |
| 45 | do | 53 | do |
| 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 | ||
| 113 | end | 119 | end |
| 114 | return nil | 120 | return 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 | |||
| 14 | do | 14 | do |
| 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 | ||
| 22 | end | 20 | end |
| 23 | do | 21 | do |
| 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 | ||
| 31 | end | 27 | end |
| 32 | do | 28 | do |
| 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)()) |
| 32 | end | 32 | end |
| 33 | do | 33 | do |
| 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 |
| 48 | end | 46 | end |
| 49 | do | 47 | do |
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 | ||
| 123 | end | 121 | end |
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") | |||
| 496 | local yyy | 496 | local yyy |
| 497 | yyy = function() | 497 | yyy = 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 | ||
| 523 | end | 521 | end |
| 524 | do | 522 | do |
| 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 | |||
| 46 | return _module_0 | 46 | return _module_0 |
| 47 | local area = 6.2831853071796 * 5 | 47 | local area = 6.2831853071796 * 5 |
| 48 | print('hello world') | 48 | print('hello world') |
| 49 | assert(item ~= nil) | 49 | do |
| 50 | assert(item ~= nil) | ||
| 51 | end | ||
| 50 | local value = item | 52 | local value = item |
| 51 | if (f1() and f2() and f3()) then | 53 | if (f1() and f2() and f3()) then |
| 52 | print("OK") | 54 | print("OK") |
| 53 | end | 55 | end |
| 56 | do | ||
| 57 | local funcA | ||
| 58 | funcA = function() end | ||
| 59 | end | ||
| 54 | local funcA | 60 | local funcA |
| 55 | funcA = function() end | ||
| 56 | funcA = function() | 61 | funcA = function() |
| 57 | return "assign the Yue defined variable" | 62 | return "assign the Yue defined variable" |
| 58 | end | 63 | end |
| @@ -146,28 +151,26 @@ local b = { | |||
| 146 | y = 1 | 151 | y = 1 |
| 147 | } | 152 | } |
| 148 | local merge | 153 | local merge |
| 149 | do | 154 | local _tab_0 = { } |
| 150 | local _tab_0 = { } | 155 | local _idx_0 = 1 |
| 151 | local _idx_0 = 1 | 156 | for _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 | 163 | end |
| 161 | for _key_0, _value_0 in pairs(b) do | 164 | local _idx_1 = 1 |
| 162 | if _idx_1 == _key_0 then | 165 | for _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 | ||
| 170 | end | 172 | end |
| 173 | merge = _tab_0 | ||
| 171 | local mt = { } | 174 | local mt = { } |
| 172 | local add | 175 | local add |
| 173 | add = function(self, right) | 176 | add = function(self, right) |
| @@ -259,12 +262,10 @@ end | |||
| 259 | if print and (x ~= nil) then | 262 | if print and (x ~= nil) then |
| 260 | print(x) | 263 | print(x) |
| 261 | end | 264 | end |
| 262 | do | 265 | local _with_0 = io.open("test.txt", "w") |
| 263 | local _with_0 = io.open("test.txt", "w") | 266 | if _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 | ||
| 268 | end | 269 | end |
| 269 | print("hello") | 270 | print("hello") |
| 270 | print(1, 2) | 271 | print(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 | ||
| 348 | end | 347 | end |
| 349 | do | 348 | do |
| 350 | local module = require('module') | 349 | local module = require('module') |
| @@ -383,29 +382,27 @@ y = function() | |||
| 383 | end | 382 | end |
| 384 | _module_0["y"] = y | 383 | _module_0["y"] = y |
| 385 | local Something | 384 | local Something |
| 386 | do | 385 | local _class_0 |
| 387 | local _class_0 | 386 | local _base_0 = { |
| 388 | local _base_0 = { | 387 | umm = "cool" |
| 389 | umm = "cool" | 388 | } |
| 390 | } | 389 | if _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 | ||
| 408 | end | 391 | end |
| 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 | ||
| 405 | Something = _class_0 | ||
| 409 | _module_0["Something"] = Something | 406 | _module_0["Something"] = Something |
| 410 | return _module_0 | 407 | return _module_0 |
| 411 | local _module_0 = { } | 408 | local _module_0 = { } |
| @@ -436,11 +433,9 @@ if this then | |||
| 436 | else | 433 | else |
| 437 | _module_0[#_module_0 + 1] = 456 | 434 | _module_0[#_module_0 + 1] = 456 |
| 438 | end | 435 | end |
| 439 | do | 436 | local _with_0 = tmp |
| 440 | local _with_0 = tmp | 437 | local j = 2000 |
| 441 | local j = 2000 | 438 | _module_0[#_module_0 + 1] = _with_0 |
| 442 | _module_0[#_module_0 + 1] = _with_0 | ||
| 443 | end | ||
| 444 | return _module_0 | 439 | return _module_0 |
| 445 | local _module_0 = nil | 440 | local _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) |
| 579 | end | 574 | end |
| 580 | do | 575 | local user = database.find_user("moon") |
| 581 | local user = database.find_user("moon") | 576 | if user then |
| 582 | if user then | 577 | print(user.name) |
| 583 | print(user.name) | ||
| 584 | end | ||
| 585 | end | 578 | end |
| 586 | do | 579 | local hello = os.getenv("hello") |
| 587 | local hello = os.getenv("hello") | 580 | if hello then |
| 588 | if hello then | 581 | print("You have hello", hello) |
| 589 | print("You have hello", hello) | 582 | else |
| 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 |
| 600 | end | 589 | end |
| 601 | do | 590 | do |
| @@ -858,40 +847,34 @@ local items = { | |||
| 858 | 4 | 847 | 4 |
| 859 | } | 848 | } |
| 860 | local doubled | 849 | local doubled |
| 861 | do | 850 | local _accum_0 = { } |
| 862 | local _accum_0 = { } | 851 | local _len_0 = 1 |
| 863 | local _len_0 = 1 | 852 | for 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 | ||
| 869 | end | 855 | end |
| 856 | doubled = _accum_0 | ||
| 870 | local iter = ipairs(items) | 857 | local iter = ipairs(items) |
| 871 | local slice | 858 | local slice |
| 872 | do | 859 | local _accum_0 = { } |
| 873 | local _accum_0 = { } | 860 | local _len_0 = 1 |
| 874 | local _len_0 = 1 | 861 | for 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 | ||
| 882 | end | 866 | end |
| 867 | slice = _accum_0 | ||
| 883 | local doubled | 868 | local doubled |
| 884 | do | 869 | local _accum_0 = { } |
| 885 | local _accum_0 = { } | 870 | local _len_0 = 1 |
| 886 | local _len_0 = 1 | 871 | local _list_0 = items |
| 887 | local _list_0 = items | 872 | for _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 | ||
| 894 | end | 876 | end |
| 877 | doubled = _accum_0 | ||
| 895 | local x_coords = { | 878 | local x_coords = { |
| 896 | 4, | 879 | 4, |
| 897 | 5, | 880 | 5, |
| @@ -904,57 +887,49 @@ local y_coords = { | |||
| 904 | 3 | 887 | 3 |
| 905 | } | 888 | } |
| 906 | local points | 889 | local points |
| 907 | do | 890 | local _accum_0 = { } |
| 908 | local _accum_0 = { } | 891 | local _len_0 = 1 |
| 909 | local _len_0 = 1 | 892 | for _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 | ||
| 922 | end | 902 | end |
| 903 | points = _accum_0 | ||
| 923 | local evens | 904 | local evens |
| 924 | do | 905 | local _accum_0 = { } |
| 925 | local _accum_0 = { } | 906 | local _len_0 = 1 |
| 926 | local _len_0 = 1 | 907 | for 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 | ||
| 934 | end | 912 | end |
| 913 | evens = _accum_0 | ||
| 935 | local thing = { | 914 | local thing = { |
| 936 | color = "red", | 915 | color = "red", |
| 937 | name = "fast", | 916 | name = "fast", |
| 938 | width = 123 | 917 | width = 123 |
| 939 | } | 918 | } |
| 940 | local thing_copy | 919 | local thing_copy |
| 941 | do | 920 | local _tbl_0 = { } |
| 942 | local _tbl_0 = { } | 921 | for 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 | ||
| 947 | end | 923 | end |
| 924 | thing_copy = _tbl_0 | ||
| 948 | local no_color | 925 | local no_color |
| 949 | do | 926 | local _tbl_0 = { } |
| 950 | local _tbl_0 = { } | 927 | for 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 | ||
| 957 | end | 931 | end |
| 932 | no_color = _tbl_0 | ||
| 958 | local numbers = { | 933 | local numbers = { |
| 959 | 1, | 934 | 1, |
| 960 | 2, | 935 | 2, |
| @@ -962,14 +937,12 @@ local numbers = { | |||
| 962 | 4 | 937 | 4 |
| 963 | } | 938 | } |
| 964 | local sqrts | 939 | local sqrts |
| 965 | do | 940 | local _tbl_0 = { } |
| 966 | local _tbl_0 = { } | 941 | for _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 | ||
| 972 | end | 944 | end |
| 945 | sqrts = _tbl_0 | ||
| 973 | local tuples = { | 946 | local tuples = { |
| 974 | { | 947 | { |
| 975 | "hello", | 948 | "hello", |
| @@ -981,52 +954,44 @@ local tuples = { | |||
| 981 | } | 954 | } |
| 982 | } | 955 | } |
| 983 | local tbl | 956 | local tbl |
| 984 | do | 957 | local _tbl_0 = { } |
| 985 | local _tbl_0 = { } | 958 | for _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 | ||
| 992 | end | 962 | end |
| 963 | tbl = _tbl_0 | ||
| 993 | local slice | 964 | local slice |
| 994 | do | 965 | local _accum_0 = { } |
| 995 | local _accum_0 = { } | 966 | local _len_0 = 1 |
| 996 | local _len_0 = 1 | 967 | local _list_0 = items |
| 997 | local _list_0 = items | 968 | local _max_0 = 5 |
| 998 | local _max_0 = 5 | 969 | for _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 | ||
| 1005 | end | 973 | end |
| 974 | slice = _accum_0 | ||
| 1006 | local slice | 975 | local slice |
| 1007 | do | 976 | local _accum_0 = { } |
| 1008 | local _accum_0 = { } | 977 | local _len_0 = 1 |
| 1009 | local _len_0 = 1 | 978 | local _list_0 = items |
| 1010 | local _list_0 = items | 979 | for _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 | ||
| 1017 | end | 983 | end |
| 984 | slice = _accum_0 | ||
| 1018 | local slice | 985 | local slice |
| 1019 | do | 986 | local _accum_0 = { } |
| 1020 | local _accum_0 = { } | 987 | local _len_0 = 1 |
| 1021 | local _len_0 = 1 | 988 | local _list_0 = items |
| 1022 | local _list_0 = items | 989 | for _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 | ||
| 1029 | end | 993 | end |
| 994 | slice = _accum_0 | ||
| 1030 | for i = 10, 20 do | 995 | for i = 10, 20 do |
| 1031 | print(i) | 996 | print(i) |
| 1032 | end | 997 | end |
| @@ -1036,13 +1001,11 @@ end | |||
| 1036 | for key, value in pairs(object) do | 1001 | for key, value in pairs(object) do |
| 1037 | print(key, value) | 1002 | print(key, value) |
| 1038 | end | 1003 | end |
| 1039 | do | 1004 | local _list_0 = items |
| 1040 | local _list_0 = items | 1005 | local _max_0 = 4 |
| 1041 | local _max_0 = 4 | 1006 | for _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 | ||
| 1046 | end | 1009 | end |
| 1047 | local _list_0 = items | 1010 | local _list_0 = items |
| 1048 | for _index_0 = 1, #_list_0 do | 1011 | for _index_0 = 1, #_list_0 do |
| @@ -1053,19 +1016,17 @@ for j = 1, 10, 3 do | |||
| 1053 | print(j) | 1016 | print(j) |
| 1054 | end | 1017 | end |
| 1055 | local doubled_evens | 1018 | local doubled_evens |
| 1056 | do | 1019 | local _accum_0 = { } |
| 1057 | local _accum_0 = { } | 1020 | local _len_0 = 1 |
| 1058 | local _len_0 = 1 | 1021 | for 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 |
| 1068 | end | 1028 | end |
| 1029 | doubled_evens = _accum_0 | ||
| 1069 | local func_a | 1030 | local func_a |
| 1070 | func_a = function() | 1031 | func_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 | } |
| 1125 | local odds | 1086 | local odds |
| 1126 | do | 1087 | local _accum_0 = { } |
| 1127 | local _accum_0 = { } | 1088 | local _len_0 = 1 |
| 1128 | local _len_0 = 1 | 1089 | for _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:: | ||
| 1139 | end | 1097 | end |
| 1098 | odds = _accum_0 | ||
| 1140 | local have_coins = false | 1099 | local have_coins = false |
| 1141 | if have_coins then | 1100 | if 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!") |
| 1229 | end | 1188 | end |
| 1230 | local msg | 1189 | local msg |
| 1231 | do | 1190 | local _exp_0 = math.random(1, 5) |
| 1232 | local _exp_0 = math.random(1, 5) | 1191 | if 1 == _exp_0 then |
| 1233 | if 1 == _exp_0 then | 1192 | msg = "you are lucky" |
| 1234 | msg = "you are lucky" | 1193 | elseif 2 == _exp_0 then |
| 1235 | elseif 2 == _exp_0 then | 1194 | msg = "you are almost lucky" |
| 1236 | msg = "you are almost lucky" | 1195 | else |
| 1237 | else | 1196 | msg = "not so lucky" |
| 1238 | msg = "not so lucky" | ||
| 1239 | end | ||
| 1240 | end | 1197 | end |
| 1241 | do | 1198 | do |
| 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 |
| 1248 | end | 1205 | end |
| 1249 | do | 1206 | local _exp_0 = math.random(1, 5) |
| 1250 | local _exp_0 = math.random(1, 5) | 1207 | if 1 == _exp_0 then |
| 1251 | if 1 == _exp_0 then | 1208 | print("you are lucky") |
| 1252 | print("you are lucky") | 1209 | else |
| 1253 | else | 1210 | print("not so lucky") |
| 1254 | print("not so lucky") | ||
| 1255 | end | ||
| 1256 | end | 1211 | end |
| 1257 | local items = { | 1212 | local items = { |
| 1258 | { | 1213 | { |
| @@ -1266,25 +1221,23 @@ local items = { | |||
| 1266 | } | 1221 | } |
| 1267 | for _index_0 = 1, #items do | 1222 | for _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 | |||
| 1297 | if y == nil then | 1250 | if y == nil then |
| 1298 | y = 200 | 1251 | y = 200 |
| 1299 | end | 1252 | end |
| 1300 | do | 1253 | local _type_0 = type(item) |
| 1301 | local _type_0 = type(item) | 1254 | local _tab_0 = "table" == _type_0 or "userdata" == _type_0 |
| 1302 | local _tab_0 = "table" == _type_0 or "userdata" == _type_0 | 1255 | if _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)) | ||
| 1326 | end | 1277 | end |
| 1327 | local Inventory | 1278 | local Inventory |
| 1328 | do | 1279 | local _class_0 |
| 1329 | local _class_0 | 1280 | local _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) | 1290 | if _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 | ||
| 1359 | end | 1292 | end |
| 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 | ||
| 1308 | Inventory = _class_0 | ||
| 1360 | local inv = Inventory() | 1309 | local inv = Inventory() |
| 1361 | inv:add_item("t-shirt") | 1310 | inv:add_item("t-shirt") |
| 1362 | inv:add_item("pants") | 1311 | inv:add_item("pants") |
| @@ -1397,82 +1346,78 @@ for _index_0 = 1, #_list_0 do | |||
| 1397 | print(item) | 1346 | print(item) |
| 1398 | end | 1347 | end |
| 1399 | local Person | 1348 | local Person |
| 1400 | do | 1349 | local _class_0 |
| 1401 | local _class_0 | 1350 | local _base_0 = { } |
| 1402 | local _base_0 = { } | 1351 | if _base_0.__index == nil then |
| 1403 | if _base_0.__index == nil then | 1352 | _base_0.__index = _base_0 |
| 1404 | _base_0.__index = _base_0 | 1353 | end |
| 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 = { } | 1369 | Person = _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 | ||
| 1422 | end | ||
| 1423 | local BackPack | 1370 | local BackPack |
| 1424 | do | 1371 | local _class_0 |
| 1425 | local _class_0 | 1372 | local _parent_0 = Inventory |
| 1426 | local _parent_0 = Inventory | 1373 | local _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 | 1382 | for _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) | 1386 | end |
| 1445 | _class_0 = setmetatable({ | 1387 | if _base_0.__index == nil then |
| 1446 | __init = function(self, ...) | 1388 | _base_0.__index = _base_0 |
| 1447 | return _class_0.__parent.__init(self, ...) | 1389 | end |
| 1448 | end, | 1390 | setmetatable(_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 | ||
| 1417 | if _parent_0.__inherited then | ||
| 1418 | _parent_0.__inherited(_parent_0, _class_0) | ||
| 1475 | end | 1419 | end |
| 1420 | BackPack = _class_0 | ||
| 1476 | local Shelf | 1421 | local Shelf |
| 1477 | do | 1422 | do |
| 1478 | local _class_0 | 1423 | local _class_0 |
| @@ -1500,102 +1445,98 @@ do | |||
| 1500 | Shelf = _class_0 | 1445 | Shelf = _class_0 |
| 1501 | end | 1446 | end |
| 1502 | local Cupboard | 1447 | local Cupboard |
| 1503 | do | 1448 | local _class_0 |
| 1504 | local _class_0 | 1449 | local _parent_0 = Shelf |
| 1505 | local _parent_0 = Shelf | 1450 | local _base_0 = { } |
| 1506 | local _base_0 = { } | 1451 | for _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 | 1455 | end |
| 1511 | end | 1456 | if _base_0.__index == nil then |
| 1512 | if _base_0.__index == nil then | 1457 | _base_0.__index = _base_0 |
| 1513 | _base_0.__index = _base_0 | 1458 | end |
| 1514 | end | 1459 | setmetatable(_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 | ||
| 1486 | if _parent_0.__inherited then | ||
| 1487 | _parent_0.__inherited(_parent_0, _class_0) | ||
| 1546 | end | 1488 | end |
| 1489 | Cupboard = _class_0 | ||
| 1547 | local MyClass | 1490 | local MyClass |
| 1548 | do | 1491 | local _class_0 |
| 1549 | local _class_0 | 1492 | local _parent_0 = ParentClass |
| 1550 | local _parent_0 = ParentClass | 1493 | local _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 | } | 1501 | for _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 | 1505 | end |
| 1563 | end | 1506 | if _base_0.__index == nil then |
| 1564 | if _base_0.__index == nil then | 1507 | _base_0.__index = _base_0 |
| 1565 | _base_0.__index = _base_0 | 1508 | end |
| 1566 | end | 1509 | setmetatable(_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 | ||
| 1536 | if _parent_0.__inherited then | ||
| 1537 | _parent_0.__inherited(_parent_0, _class_0) | ||
| 1598 | end | 1538 | end |
| 1539 | MyClass = _class_0 | ||
| 1599 | local b = BackPack() | 1540 | local b = BackPack() |
| 1600 | assert(b.__class == BackPack) | 1541 | assert(b.__class == BackPack) |
| 1601 | print(BackPack.size) | 1542 | print(BackPack.size) |
| @@ -1659,61 +1600,57 @@ Counter() | |||
| 1659 | print(Counter.count) | 1600 | print(Counter.count) |
| 1660 | self.__class:hello(1, 2, 3, 4) | 1601 | self.__class:hello(1, 2, 3, 4) |
| 1661 | local Things | 1602 | local Things |
| 1662 | do | 1603 | local _class_0 |
| 1663 | local _class_0 | 1604 | local _base_0 = { } |
| 1664 | local _base_0 = { } | 1605 | if _base_0.__index == nil then |
| 1665 | if _base_0.__index == nil then | 1606 | _base_0.__index = _base_0 |
| 1666 | _base_0.__index = _base_0 | 1607 | end |
| 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, | 1621 | local self = _class_0; |
| 1671 | __name = "Things" | 1622 | self.class_var = "hello world" |
| 1672 | }, { | 1623 | Things = _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 | ||
| 1684 | end | ||
| 1685 | local MoreThings | 1624 | local MoreThings |
| 1686 | do | 1625 | local _class_0 |
| 1687 | local _class_0 | 1626 | local secret, log |
| 1688 | local secret, log | 1627 | local _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, | 1632 | if _base_0.__index == nil then |
| 1699 | __base = _base_0, | 1633 | _base_0.__index = _base_0 |
| 1700 | __name = "MoreThings" | 1634 | end |
| 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 | ||
| 1648 | local self = _class_0; | ||
| 1649 | secret = 123 | ||
| 1650 | log = function(msg) | ||
| 1651 | return print("LOG:", msg) | ||
| 1716 | end | 1652 | end |
| 1653 | MoreThings = _class_0 | ||
| 1717 | assert(self == self) | 1654 | assert(self == self) |
| 1718 | assert(self.__class == self.__class) | 1655 | assert(self.__class == self.__class) |
| 1719 | local some_instance_method | 1656 | local 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 |
| 1749 | end | 1686 | end |
| 1750 | do | 1687 | local _class_0 |
| 1751 | local _class_0 | 1688 | local _base_0 = { } |
| 1752 | local _base_0 = { } | 1689 | if _base_0.__index == nil then |
| 1753 | if _base_0.__index == nil then | 1690 | _base_0.__index = _base_0 |
| 1754 | _base_0.__index = _base_0 | 1691 | end |
| 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 | 1710 | Something = _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 | ||
| 1775 | end | ||
| 1776 | local new | 1711 | local new |
| 1777 | new = function(self, fieldA, fieldB) | 1712 | new = function(self, fieldA, fieldB) |
| 1778 | self.fieldA = fieldA | 1713 | self.fieldA = fieldA |
| @@ -1783,33 +1718,31 @@ local obj = new({ }, 123, "abc") | |||
| 1783 | print(obj) | 1718 | print(obj) |
| 1784 | local x | 1719 | local x |
| 1785 | local Bucket | 1720 | local Bucket |
| 1786 | do | 1721 | local _class_0 |
| 1787 | local _class_0 | 1722 | local _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, | 1728 | if _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 | ||
| 1812 | end | 1730 | end |
| 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 | ||
| 1744 | Bucket = _class_0 | ||
| 1745 | x = _class_0 | ||
| 1813 | local BigBucket | 1746 | local BigBucket |
| 1814 | do | 1747 | do |
| 1815 | local _class_0 | 1748 | local _class_0 |
| @@ -1861,27 +1794,25 @@ do | |||
| 1861 | end | 1794 | end |
| 1862 | assert(Bucket.__name == "BigBucket") | 1795 | assert(Bucket.__name == "BigBucket") |
| 1863 | local x | 1796 | local x |
| 1864 | do | 1797 | local _class_0 |
| 1865 | local _class_0 | 1798 | local _base_0 = { } |
| 1866 | local _base_0 = { } | 1799 | if _base_0.__index == nil then |
| 1867 | if _base_0.__index == nil then | 1800 | _base_0.__index = _base_0 |
| 1868 | _base_0.__index = _base_0 | 1801 | end |
| 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, | 1815 | x = _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 | ||
| 1884 | end | ||
| 1885 | local MyIndex = { | 1816 | local MyIndex = { |
| 1886 | __index = { | 1817 | __index = { |
| 1887 | var = 1 | 1818 | var = 1 |
| @@ -1964,19 +1895,15 @@ end | |||
| 1964 | local y = Y() | 1895 | local y = Y() |
| 1965 | y:func() | 1896 | y:func() |
| 1966 | assert(y.__class.__parent ~= X) | 1897 | assert(y.__class.__parent ~= X) |
| 1967 | do | 1898 | local _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() | 1902 | print(_with_0.name) |
| 1972 | print(_with_0.name) | ||
| 1973 | end | ||
| 1974 | local file | 1903 | local file |
| 1975 | do | 1904 | local _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") | 1906 | file = _with_0 |
| 1978 | file = _with_0 | ||
| 1979 | end | ||
| 1980 | local create_person | 1907 | local create_person |
| 1981 | create_person = function(name, relatives) | 1908 | create_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 | }) |
| 1922 | local str = "Hello" | ||
| 1923 | print("original:", str) | ||
| 1924 | print("upper:", str:upper()) | ||
| 1925 | local _with_0 = tb | ||
| 1926 | _with_0[1] = 1 | ||
| 1927 | print(_with_0[2]) | ||
| 1995 | do | 1928 | do |
| 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 |
| 1999 | end | ||
| 2000 | do | ||
| 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" | ||
| 2010 | end | 1932 | end |
| 1933 | _with_0[#_with_0 + 1] = "abc" | ||
| 2011 | do | 1934 | do |
| 2012 | local var = "hello" | 1935 | local var = "hello" |
| 2013 | print(var) | 1936 | print(var) |
| @@ -2124,13 +2047,18 @@ _module_0["🌛"] = _ud83c_udf1b | |||
| 2124 | return _module_0 | 2047 | return _module_0 |
| 2125 | local area = 6.2831853071796 * 5 | 2048 | local area = 6.2831853071796 * 5 |
| 2126 | print('hello world') | 2049 | print('hello world') |
| 2127 | assert(item ~= nil) | 2050 | do |
| 2051 | assert(item ~= nil) | ||
| 2052 | end | ||
| 2128 | local value = item | 2053 | local value = item |
| 2129 | if (f1() and f2() and f3()) then | 2054 | if (f1() and f2() and f3()) then |
| 2130 | print("OK") | 2055 | print("OK") |
| 2131 | end | 2056 | end |
| 2057 | do | ||
| 2058 | local funcA | ||
| 2059 | funcA = function() end | ||
| 2060 | end | ||
| 2132 | local funcA | 2061 | local funcA |
| 2133 | funcA = function() end | ||
| 2134 | funcA = function() | 2062 | funcA = function() |
| 2135 | return "assign the Yue defined variable" | 2063 | return "assign the Yue defined variable" |
| 2136 | end | 2064 | end |
| @@ -2224,28 +2152,26 @@ local b = { | |||
| 2224 | y = 1 | 2152 | y = 1 |
| 2225 | } | 2153 | } |
| 2226 | local merge | 2154 | local merge |
| 2227 | do | 2155 | local _tab_0 = { } |
| 2228 | local _tab_0 = { } | 2156 | local _idx_0 = 1 |
| 2229 | local _idx_0 = 1 | 2157 | for _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 | 2164 | end |
| 2239 | for _key_0, _value_0 in pairs(b) do | 2165 | local _idx_1 = 1 |
| 2240 | if _idx_1 == _key_0 then | 2166 | for _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 | ||
| 2248 | end | 2173 | end |
| 2174 | merge = _tab_0 | ||
| 2249 | local mt = { } | 2175 | local mt = { } |
| 2250 | local add | 2176 | local add |
| 2251 | add = function(self, right) | 2177 | add = function(self, right) |
| @@ -2337,12 +2263,10 @@ end | |||
| 2337 | if print and (x ~= nil) then | 2263 | if print and (x ~= nil) then |
| 2338 | print(x) | 2264 | print(x) |
| 2339 | end | 2265 | end |
| 2340 | do | 2266 | local _with_0 = io.open("test.txt", "w") |
| 2341 | local _with_0 = io.open("test.txt", "w") | 2267 | if _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 | ||
| 2346 | end | 2270 | end |
| 2347 | print("hello") | 2271 | print("hello") |
| 2348 | print(1, 2) | 2272 | print(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 | ||
| 2426 | end | 2348 | end |
| 2427 | do | 2349 | do |
| 2428 | local module = require('module') | 2350 | local module = require('module') |
| @@ -2461,29 +2383,27 @@ y = function() | |||
| 2461 | end | 2383 | end |
| 2462 | _module_0["y"] = y | 2384 | _module_0["y"] = y |
| 2463 | local Something | 2385 | local Something |
| 2464 | do | 2386 | local _class_0 |
| 2465 | local _class_0 | 2387 | local _base_0 = { |
| 2466 | local _base_0 = { | 2388 | umm = "cool" |
| 2467 | umm = "cool" | 2389 | } |
| 2468 | } | 2390 | if _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 | ||
| 2486 | end | 2392 | end |
| 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 | ||
| 2406 | Something = _class_0 | ||
| 2487 | _module_0["Something"] = Something | 2407 | _module_0["Something"] = Something |
| 2488 | return _module_0 | 2408 | return _module_0 |
| 2489 | local _module_0 = { } | 2409 | local _module_0 = { } |
| @@ -2514,11 +2434,9 @@ if this then | |||
| 2514 | else | 2434 | else |
| 2515 | _module_0[#_module_0 + 1] = 456 | 2435 | _module_0[#_module_0 + 1] = 456 |
| 2516 | end | 2436 | end |
| 2517 | do | 2437 | local _with_0 = tmp |
| 2518 | local _with_0 = tmp | 2438 | local j = 2000 |
| 2519 | local j = 2000 | 2439 | _module_0[#_module_0 + 1] = _with_0 |
| 2520 | _module_0[#_module_0 + 1] = _with_0 | ||
| 2521 | end | ||
| 2522 | return _module_0 | 2440 | return _module_0 |
| 2523 | local _module_0 = nil | 2441 | local _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) |
| 2657 | end | 2575 | end |
| 2658 | do | 2576 | local user = database.find_user("moon") |
| 2659 | local user = database.find_user("moon") | 2577 | if user then |
| 2660 | if user then | 2578 | print(user.name) |
| 2661 | print(user.name) | ||
| 2662 | end | ||
| 2663 | end | 2579 | end |
| 2664 | do | 2580 | local hello = os.getenv("hello") |
| 2665 | local hello = os.getenv("hello") | 2581 | if hello then |
| 2666 | if hello then | 2582 | print("You have hello", hello) |
| 2667 | print("You have hello", hello) | 2583 | else |
| 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 |
| 2678 | end | 2590 | end |
| 2679 | do | 2591 | do |
| @@ -2936,40 +2848,34 @@ local items = { | |||
| 2936 | 4 | 2848 | 4 |
| 2937 | } | 2849 | } |
| 2938 | local doubled | 2850 | local doubled |
| 2939 | do | 2851 | local _accum_0 = { } |
| 2940 | local _accum_0 = { } | 2852 | local _len_0 = 1 |
| 2941 | local _len_0 = 1 | 2853 | for 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 | ||
| 2947 | end | 2856 | end |
| 2857 | doubled = _accum_0 | ||
| 2948 | local iter = ipairs(items) | 2858 | local iter = ipairs(items) |
| 2949 | local slice | 2859 | local slice |
| 2950 | do | 2860 | local _accum_0 = { } |
| 2951 | local _accum_0 = { } | 2861 | local _len_0 = 1 |
| 2952 | local _len_0 = 1 | 2862 | for 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 | ||
| 2960 | end | 2867 | end |
| 2868 | slice = _accum_0 | ||
| 2961 | local doubled | 2869 | local doubled |
| 2962 | do | 2870 | local _accum_0 = { } |
| 2963 | local _accum_0 = { } | 2871 | local _len_0 = 1 |
| 2964 | local _len_0 = 1 | 2872 | local _list_0 = items |
| 2965 | local _list_0 = items | 2873 | for _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 | ||
| 2972 | end | 2877 | end |
| 2878 | doubled = _accum_0 | ||
| 2973 | local x_coords = { | 2879 | local x_coords = { |
| 2974 | 4, | 2880 | 4, |
| 2975 | 5, | 2881 | 5, |
| @@ -2982,57 +2888,49 @@ local y_coords = { | |||
| 2982 | 3 | 2888 | 3 |
| 2983 | } | 2889 | } |
| 2984 | local points | 2890 | local points |
| 2985 | do | 2891 | local _accum_0 = { } |
| 2986 | local _accum_0 = { } | 2892 | local _len_0 = 1 |
| 2987 | local _len_0 = 1 | 2893 | for _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 | ||
| 3000 | end | 2903 | end |
| 2904 | points = _accum_0 | ||
| 3001 | local evens | 2905 | local evens |
| 3002 | do | 2906 | local _accum_0 = { } |
| 3003 | local _accum_0 = { } | 2907 | local _len_0 = 1 |
| 3004 | local _len_0 = 1 | 2908 | for 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 | ||
| 3012 | end | 2913 | end |
| 2914 | evens = _accum_0 | ||
| 3013 | local thing = { | 2915 | local thing = { |
| 3014 | color = "red", | 2916 | color = "red", |
| 3015 | name = "fast", | 2917 | name = "fast", |
| 3016 | width = 123 | 2918 | width = 123 |
| 3017 | } | 2919 | } |
| 3018 | local thing_copy | 2920 | local thing_copy |
| 3019 | do | 2921 | local _tbl_0 = { } |
| 3020 | local _tbl_0 = { } | 2922 | for 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 | ||
| 3025 | end | 2924 | end |
| 2925 | thing_copy = _tbl_0 | ||
| 3026 | local no_color | 2926 | local no_color |
| 3027 | do | 2927 | local _tbl_0 = { } |
| 3028 | local _tbl_0 = { } | 2928 | for 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 | ||
| 3035 | end | 2932 | end |
| 2933 | no_color = _tbl_0 | ||
| 3036 | local numbers = { | 2934 | local numbers = { |
| 3037 | 1, | 2935 | 1, |
| 3038 | 2, | 2936 | 2, |
| @@ -3040,14 +2938,12 @@ local numbers = { | |||
| 3040 | 4 | 2938 | 4 |
| 3041 | } | 2939 | } |
| 3042 | local sqrts | 2940 | local sqrts |
| 3043 | do | 2941 | local _tbl_0 = { } |
| 3044 | local _tbl_0 = { } | 2942 | for _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 | ||
| 3050 | end | 2945 | end |
| 2946 | sqrts = _tbl_0 | ||
| 3051 | local tuples = { | 2947 | local tuples = { |
| 3052 | { | 2948 | { |
| 3053 | "hello", | 2949 | "hello", |
| @@ -3059,52 +2955,44 @@ local tuples = { | |||
| 3059 | } | 2955 | } |
| 3060 | } | 2956 | } |
| 3061 | local tbl | 2957 | local tbl |
| 3062 | do | 2958 | local _tbl_0 = { } |
| 3063 | local _tbl_0 = { } | 2959 | for _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 | ||
| 3070 | end | 2963 | end |
| 2964 | tbl = _tbl_0 | ||
| 3071 | local slice | 2965 | local slice |
| 3072 | do | 2966 | local _accum_0 = { } |
| 3073 | local _accum_0 = { } | 2967 | local _len_0 = 1 |
| 3074 | local _len_0 = 1 | 2968 | local _list_0 = items |
| 3075 | local _list_0 = items | 2969 | local _max_0 = 5 |
| 3076 | local _max_0 = 5 | 2970 | for _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 | ||
| 3083 | end | 2974 | end |
| 2975 | slice = _accum_0 | ||
| 3084 | local slice | 2976 | local slice |
| 3085 | do | 2977 | local _accum_0 = { } |
| 3086 | local _accum_0 = { } | 2978 | local _len_0 = 1 |
| 3087 | local _len_0 = 1 | 2979 | local _list_0 = items |
| 3088 | local _list_0 = items | 2980 | for _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 | ||
| 3095 | end | 2984 | end |
| 2985 | slice = _accum_0 | ||
| 3096 | local slice | 2986 | local slice |
| 3097 | do | 2987 | local _accum_0 = { } |
| 3098 | local _accum_0 = { } | 2988 | local _len_0 = 1 |
| 3099 | local _len_0 = 1 | 2989 | local _list_0 = items |
| 3100 | local _list_0 = items | 2990 | for _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 | ||
| 3107 | end | 2994 | end |
| 2995 | slice = _accum_0 | ||
| 3108 | for i = 10, 20 do | 2996 | for i = 10, 20 do |
| 3109 | print(i) | 2997 | print(i) |
| 3110 | end | 2998 | end |
| @@ -3114,13 +3002,11 @@ end | |||
| 3114 | for key, value in pairs(object) do | 3002 | for key, value in pairs(object) do |
| 3115 | print(key, value) | 3003 | print(key, value) |
| 3116 | end | 3004 | end |
| 3117 | do | 3005 | local _list_0 = items |
| 3118 | local _list_0 = items | 3006 | local _max_0 = 4 |
| 3119 | local _max_0 = 4 | 3007 | for _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 | ||
| 3124 | end | 3010 | end |
| 3125 | local _list_0 = items | 3011 | local _list_0 = items |
| 3126 | for _index_0 = 1, #_list_0 do | 3012 | for _index_0 = 1, #_list_0 do |
| @@ -3131,19 +3017,17 @@ for j = 1, 10, 3 do | |||
| 3131 | print(j) | 3017 | print(j) |
| 3132 | end | 3018 | end |
| 3133 | local doubled_evens | 3019 | local doubled_evens |
| 3134 | do | 3020 | local _accum_0 = { } |
| 3135 | local _accum_0 = { } | 3021 | local _len_0 = 1 |
| 3136 | local _len_0 = 1 | 3022 | for 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 |
| 3146 | end | 3029 | end |
| 3030 | doubled_evens = _accum_0 | ||
| 3147 | local func_a | 3031 | local func_a |
| 3148 | func_a = function() | 3032 | func_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 | } |
| 3203 | local odds | 3087 | local odds |
| 3204 | do | 3088 | local _accum_0 = { } |
| 3205 | local _accum_0 = { } | 3089 | local _len_0 = 1 |
| 3206 | local _len_0 = 1 | 3090 | for _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:: | ||
| 3217 | end | 3098 | end |
| 3099 | odds = _accum_0 | ||
| 3218 | local have_coins = false | 3100 | local have_coins = false |
| 3219 | if have_coins then | 3101 | if 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!") |
| 3307 | end | 3189 | end |
| 3308 | local msg | 3190 | local msg |
| 3309 | do | 3191 | local _exp_0 = math.random(1, 5) |
| 3310 | local _exp_0 = math.random(1, 5) | 3192 | if 1 == _exp_0 then |
| 3311 | if 1 == _exp_0 then | 3193 | msg = "you are lucky" |
| 3312 | msg = "you are lucky" | 3194 | elseif 2 == _exp_0 then |
| 3313 | elseif 2 == _exp_0 then | 3195 | msg = "you are almost lucky" |
| 3314 | msg = "you are almost lucky" | 3196 | else |
| 3315 | else | 3197 | msg = "not so lucky" |
| 3316 | msg = "not so lucky" | ||
| 3317 | end | ||
| 3318 | end | 3198 | end |
| 3319 | do | 3199 | do |
| 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 |
| 3326 | end | 3206 | end |
| 3327 | do | 3207 | local _exp_0 = math.random(1, 5) |
| 3328 | local _exp_0 = math.random(1, 5) | 3208 | if 1 == _exp_0 then |
| 3329 | if 1 == _exp_0 then | 3209 | print("you are lucky") |
| 3330 | print("you are lucky") | 3210 | else |
| 3331 | else | 3211 | print("not so lucky") |
| 3332 | print("not so lucky") | ||
| 3333 | end | ||
| 3334 | end | 3212 | end |
| 3335 | local items = { | 3213 | local items = { |
| 3336 | { | 3214 | { |
| @@ -3344,25 +3222,23 @@ local items = { | |||
| 3344 | } | 3222 | } |
| 3345 | for _index_0 = 1, #items do | 3223 | for _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 | |||
| 3375 | if y == nil then | 3251 | if y == nil then |
| 3376 | y = 200 | 3252 | y = 200 |
| 3377 | end | 3253 | end |
| 3378 | do | 3254 | local _type_0 = type(item) |
| 3379 | local _type_0 = type(item) | 3255 | local _tab_0 = "table" == _type_0 or "userdata" == _type_0 |
| 3380 | local _tab_0 = "table" == _type_0 or "userdata" == _type_0 | 3256 | if _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)) | ||
| 3404 | end | 3278 | end |
| 3405 | local Inventory | 3279 | local Inventory |
| 3406 | do | 3280 | local _class_0 |
| 3407 | local _class_0 | 3281 | local _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) | 3291 | if _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 | ||
| 3437 | end | 3293 | end |
| 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 | ||
| 3309 | Inventory = _class_0 | ||
| 3438 | local inv = Inventory() | 3310 | local inv = Inventory() |
| 3439 | inv:add_item("t-shirt") | 3311 | inv:add_item("t-shirt") |
| 3440 | inv:add_item("pants") | 3312 | inv:add_item("pants") |
| @@ -3475,82 +3347,78 @@ for _index_0 = 1, #_list_0 do | |||
| 3475 | print(item) | 3347 | print(item) |
| 3476 | end | 3348 | end |
| 3477 | local Person | 3349 | local Person |
| 3478 | do | 3350 | local _class_0 |
| 3479 | local _class_0 | 3351 | local _base_0 = { } |
| 3480 | local _base_0 = { } | 3352 | if _base_0.__index == nil then |
| 3481 | if _base_0.__index == nil then | 3353 | _base_0.__index = _base_0 |
| 3482 | _base_0.__index = _base_0 | 3354 | end |
| 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 = { } | 3370 | Person = _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 | ||
| 3500 | end | ||
| 3501 | local BackPack | 3371 | local BackPack |
| 3502 | do | 3372 | local _class_0 |
| 3503 | local _class_0 | 3373 | local _parent_0 = Inventory |
| 3504 | local _parent_0 = Inventory | 3374 | local _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 | 3383 | for _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) | 3387 | end |
| 3523 | _class_0 = setmetatable({ | 3388 | if _base_0.__index == nil then |
| 3524 | __init = function(self, ...) | 3389 | _base_0.__index = _base_0 |
| 3525 | return _class_0.__parent.__init(self, ...) | 3390 | end |
| 3526 | end, | 3391 | setmetatable(_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 | ||
| 3418 | if _parent_0.__inherited then | ||
| 3419 | _parent_0.__inherited(_parent_0, _class_0) | ||
| 3553 | end | 3420 | end |
| 3421 | BackPack = _class_0 | ||
| 3554 | local Shelf | 3422 | local Shelf |
| 3555 | do | 3423 | do |
| 3556 | local _class_0 | 3424 | local _class_0 |
| @@ -3578,102 +3446,98 @@ do | |||
| 3578 | Shelf = _class_0 | 3446 | Shelf = _class_0 |
| 3579 | end | 3447 | end |
| 3580 | local Cupboard | 3448 | local Cupboard |
| 3581 | do | 3449 | local _class_0 |
| 3582 | local _class_0 | 3450 | local _parent_0 = Shelf |
| 3583 | local _parent_0 = Shelf | 3451 | local _base_0 = { } |
| 3584 | local _base_0 = { } | 3452 | for _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 | 3456 | end |
| 3589 | end | 3457 | if _base_0.__index == nil then |
| 3590 | if _base_0.__index == nil then | 3458 | _base_0.__index = _base_0 |
| 3591 | _base_0.__index = _base_0 | 3459 | end |
| 3592 | end | 3460 | setmetatable(_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 | ||
| 3487 | if _parent_0.__inherited then | ||
| 3488 | _parent_0.__inherited(_parent_0, _class_0) | ||
| 3624 | end | 3489 | end |
| 3490 | Cupboard = _class_0 | ||
| 3625 | local MyClass | 3491 | local MyClass |
| 3626 | do | 3492 | local _class_0 |
| 3627 | local _class_0 | 3493 | local _parent_0 = ParentClass |
| 3628 | local _parent_0 = ParentClass | 3494 | local _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 | } | 3502 | for _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 | 3506 | end |
| 3641 | end | 3507 | if _base_0.__index == nil then |
| 3642 | if _base_0.__index == nil then | 3508 | _base_0.__index = _base_0 |
| 3643 | _base_0.__index = _base_0 | 3509 | end |
| 3644 | end | 3510 | setmetatable(_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 | ||
| 3537 | if _parent_0.__inherited then | ||
| 3538 | _parent_0.__inherited(_parent_0, _class_0) | ||
| 3676 | end | 3539 | end |
| 3540 | MyClass = _class_0 | ||
| 3677 | local b = BackPack() | 3541 | local b = BackPack() |
| 3678 | assert(b.__class == BackPack) | 3542 | assert(b.__class == BackPack) |
| 3679 | print(BackPack.size) | 3543 | print(BackPack.size) |
| @@ -3737,61 +3601,57 @@ Counter() | |||
| 3737 | print(Counter.count) | 3601 | print(Counter.count) |
| 3738 | self.__class:hello(1, 2, 3, 4) | 3602 | self.__class:hello(1, 2, 3, 4) |
| 3739 | local Things | 3603 | local Things |
| 3740 | do | 3604 | local _class_0 |
| 3741 | local _class_0 | 3605 | local _base_0 = { } |
| 3742 | local _base_0 = { } | 3606 | if _base_0.__index == nil then |
| 3743 | if _base_0.__index == nil then | 3607 | _base_0.__index = _base_0 |
| 3744 | _base_0.__index = _base_0 | 3608 | end |
| 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, | 3622 | local self = _class_0; |
| 3749 | __name = "Things" | 3623 | self.class_var = "hello world" |
| 3750 | }, { | 3624 | Things = _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 | ||
| 3762 | end | ||
| 3763 | local MoreThings | 3625 | local MoreThings |
| 3764 | do | 3626 | local _class_0 |
| 3765 | local _class_0 | 3627 | local secret, log |
| 3766 | local secret, log | 3628 | local _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, | 3633 | if _base_0.__index == nil then |
| 3777 | __base = _base_0, | 3634 | _base_0.__index = _base_0 |
| 3778 | __name = "MoreThings" | 3635 | end |
| 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 | ||
| 3649 | local self = _class_0; | ||
| 3650 | secret = 123 | ||
| 3651 | log = function(msg) | ||
| 3652 | return print("LOG:", msg) | ||
| 3794 | end | 3653 | end |
| 3654 | MoreThings = _class_0 | ||
| 3795 | assert(self == self) | 3655 | assert(self == self) |
| 3796 | assert(self.__class == self.__class) | 3656 | assert(self.__class == self.__class) |
| 3797 | local some_instance_method | 3657 | local 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 |
| 3827 | end | 3687 | end |
| 3828 | do | 3688 | local _class_0 |
| 3829 | local _class_0 | 3689 | local _base_0 = { } |
| 3830 | local _base_0 = { } | 3690 | if _base_0.__index == nil then |
| 3831 | if _base_0.__index == nil then | 3691 | _base_0.__index = _base_0 |
| 3832 | _base_0.__index = _base_0 | 3692 | end |
| 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 | 3711 | Something = _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 | ||
| 3853 | end | ||
| 3854 | local new | 3712 | local new |
| 3855 | new = function(self, fieldA, fieldB) | 3713 | new = function(self, fieldA, fieldB) |
| 3856 | self.fieldA = fieldA | 3714 | self.fieldA = fieldA |
| @@ -3861,33 +3719,31 @@ local obj = new({ }, 123, "abc") | |||
| 3861 | print(obj) | 3719 | print(obj) |
| 3862 | local x | 3720 | local x |
| 3863 | local Bucket | 3721 | local Bucket |
| 3864 | do | 3722 | local _class_0 |
| 3865 | local _class_0 | 3723 | local _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, | 3729 | if _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 | ||
| 3890 | end | 3731 | end |
| 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 | ||
| 3745 | Bucket = _class_0 | ||
| 3746 | x = _class_0 | ||
| 3891 | local BigBucket | 3747 | local BigBucket |
| 3892 | do | 3748 | do |
| 3893 | local _class_0 | 3749 | local _class_0 |
| @@ -3939,27 +3795,25 @@ do | |||
| 3939 | end | 3795 | end |
| 3940 | assert(Bucket.__name == "BigBucket") | 3796 | assert(Bucket.__name == "BigBucket") |
| 3941 | local x | 3797 | local x |
| 3942 | do | 3798 | local _class_0 |
| 3943 | local _class_0 | 3799 | local _base_0 = { } |
| 3944 | local _base_0 = { } | 3800 | if _base_0.__index == nil then |
| 3945 | if _base_0.__index == nil then | 3801 | _base_0.__index = _base_0 |
| 3946 | _base_0.__index = _base_0 | 3802 | end |
| 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, | 3816 | x = _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 | ||
| 3962 | end | ||
| 3963 | local MyIndex = { | 3817 | local MyIndex = { |
| 3964 | __index = { | 3818 | __index = { |
| 3965 | var = 1 | 3819 | var = 1 |
| @@ -4042,19 +3896,15 @@ end | |||
| 4042 | local y = Y() | 3896 | local y = Y() |
| 4043 | y:func() | 3897 | y:func() |
| 4044 | assert(y.__class.__parent ~= X) | 3898 | assert(y.__class.__parent ~= X) |
| 4045 | do | 3899 | local _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() | 3903 | print(_with_0.name) |
| 4050 | print(_with_0.name) | ||
| 4051 | end | ||
| 4052 | local file | 3904 | local file |
| 4053 | do | 3905 | local _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") | 3907 | file = _with_0 |
| 4056 | file = _with_0 | ||
| 4057 | end | ||
| 4058 | local create_person | 3908 | local create_person |
| 4059 | create_person = function(name, relatives) | 3909 | create_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 | }) |
| 4073 | do | 3923 | local str = "Hello" |
| 4074 | local str = "Hello" | 3924 | print("original:", str) |
| 4075 | print("original:", str) | 3925 | print("upper:", str:upper()) |
| 4076 | print("upper:", str:upper()) | 3926 | local _with_0 = tb |
| 4077 | end | 3927 | _with_0[1] = 1 |
| 4078 | do | 3928 | print(_with_0[2]) |
| 4079 | local _with_0 = tb | 3929 | do |
| 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] | 3933 | end |
| 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" | ||
| 4088 | end | ||
| 4089 | do | 3935 | do |
| 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 | |||
| 46 | return _module_0 | 46 | return _module_0 |
| 47 | local area = 6.2831853071796 * 5 | 47 | local area = 6.2831853071796 * 5 |
| 48 | print('ä½ å¥½ 世界') | 48 | print('ä½ å¥½ 世界') |
| 49 | assert(item ~= nil) | 49 | do |
| 50 | assert(item ~= nil) | ||
| 51 | end | ||
| 50 | local value = item | 52 | local value = item |
| 51 | if (f1() and f2() and f3()) then | 53 | if (f1() and f2() and f3()) then |
| 52 | print("OK") | 54 | print("OK") |
| 53 | end | 55 | end |
| 56 | do | ||
| 57 | local funcA | ||
| 58 | funcA = function() end | ||
| 59 | end | ||
| 54 | local funcA | 60 | local funcA |
| 55 | funcA = function() end | ||
| 56 | funcA = function() | 61 | funcA = function() |
| 57 | return "访问月之脚本定义的å˜é‡" | 62 | return "访问月之脚本定义的å˜é‡" |
| 58 | end | 63 | end |
| @@ -146,28 +151,26 @@ local b = { | |||
| 146 | y = 1 | 151 | y = 1 |
| 147 | } | 152 | } |
| 148 | local merge | 153 | local merge |
| 149 | do | 154 | local _tab_0 = { } |
| 150 | local _tab_0 = { } | 155 | local _idx_0 = 1 |
| 151 | local _idx_0 = 1 | 156 | for _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 | 163 | end |
| 161 | for _key_0, _value_0 in pairs(b) do | 164 | local _idx_1 = 1 |
| 162 | if _idx_1 == _key_0 then | 165 | for _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 | ||
| 170 | end | 172 | end |
| 173 | merge = _tab_0 | ||
| 171 | local mt = { } | 174 | local mt = { } |
| 172 | local add | 175 | local add |
| 173 | add = function(self, right) | 176 | add = function(self, right) |
| @@ -259,12 +262,10 @@ end | |||
| 259 | if print and (x ~= nil) then | 262 | if print and (x ~= nil) then |
| 260 | print(x) | 263 | print(x) |
| 261 | end | 264 | end |
| 262 | do | 265 | local _with_0 = io.open("test.txt", "w") |
| 263 | local _with_0 = io.open("test.txt", "w") | 266 | if _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 | ||
| 268 | end | 269 | end |
| 269 | print("ä½ å¥½") | 270 | print("ä½ å¥½") |
| 270 | print(1, 2) | 271 | print(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 | ||
| 348 | end | 347 | end |
| 349 | do | 348 | do |
| 350 | local module = require('module') | 349 | local module = require('module') |
| @@ -383,29 +382,27 @@ y = function() | |||
| 383 | end | 382 | end |
| 384 | _module_0["y"] = y | 383 | _module_0["y"] = y |
| 385 | local Something | 384 | local Something |
| 386 | do | 385 | local _class_0 |
| 387 | local _class_0 | 386 | local _base_0 = { |
| 388 | local _base_0 = { | 387 | umm = "cool" |
| 389 | umm = "cool" | 388 | } |
| 390 | } | 389 | if _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 | ||
| 408 | end | 391 | end |
| 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 | ||
| 405 | Something = _class_0 | ||
| 409 | _module_0["Something"] = Something | 406 | _module_0["Something"] = Something |
| 410 | return _module_0 | 407 | return _module_0 |
| 411 | local _module_0 = { } | 408 | local _module_0 = { } |
| @@ -436,11 +433,9 @@ if this then | |||
| 436 | else | 433 | else |
| 437 | _module_0[#_module_0 + 1] = 456 | 434 | _module_0[#_module_0 + 1] = 456 |
| 438 | end | 435 | end |
| 439 | do | 436 | local _with_0 = tmp |
| 440 | local _with_0 = tmp | 437 | local j = 2000 |
| 441 | local j = 2000 | 438 | _module_0[#_module_0 + 1] = _with_0 |
| 442 | _module_0[#_module_0 + 1] = _with_0 | ||
| 443 | end | ||
| 444 | return _module_0 | 439 | return _module_0 |
| 445 | local _module_0 = nil | 440 | local _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) |
| 579 | end | 574 | end |
| 580 | do | 575 | local user = database.find_user("moon") |
| 581 | local user = database.find_user("moon") | 576 | if user then |
| 582 | if user then | 577 | print(user.name) |
| 583 | print(user.name) | ||
| 584 | end | ||
| 585 | end | 578 | end |
| 586 | do | 579 | local hello = os.getenv("hello") |
| 587 | local hello = os.getenv("hello") | 580 | if hello then |
| 588 | if hello then | 581 | print("ä½ æœ‰ hello", hello) |
| 589 | print("ä½ æœ‰ hello", hello) | 582 | else |
| 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 |
| 600 | end | 589 | end |
| 601 | do | 590 | do |
| @@ -852,40 +841,34 @@ local items = { | |||
| 852 | 4 | 841 | 4 |
| 853 | } | 842 | } |
| 854 | local doubled | 843 | local doubled |
| 855 | do | 844 | local _accum_0 = { } |
| 856 | local _accum_0 = { } | 845 | local _len_0 = 1 |
| 857 | local _len_0 = 1 | 846 | for 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 | ||
| 863 | end | 849 | end |
| 850 | doubled = _accum_0 | ||
| 864 | local iter = ipairs(items) | 851 | local iter = ipairs(items) |
| 865 | local slice | 852 | local slice |
| 866 | do | 853 | local _accum_0 = { } |
| 867 | local _accum_0 = { } | 854 | local _len_0 = 1 |
| 868 | local _len_0 = 1 | 855 | for 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 | ||
| 876 | end | 860 | end |
| 861 | slice = _accum_0 | ||
| 877 | local doubled | 862 | local doubled |
| 878 | do | 863 | local _accum_0 = { } |
| 879 | local _accum_0 = { } | 864 | local _len_0 = 1 |
| 880 | local _len_0 = 1 | 865 | local _list_0 = items |
| 881 | local _list_0 = items | 866 | for _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 | ||
| 888 | end | 870 | end |
| 871 | doubled = _accum_0 | ||
| 889 | local x_coords = { | 872 | local x_coords = { |
| 890 | 4, | 873 | 4, |
| 891 | 5, | 874 | 5, |
| @@ -898,57 +881,49 @@ local y_coords = { | |||
| 898 | 3 | 881 | 3 |
| 899 | } | 882 | } |
| 900 | local points | 883 | local points |
| 901 | do | 884 | local _accum_0 = { } |
| 902 | local _accum_0 = { } | 885 | local _len_0 = 1 |
| 903 | local _len_0 = 1 | 886 | for _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 | ||
| 916 | end | 896 | end |
| 897 | points = _accum_0 | ||
| 917 | local evens | 898 | local evens |
| 918 | do | 899 | local _accum_0 = { } |
| 919 | local _accum_0 = { } | 900 | local _len_0 = 1 |
| 920 | local _len_0 = 1 | 901 | for 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 | ||
| 928 | end | 906 | end |
| 907 | evens = _accum_0 | ||
| 929 | local thing = { | 908 | local thing = { |
| 930 | color = "red", | 909 | color = "red", |
| 931 | name = "fast", | 910 | name = "fast", |
| 932 | width = 123 | 911 | width = 123 |
| 933 | } | 912 | } |
| 934 | local thing_copy | 913 | local thing_copy |
| 935 | do | 914 | local _tbl_0 = { } |
| 936 | local _tbl_0 = { } | 915 | for 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 | ||
| 941 | end | 917 | end |
| 918 | thing_copy = _tbl_0 | ||
| 942 | local no_color | 919 | local no_color |
| 943 | do | 920 | local _tbl_0 = { } |
| 944 | local _tbl_0 = { } | 921 | for 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 | ||
| 951 | end | 925 | end |
| 926 | no_color = _tbl_0 | ||
| 952 | local numbers = { | 927 | local numbers = { |
| 953 | 1, | 928 | 1, |
| 954 | 2, | 929 | 2, |
| @@ -956,14 +931,12 @@ local numbers = { | |||
| 956 | 4 | 931 | 4 |
| 957 | } | 932 | } |
| 958 | local sqrts | 933 | local sqrts |
| 959 | do | 934 | local _tbl_0 = { } |
| 960 | local _tbl_0 = { } | 935 | for _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 | ||
| 966 | end | 938 | end |
| 939 | sqrts = _tbl_0 | ||
| 967 | local tuples = { | 940 | local tuples = { |
| 968 | { | 941 | { |
| 969 | "hello", | 942 | "hello", |
| @@ -975,52 +948,44 @@ local tuples = { | |||
| 975 | } | 948 | } |
| 976 | } | 949 | } |
| 977 | local tbl | 950 | local tbl |
| 978 | do | 951 | local _tbl_0 = { } |
| 979 | local _tbl_0 = { } | 952 | for _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 | ||
| 986 | end | 956 | end |
| 957 | tbl = _tbl_0 | ||
| 987 | local slice | 958 | local slice |
| 988 | do | 959 | local _accum_0 = { } |
| 989 | local _accum_0 = { } | 960 | local _len_0 = 1 |
| 990 | local _len_0 = 1 | 961 | local _list_0 = items |
| 991 | local _list_0 = items | 962 | local _max_0 = 5 |
| 992 | local _max_0 = 5 | 963 | for _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 | ||
| 999 | end | 967 | end |
| 968 | slice = _accum_0 | ||
| 1000 | local slice | 969 | local slice |
| 1001 | do | 970 | local _accum_0 = { } |
| 1002 | local _accum_0 = { } | 971 | local _len_0 = 1 |
| 1003 | local _len_0 = 1 | 972 | local _list_0 = items |
| 1004 | local _list_0 = items | 973 | for _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 | ||
| 1011 | end | 977 | end |
| 978 | slice = _accum_0 | ||
| 1012 | local slice | 979 | local slice |
| 1013 | do | 980 | local _accum_0 = { } |
| 1014 | local _accum_0 = { } | 981 | local _len_0 = 1 |
| 1015 | local _len_0 = 1 | 982 | local _list_0 = items |
| 1016 | local _list_0 = items | 983 | for _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 | ||
| 1023 | end | 987 | end |
| 988 | slice = _accum_0 | ||
| 1024 | for i = 10, 20 do | 989 | for i = 10, 20 do |
| 1025 | print(i) | 990 | print(i) |
| 1026 | end | 991 | end |
| @@ -1030,13 +995,11 @@ end | |||
| 1030 | for key, value in pairs(object) do | 995 | for key, value in pairs(object) do |
| 1031 | print(key, value) | 996 | print(key, value) |
| 1032 | end | 997 | end |
| 1033 | do | 998 | local _list_0 = items |
| 1034 | local _list_0 = items | 999 | local _max_0 = 4 |
| 1035 | local _max_0 = 4 | 1000 | for _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 | ||
| 1040 | end | 1003 | end |
| 1041 | local _list_0 = items | 1004 | local _list_0 = items |
| 1042 | for _index_0 = 1, #_list_0 do | 1005 | for _index_0 = 1, #_list_0 do |
| @@ -1047,19 +1010,17 @@ for j = 1, 10, 3 do | |||
| 1047 | print(j) | 1010 | print(j) |
| 1048 | end | 1011 | end |
| 1049 | local doubled_evens | 1012 | local doubled_evens |
| 1050 | do | 1013 | local _accum_0 = { } |
| 1051 | local _accum_0 = { } | 1014 | local _len_0 = 1 |
| 1052 | local _len_0 = 1 | 1015 | for 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 |
| 1062 | end | 1022 | end |
| 1023 | doubled_evens = _accum_0 | ||
| 1063 | local func_a | 1024 | local func_a |
| 1064 | func_a = function() | 1025 | func_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 | } |
| 1119 | local odds | 1080 | local odds |
| 1120 | do | 1081 | local _accum_0 = { } |
| 1121 | local _accum_0 = { } | 1082 | local _len_0 = 1 |
| 1122 | local _len_0 = 1 | 1083 | for _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:: | ||
| 1133 | end | 1091 | end |
| 1092 | odds = _accum_0 | ||
| 1134 | local have_coins = false | 1093 | local have_coins = false |
| 1135 | if have_coins then | 1094 | if have_coins then |
| 1136 | print("有硬å¸") | 1095 | print("有硬å¸") |
| @@ -1222,15 +1181,13 @@ else | |||
| 1222 | next_number = error("æ•°å—æ•°å¾—太大了ï¼") | 1181 | next_number = error("æ•°å—æ•°å¾—太大了ï¼") |
| 1223 | end | 1182 | end |
| 1224 | local msg | 1183 | local msg |
| 1225 | do | 1184 | local _exp_0 = math.random(1, 5) |
| 1226 | local _exp_0 = math.random(1, 5) | 1185 | if 1 == _exp_0 then |
| 1227 | if 1 == _exp_0 then | 1186 | msg = "ä½ å¾ˆå¹¸è¿" |
| 1228 | msg = "ä½ å¾ˆå¹¸è¿" | 1187 | elseif 2 == _exp_0 then |
| 1229 | elseif 2 == _exp_0 then | 1188 | msg = "ä½ å·®ç‚¹å¾ˆå¹¸è¿" |
| 1230 | msg = "ä½ å·®ç‚¹å¾ˆå¹¸è¿" | 1189 | else |
| 1231 | else | 1190 | msg = "ä¸å¤ªå¹¸è¿" |
| 1232 | msg = "ä¸å¤ªå¹¸è¿" | ||
| 1233 | end | ||
| 1234 | end | 1191 | end |
| 1235 | do | 1192 | do |
| 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 |
| 1242 | end | 1199 | end |
| 1243 | do | 1200 | local _exp_0 = math.random(1, 5) |
| 1244 | local _exp_0 = math.random(1, 5) | 1201 | if 1 == _exp_0 then |
| 1245 | if 1 == _exp_0 then | 1202 | print("ä½ å¾ˆå¹¸è¿") |
| 1246 | print("ä½ å¾ˆå¹¸è¿") | 1203 | else |
| 1247 | else | 1204 | print("ä¸å¤ªå¹¸è¿") |
| 1248 | print("ä¸å¤ªå¹¸è¿") | ||
| 1249 | end | ||
| 1250 | end | 1205 | end |
| 1251 | local items = { | 1206 | local items = { |
| 1252 | { | 1207 | { |
| @@ -1260,25 +1215,23 @@ local items = { | |||
| 1260 | } | 1215 | } |
| 1261 | for _index_0 = 1, #items do | 1216 | for _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 | |||
| 1291 | if y == nil then | 1244 | if y == nil then |
| 1292 | y = 200 | 1245 | y = 200 |
| 1293 | end | 1246 | end |
| 1294 | do | 1247 | local _type_0 = type(item) |
| 1295 | local _type_0 = type(item) | 1248 | local _tab_0 = "table" == _type_0 or "userdata" == _type_0 |
| 1296 | local _tab_0 = "table" == _type_0 or "userdata" == _type_0 | 1249 | if _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)) | ||
| 1320 | end | 1271 | end |
| 1321 | local Inventory | 1272 | local Inventory |
| 1322 | do | 1273 | local _class_0 |
| 1323 | local _class_0 | 1274 | local _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) | 1284 | if _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 | ||
| 1353 | end | 1286 | end |
| 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 | ||
| 1302 | Inventory = _class_0 | ||
| 1354 | local inv = Inventory() | 1303 | local inv = Inventory() |
| 1355 | inv:add_item("t-shirt") | 1304 | inv:add_item("t-shirt") |
| 1356 | inv:add_item("pants") | 1305 | inv:add_item("pants") |
| @@ -1391,82 +1340,78 @@ for _index_0 = 1, #_list_0 do | |||
| 1391 | print(item) | 1340 | print(item) |
| 1392 | end | 1341 | end |
| 1393 | local Person | 1342 | local Person |
| 1394 | do | 1343 | local _class_0 |
| 1395 | local _class_0 | 1344 | local _base_0 = { } |
| 1396 | local _base_0 = { } | 1345 | if _base_0.__index == nil then |
| 1397 | if _base_0.__index == nil then | 1346 | _base_0.__index = _base_0 |
| 1398 | _base_0.__index = _base_0 | 1347 | end |
| 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 = { } | 1363 | Person = _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 | ||
| 1416 | end | ||
| 1417 | local BackPack | 1364 | local BackPack |
| 1418 | do | 1365 | local _class_0 |
| 1419 | local _class_0 | 1366 | local _parent_0 = Inventory |
| 1420 | local _parent_0 = Inventory | 1367 | local _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 | 1376 | for _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) | 1380 | end |
| 1439 | _class_0 = setmetatable({ | 1381 | if _base_0.__index == nil then |
| 1440 | __init = function(self, ...) | 1382 | _base_0.__index = _base_0 |
| 1441 | return _class_0.__parent.__init(self, ...) | 1383 | end |
| 1442 | end, | 1384 | setmetatable(_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 | ||
| 1411 | if _parent_0.__inherited then | ||
| 1412 | _parent_0.__inherited(_parent_0, _class_0) | ||
| 1469 | end | 1413 | end |
| 1414 | BackPack = _class_0 | ||
| 1470 | local Shelf | 1415 | local Shelf |
| 1471 | do | 1416 | do |
| 1472 | local _class_0 | 1417 | local _class_0 |
| @@ -1494,102 +1439,98 @@ do | |||
| 1494 | Shelf = _class_0 | 1439 | Shelf = _class_0 |
| 1495 | end | 1440 | end |
| 1496 | local Cupboard | 1441 | local Cupboard |
| 1497 | do | 1442 | local _class_0 |
| 1498 | local _class_0 | 1443 | local _parent_0 = Shelf |
| 1499 | local _parent_0 = Shelf | 1444 | local _base_0 = { } |
| 1500 | local _base_0 = { } | 1445 | for _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 | 1449 | end |
| 1505 | end | 1450 | if _base_0.__index == nil then |
| 1506 | if _base_0.__index == nil then | 1451 | _base_0.__index = _base_0 |
| 1507 | _base_0.__index = _base_0 | 1452 | end |
| 1508 | end | 1453 | setmetatable(_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 | ||
| 1480 | if _parent_0.__inherited then | ||
| 1481 | _parent_0.__inherited(_parent_0, _class_0) | ||
| 1540 | end | 1482 | end |
| 1483 | Cupboard = _class_0 | ||
| 1541 | local MyClass | 1484 | local MyClass |
| 1542 | do | 1485 | local _class_0 |
| 1543 | local _class_0 | 1486 | local _parent_0 = ParentClass |
| 1544 | local _parent_0 = ParentClass | 1487 | local _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 | } | 1495 | for _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 | 1499 | end |
| 1557 | end | 1500 | if _base_0.__index == nil then |
| 1558 | if _base_0.__index == nil then | 1501 | _base_0.__index = _base_0 |
| 1559 | _base_0.__index = _base_0 | 1502 | end |
| 1560 | end | 1503 | setmetatable(_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 | ||
| 1530 | if _parent_0.__inherited then | ||
| 1531 | _parent_0.__inherited(_parent_0, _class_0) | ||
| 1592 | end | 1532 | end |
| 1533 | MyClass = _class_0 | ||
| 1593 | local b = BackPack() | 1534 | local b = BackPack() |
| 1594 | assert(b.__class == BackPack) | 1535 | assert(b.__class == BackPack) |
| 1595 | print(BackPack.size) | 1536 | print(BackPack.size) |
| @@ -1653,61 +1594,57 @@ Counter() | |||
| 1653 | print(Counter.count) | 1594 | print(Counter.count) |
| 1654 | self.__class:hello(1, 2, 3, 4) | 1595 | self.__class:hello(1, 2, 3, 4) |
| 1655 | local Things | 1596 | local Things |
| 1656 | do | 1597 | local _class_0 |
| 1657 | local _class_0 | 1598 | local _base_0 = { } |
| 1658 | local _base_0 = { } | 1599 | if _base_0.__index == nil then |
| 1659 | if _base_0.__index == nil then | 1600 | _base_0.__index = _base_0 |
| 1660 | _base_0.__index = _base_0 | 1601 | end |
| 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, | 1615 | local self = _class_0; |
| 1665 | __name = "Things" | 1616 | self.class_var = "hello world" |
| 1666 | }, { | 1617 | Things = _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 | ||
| 1678 | end | ||
| 1679 | local MoreThings | 1618 | local MoreThings |
| 1680 | do | 1619 | local _class_0 |
| 1681 | local _class_0 | 1620 | local secret, log |
| 1682 | local secret, log | 1621 | local _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, | 1626 | if _base_0.__index == nil then |
| 1693 | __base = _base_0, | 1627 | _base_0.__index = _base_0 |
| 1694 | __name = "MoreThings" | 1628 | end |
| 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 | ||
| 1642 | local self = _class_0; | ||
| 1643 | secret = 123 | ||
| 1644 | log = function(msg) | ||
| 1645 | return print("LOG:", msg) | ||
| 1710 | end | 1646 | end |
| 1647 | MoreThings = _class_0 | ||
| 1711 | assert(self == self) | 1648 | assert(self == self) |
| 1712 | assert(self.__class == self.__class) | 1649 | assert(self.__class == self.__class) |
| 1713 | local some_instance_method | 1650 | local 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 |
| 1743 | end | 1680 | end |
| 1744 | do | 1681 | local _class_0 |
| 1745 | local _class_0 | 1682 | local _base_0 = { } |
| 1746 | local _base_0 = { } | 1683 | if _base_0.__index == nil then |
| 1747 | if _base_0.__index == nil then | 1684 | _base_0.__index = _base_0 |
| 1748 | _base_0.__index = _base_0 | 1685 | end |
| 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 | 1704 | Something = _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 | ||
| 1769 | end | ||
| 1770 | local new | 1705 | local new |
| 1771 | new = function(self, fieldA, fieldB) | 1706 | new = function(self, fieldA, fieldB) |
| 1772 | self.fieldA = fieldA | 1707 | self.fieldA = fieldA |
| @@ -1777,33 +1712,31 @@ local obj = new({ }, 123, "abc") | |||
| 1777 | print(obj) | 1712 | print(obj) |
| 1778 | local x | 1713 | local x |
| 1779 | local Bucket | 1714 | local Bucket |
| 1780 | do | 1715 | local _class_0 |
| 1781 | local _class_0 | 1716 | local _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, | 1722 | if _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 | ||
| 1806 | end | 1724 | end |
| 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 | ||
| 1738 | Bucket = _class_0 | ||
| 1739 | x = _class_0 | ||
| 1807 | local BigBucket | 1740 | local BigBucket |
| 1808 | do | 1741 | do |
| 1809 | local _class_0 | 1742 | local _class_0 |
| @@ -1855,27 +1788,25 @@ do | |||
| 1855 | end | 1788 | end |
| 1856 | assert(Bucket.__name == "BigBucket") | 1789 | assert(Bucket.__name == "BigBucket") |
| 1857 | local x | 1790 | local x |
| 1858 | do | 1791 | local _class_0 |
| 1859 | local _class_0 | 1792 | local _base_0 = { } |
| 1860 | local _base_0 = { } | 1793 | if _base_0.__index == nil then |
| 1861 | if _base_0.__index == nil then | 1794 | _base_0.__index = _base_0 |
| 1862 | _base_0.__index = _base_0 | 1795 | end |
| 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, | 1809 | x = _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 | ||
| 1878 | end | ||
| 1879 | local MyIndex = { | 1810 | local MyIndex = { |
| 1880 | __index = { | 1811 | __index = { |
| 1881 | var = 1 | 1812 | var = 1 |
| @@ -1958,19 +1889,15 @@ end | |||
| 1958 | local y = Y() | 1889 | local y = Y() |
| 1959 | y:func() | 1890 | y:func() |
| 1960 | assert(y.__class.__parent ~= X) | 1891 | assert(y.__class.__parent ~= X) |
| 1961 | do | 1892 | local _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() | 1896 | print(_with_0.name) |
| 1966 | print(_with_0.name) | ||
| 1967 | end | ||
| 1968 | local file | 1897 | local file |
| 1969 | do | 1898 | local _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") | 1900 | file = _with_0 |
| 1972 | file = _with_0 | ||
| 1973 | end | ||
| 1974 | local create_person | 1901 | local create_person |
| 1975 | create_person = function(name, relatives) | 1902 | create_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 | }) |
| 1916 | local str = "ä½ å¥½" | ||
| 1917 | print("原始:", str) | ||
| 1918 | print("大写:", str:upper()) | ||
| 1919 | local _with_0 = tb | ||
| 1920 | _with_0[1] = 1 | ||
| 1921 | print(_with_0[2]) | ||
| 1989 | do | 1922 | do |
| 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 |
| 1993 | end | ||
| 1994 | do | ||
| 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" | ||
| 2004 | end | 1926 | end |
| 1927 | _with_0[#_with_0 + 1] = "abc" | ||
| 2005 | do | 1928 | do |
| 2006 | local var = "hello" | 1929 | local var = "hello" |
| 2007 | print(var) | 1930 | print(var) |
| @@ -2118,13 +2041,18 @@ _module_0["🌛"] = _ud83c_udf1b | |||
| 2118 | return _module_0 | 2041 | return _module_0 |
| 2119 | local area = 6.2831853071796 * 5 | 2042 | local area = 6.2831853071796 * 5 |
| 2120 | print('ä½ å¥½ 世界') | 2043 | print('ä½ å¥½ 世界') |
| 2121 | assert(item ~= nil) | 2044 | do |
| 2045 | assert(item ~= nil) | ||
| 2046 | end | ||
| 2122 | local value = item | 2047 | local value = item |
| 2123 | if (f1() and f2() and f3()) then | 2048 | if (f1() and f2() and f3()) then |
| 2124 | print("OK") | 2049 | print("OK") |
| 2125 | end | 2050 | end |
| 2051 | do | ||
| 2052 | local funcA | ||
| 2053 | funcA = function() end | ||
| 2054 | end | ||
| 2126 | local funcA | 2055 | local funcA |
| 2127 | funcA = function() end | ||
| 2128 | funcA = function() | 2056 | funcA = function() |
| 2129 | return "访问月之脚本定义的å˜é‡" | 2057 | return "访问月之脚本定义的å˜é‡" |
| 2130 | end | 2058 | end |
| @@ -2218,28 +2146,26 @@ local b = { | |||
| 2218 | y = 1 | 2146 | y = 1 |
| 2219 | } | 2147 | } |
| 2220 | local merge | 2148 | local merge |
| 2221 | do | 2149 | local _tab_0 = { } |
| 2222 | local _tab_0 = { } | 2150 | local _idx_0 = 1 |
| 2223 | local _idx_0 = 1 | 2151 | for _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 | 2158 | end |
| 2233 | for _key_0, _value_0 in pairs(b) do | 2159 | local _idx_1 = 1 |
| 2234 | if _idx_1 == _key_0 then | 2160 | for _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 | ||
| 2242 | end | 2167 | end |
| 2168 | merge = _tab_0 | ||
| 2243 | local mt = { } | 2169 | local mt = { } |
| 2244 | local add | 2170 | local add |
| 2245 | add = function(self, right) | 2171 | add = function(self, right) |
| @@ -2331,12 +2257,10 @@ end | |||
| 2331 | if print and (x ~= nil) then | 2257 | if print and (x ~= nil) then |
| 2332 | print(x) | 2258 | print(x) |
| 2333 | end | 2259 | end |
| 2334 | do | 2260 | local _with_0 = io.open("test.txt", "w") |
| 2335 | local _with_0 = io.open("test.txt", "w") | 2261 | if _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 | ||
| 2340 | end | 2264 | end |
| 2341 | print("ä½ å¥½") | 2265 | print("ä½ å¥½") |
| 2342 | print(1, 2) | 2266 | print(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 | ||
| 2420 | end | 2342 | end |
| 2421 | do | 2343 | do |
| 2422 | local module = require('module') | 2344 | local module = require('module') |
| @@ -2455,29 +2377,27 @@ y = function() | |||
| 2455 | end | 2377 | end |
| 2456 | _module_0["y"] = y | 2378 | _module_0["y"] = y |
| 2457 | local Something | 2379 | local Something |
| 2458 | do | 2380 | local _class_0 |
| 2459 | local _class_0 | 2381 | local _base_0 = { |
| 2460 | local _base_0 = { | 2382 | umm = "cool" |
| 2461 | umm = "cool" | 2383 | } |
| 2462 | } | 2384 | if _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 | ||
| 2480 | end | 2386 | end |
| 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 | ||
| 2400 | Something = _class_0 | ||
| 2481 | _module_0["Something"] = Something | 2401 | _module_0["Something"] = Something |
| 2482 | return _module_0 | 2402 | return _module_0 |
| 2483 | local _module_0 = { } | 2403 | local _module_0 = { } |
| @@ -2508,11 +2428,9 @@ if this then | |||
| 2508 | else | 2428 | else |
| 2509 | _module_0[#_module_0 + 1] = 456 | 2429 | _module_0[#_module_0 + 1] = 456 |
| 2510 | end | 2430 | end |
| 2511 | do | 2431 | local _with_0 = tmp |
| 2512 | local _with_0 = tmp | 2432 | local j = 2000 |
| 2513 | local j = 2000 | 2433 | _module_0[#_module_0 + 1] = _with_0 |
| 2514 | _module_0[#_module_0 + 1] = _with_0 | ||
| 2515 | end | ||
| 2516 | return _module_0 | 2434 | return _module_0 |
| 2517 | local _module_0 = nil | 2435 | local _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) |
| 2651 | end | 2569 | end |
| 2652 | do | 2570 | local user = database.find_user("moon") |
| 2653 | local user = database.find_user("moon") | 2571 | if user then |
| 2654 | if user then | 2572 | print(user.name) |
| 2655 | print(user.name) | ||
| 2656 | end | ||
| 2657 | end | 2573 | end |
| 2658 | do | 2574 | local hello = os.getenv("hello") |
| 2659 | local hello = os.getenv("hello") | 2575 | if hello then |
| 2660 | if hello then | 2576 | print("ä½ æœ‰ hello", hello) |
| 2661 | print("ä½ æœ‰ hello", hello) | 2577 | else |
| 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 |
| 2672 | end | 2584 | end |
| 2673 | do | 2585 | do |
| @@ -2924,40 +2836,34 @@ local items = { | |||
| 2924 | 4 | 2836 | 4 |
| 2925 | } | 2837 | } |
| 2926 | local doubled | 2838 | local doubled |
| 2927 | do | 2839 | local _accum_0 = { } |
| 2928 | local _accum_0 = { } | 2840 | local _len_0 = 1 |
| 2929 | local _len_0 = 1 | 2841 | for 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 | ||
| 2935 | end | 2844 | end |
| 2845 | doubled = _accum_0 | ||
| 2936 | local iter = ipairs(items) | 2846 | local iter = ipairs(items) |
| 2937 | local slice | 2847 | local slice |
| 2938 | do | 2848 | local _accum_0 = { } |
| 2939 | local _accum_0 = { } | 2849 | local _len_0 = 1 |
| 2940 | local _len_0 = 1 | 2850 | for 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 | ||
| 2948 | end | 2855 | end |
| 2856 | slice = _accum_0 | ||
| 2949 | local doubled | 2857 | local doubled |
| 2950 | do | 2858 | local _accum_0 = { } |
| 2951 | local _accum_0 = { } | 2859 | local _len_0 = 1 |
| 2952 | local _len_0 = 1 | 2860 | local _list_0 = items |
| 2953 | local _list_0 = items | 2861 | for _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 | ||
| 2960 | end | 2865 | end |
| 2866 | doubled = _accum_0 | ||
| 2961 | local x_coords = { | 2867 | local x_coords = { |
| 2962 | 4, | 2868 | 4, |
| 2963 | 5, | 2869 | 5, |
| @@ -2970,57 +2876,49 @@ local y_coords = { | |||
| 2970 | 3 | 2876 | 3 |
| 2971 | } | 2877 | } |
| 2972 | local points | 2878 | local points |
| 2973 | do | 2879 | local _accum_0 = { } |
| 2974 | local _accum_0 = { } | 2880 | local _len_0 = 1 |
| 2975 | local _len_0 = 1 | 2881 | for _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 | ||
| 2988 | end | 2891 | end |
| 2892 | points = _accum_0 | ||
| 2989 | local evens | 2893 | local evens |
| 2990 | do | 2894 | local _accum_0 = { } |
| 2991 | local _accum_0 = { } | 2895 | local _len_0 = 1 |
| 2992 | local _len_0 = 1 | 2896 | for 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 | ||
| 3000 | end | 2901 | end |
| 2902 | evens = _accum_0 | ||
| 3001 | local thing = { | 2903 | local thing = { |
| 3002 | color = "red", | 2904 | color = "red", |
| 3003 | name = "fast", | 2905 | name = "fast", |
| 3004 | width = 123 | 2906 | width = 123 |
| 3005 | } | 2907 | } |
| 3006 | local thing_copy | 2908 | local thing_copy |
| 3007 | do | 2909 | local _tbl_0 = { } |
| 3008 | local _tbl_0 = { } | 2910 | for 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 | ||
| 3013 | end | 2912 | end |
| 2913 | thing_copy = _tbl_0 | ||
| 3014 | local no_color | 2914 | local no_color |
| 3015 | do | 2915 | local _tbl_0 = { } |
| 3016 | local _tbl_0 = { } | 2916 | for 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 | ||
| 3023 | end | 2920 | end |
| 2921 | no_color = _tbl_0 | ||
| 3024 | local numbers = { | 2922 | local numbers = { |
| 3025 | 1, | 2923 | 1, |
| 3026 | 2, | 2924 | 2, |
| @@ -3028,14 +2926,12 @@ local numbers = { | |||
| 3028 | 4 | 2926 | 4 |
| 3029 | } | 2927 | } |
| 3030 | local sqrts | 2928 | local sqrts |
| 3031 | do | 2929 | local _tbl_0 = { } |
| 3032 | local _tbl_0 = { } | 2930 | for _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 | ||
| 3038 | end | 2933 | end |
| 2934 | sqrts = _tbl_0 | ||
| 3039 | local tuples = { | 2935 | local tuples = { |
| 3040 | { | 2936 | { |
| 3041 | "hello", | 2937 | "hello", |
| @@ -3047,52 +2943,44 @@ local tuples = { | |||
| 3047 | } | 2943 | } |
| 3048 | } | 2944 | } |
| 3049 | local tbl | 2945 | local tbl |
| 3050 | do | 2946 | local _tbl_0 = { } |
| 3051 | local _tbl_0 = { } | 2947 | for _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 | ||
| 3058 | end | 2951 | end |
| 2952 | tbl = _tbl_0 | ||
| 3059 | local slice | 2953 | local slice |
| 3060 | do | 2954 | local _accum_0 = { } |
| 3061 | local _accum_0 = { } | 2955 | local _len_0 = 1 |
| 3062 | local _len_0 = 1 | 2956 | local _list_0 = items |
| 3063 | local _list_0 = items | 2957 | local _max_0 = 5 |
| 3064 | local _max_0 = 5 | 2958 | for _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 | ||
| 3071 | end | 2962 | end |
| 2963 | slice = _accum_0 | ||
| 3072 | local slice | 2964 | local slice |
| 3073 | do | 2965 | local _accum_0 = { } |
| 3074 | local _accum_0 = { } | 2966 | local _len_0 = 1 |
| 3075 | local _len_0 = 1 | 2967 | local _list_0 = items |
| 3076 | local _list_0 = items | 2968 | for _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 | ||
| 3083 | end | 2972 | end |
| 2973 | slice = _accum_0 | ||
| 3084 | local slice | 2974 | local slice |
| 3085 | do | 2975 | local _accum_0 = { } |
| 3086 | local _accum_0 = { } | 2976 | local _len_0 = 1 |
| 3087 | local _len_0 = 1 | 2977 | local _list_0 = items |
| 3088 | local _list_0 = items | 2978 | for _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 | ||
| 3095 | end | 2982 | end |
| 2983 | slice = _accum_0 | ||
| 3096 | for i = 10, 20 do | 2984 | for i = 10, 20 do |
| 3097 | print(i) | 2985 | print(i) |
| 3098 | end | 2986 | end |
| @@ -3102,13 +2990,11 @@ end | |||
| 3102 | for key, value in pairs(object) do | 2990 | for key, value in pairs(object) do |
| 3103 | print(key, value) | 2991 | print(key, value) |
| 3104 | end | 2992 | end |
| 3105 | do | 2993 | local _list_0 = items |
| 3106 | local _list_0 = items | 2994 | local _max_0 = 4 |
| 3107 | local _max_0 = 4 | 2995 | for _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 | ||
| 3112 | end | 2998 | end |
| 3113 | local _list_0 = items | 2999 | local _list_0 = items |
| 3114 | for _index_0 = 1, #_list_0 do | 3000 | for _index_0 = 1, #_list_0 do |
| @@ -3119,19 +3005,17 @@ for j = 1, 10, 3 do | |||
| 3119 | print(j) | 3005 | print(j) |
| 3120 | end | 3006 | end |
| 3121 | local doubled_evens | 3007 | local doubled_evens |
| 3122 | do | 3008 | local _accum_0 = { } |
| 3123 | local _accum_0 = { } | 3009 | local _len_0 = 1 |
| 3124 | local _len_0 = 1 | 3010 | for 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 |
| 3134 | end | 3017 | end |
| 3018 | doubled_evens = _accum_0 | ||
| 3135 | local func_a | 3019 | local func_a |
| 3136 | func_a = function() | 3020 | func_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 | } |
| 3191 | local odds | 3075 | local odds |
| 3192 | do | 3076 | local _accum_0 = { } |
| 3193 | local _accum_0 = { } | 3077 | local _len_0 = 1 |
| 3194 | local _len_0 = 1 | 3078 | for _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:: | ||
| 3205 | end | 3086 | end |
| 3087 | odds = _accum_0 | ||
| 3206 | local have_coins = false | 3088 | local have_coins = false |
| 3207 | if have_coins then | 3089 | if have_coins then |
| 3208 | print("有硬å¸") | 3090 | print("有硬å¸") |
| @@ -3294,15 +3176,13 @@ else | |||
| 3294 | next_number = error("æ•°å—æ•°å¾—太大了ï¼") | 3176 | next_number = error("æ•°å—æ•°å¾—太大了ï¼") |
| 3295 | end | 3177 | end |
| 3296 | local msg | 3178 | local msg |
| 3297 | do | 3179 | local _exp_0 = math.random(1, 5) |
| 3298 | local _exp_0 = math.random(1, 5) | 3180 | if 1 == _exp_0 then |
| 3299 | if 1 == _exp_0 then | 3181 | msg = "ä½ å¾ˆå¹¸è¿" |
| 3300 | msg = "ä½ å¾ˆå¹¸è¿" | 3182 | elseif 2 == _exp_0 then |
| 3301 | elseif 2 == _exp_0 then | 3183 | msg = "ä½ å·®ç‚¹å¾ˆå¹¸è¿" |
| 3302 | msg = "ä½ å·®ç‚¹å¾ˆå¹¸è¿" | 3184 | else |
| 3303 | else | 3185 | msg = "ä¸å¤ªå¹¸è¿" |
| 3304 | msg = "ä¸å¤ªå¹¸è¿" | ||
| 3305 | end | ||
| 3306 | end | 3186 | end |
| 3307 | do | 3187 | do |
| 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 |
| 3314 | end | 3194 | end |
| 3315 | do | 3195 | local _exp_0 = math.random(1, 5) |
| 3316 | local _exp_0 = math.random(1, 5) | 3196 | if 1 == _exp_0 then |
| 3317 | if 1 == _exp_0 then | 3197 | print("ä½ å¾ˆå¹¸è¿") |
| 3318 | print("ä½ å¾ˆå¹¸è¿") | 3198 | else |
| 3319 | else | 3199 | print("ä¸å¤ªå¹¸è¿") |
| 3320 | print("ä¸å¤ªå¹¸è¿") | ||
| 3321 | end | ||
| 3322 | end | 3200 | end |
| 3323 | local items = { | 3201 | local items = { |
| 3324 | { | 3202 | { |
| @@ -3332,25 +3210,23 @@ local items = { | |||
| 3332 | } | 3210 | } |
| 3333 | for _index_0 = 1, #items do | 3211 | for _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 | |||
| 3363 | if y == nil then | 3239 | if y == nil then |
| 3364 | y = 200 | 3240 | y = 200 |
| 3365 | end | 3241 | end |
| 3366 | do | 3242 | local _type_0 = type(item) |
| 3367 | local _type_0 = type(item) | 3243 | local _tab_0 = "table" == _type_0 or "userdata" == _type_0 |
| 3368 | local _tab_0 = "table" == _type_0 or "userdata" == _type_0 | 3244 | if _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)) | ||
| 3392 | end | 3266 | end |
| 3393 | local Inventory | 3267 | local Inventory |
| 3394 | do | 3268 | local _class_0 |
| 3395 | local _class_0 | 3269 | local _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) | 3279 | if _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 | ||
| 3425 | end | 3281 | end |
| 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 | ||
| 3297 | Inventory = _class_0 | ||
| 3426 | local inv = Inventory() | 3298 | local inv = Inventory() |
| 3427 | inv:add_item("t-shirt") | 3299 | inv:add_item("t-shirt") |
| 3428 | inv:add_item("pants") | 3300 | inv:add_item("pants") |
| @@ -3463,82 +3335,78 @@ for _index_0 = 1, #_list_0 do | |||
| 3463 | print(item) | 3335 | print(item) |
| 3464 | end | 3336 | end |
| 3465 | local Person | 3337 | local Person |
| 3466 | do | 3338 | local _class_0 |
| 3467 | local _class_0 | 3339 | local _base_0 = { } |
| 3468 | local _base_0 = { } | 3340 | if _base_0.__index == nil then |
| 3469 | if _base_0.__index == nil then | 3341 | _base_0.__index = _base_0 |
| 3470 | _base_0.__index = _base_0 | 3342 | end |
| 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 = { } | 3358 | Person = _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 | ||
| 3488 | end | ||
| 3489 | local BackPack | 3359 | local BackPack |
| 3490 | do | 3360 | local _class_0 |
| 3491 | local _class_0 | 3361 | local _parent_0 = Inventory |
| 3492 | local _parent_0 = Inventory | 3362 | local _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 | 3371 | for _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) | 3375 | end |
| 3511 | _class_0 = setmetatable({ | 3376 | if _base_0.__index == nil then |
| 3512 | __init = function(self, ...) | 3377 | _base_0.__index = _base_0 |
| 3513 | return _class_0.__parent.__init(self, ...) | 3378 | end |
| 3514 | end, | 3379 | setmetatable(_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 | ||
| 3406 | if _parent_0.__inherited then | ||
| 3407 | _parent_0.__inherited(_parent_0, _class_0) | ||
| 3541 | end | 3408 | end |
| 3409 | BackPack = _class_0 | ||
| 3542 | local Shelf | 3410 | local Shelf |
| 3543 | do | 3411 | do |
| 3544 | local _class_0 | 3412 | local _class_0 |
| @@ -3566,102 +3434,98 @@ do | |||
| 3566 | Shelf = _class_0 | 3434 | Shelf = _class_0 |
| 3567 | end | 3435 | end |
| 3568 | local Cupboard | 3436 | local Cupboard |
| 3569 | do | 3437 | local _class_0 |
| 3570 | local _class_0 | 3438 | local _parent_0 = Shelf |
| 3571 | local _parent_0 = Shelf | 3439 | local _base_0 = { } |
| 3572 | local _base_0 = { } | 3440 | for _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 | 3444 | end |
| 3577 | end | 3445 | if _base_0.__index == nil then |
| 3578 | if _base_0.__index == nil then | 3446 | _base_0.__index = _base_0 |
| 3579 | _base_0.__index = _base_0 | 3447 | end |
| 3580 | end | 3448 | setmetatable(_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 | ||
| 3475 | if _parent_0.__inherited then | ||
| 3476 | _parent_0.__inherited(_parent_0, _class_0) | ||
| 3612 | end | 3477 | end |
| 3478 | Cupboard = _class_0 | ||
| 3613 | local MyClass | 3479 | local MyClass |
| 3614 | do | 3480 | local _class_0 |
| 3615 | local _class_0 | 3481 | local _parent_0 = ParentClass |
| 3616 | local _parent_0 = ParentClass | 3482 | local _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 | } | 3490 | for _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 | 3494 | end |
| 3629 | end | 3495 | if _base_0.__index == nil then |
| 3630 | if _base_0.__index == nil then | 3496 | _base_0.__index = _base_0 |
| 3631 | _base_0.__index = _base_0 | 3497 | end |
| 3632 | end | 3498 | setmetatable(_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 | ||
| 3525 | if _parent_0.__inherited then | ||
| 3526 | _parent_0.__inherited(_parent_0, _class_0) | ||
| 3664 | end | 3527 | end |
| 3528 | MyClass = _class_0 | ||
| 3665 | local b = BackPack() | 3529 | local b = BackPack() |
| 3666 | assert(b.__class == BackPack) | 3530 | assert(b.__class == BackPack) |
| 3667 | print(BackPack.size) | 3531 | print(BackPack.size) |
| @@ -3725,61 +3589,57 @@ Counter() | |||
| 3725 | print(Counter.count) | 3589 | print(Counter.count) |
| 3726 | self.__class:hello(1, 2, 3, 4) | 3590 | self.__class:hello(1, 2, 3, 4) |
| 3727 | local Things | 3591 | local Things |
| 3728 | do | 3592 | local _class_0 |
| 3729 | local _class_0 | 3593 | local _base_0 = { } |
| 3730 | local _base_0 = { } | 3594 | if _base_0.__index == nil then |
| 3731 | if _base_0.__index == nil then | 3595 | _base_0.__index = _base_0 |
| 3732 | _base_0.__index = _base_0 | 3596 | end |
| 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, | 3610 | local self = _class_0; |
| 3737 | __name = "Things" | 3611 | self.class_var = "hello world" |
| 3738 | }, { | 3612 | Things = _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 | ||
| 3750 | end | ||
| 3751 | local MoreThings | 3613 | local MoreThings |
| 3752 | do | 3614 | local _class_0 |
| 3753 | local _class_0 | 3615 | local secret, log |
| 3754 | local secret, log | 3616 | local _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, | 3621 | if _base_0.__index == nil then |
| 3765 | __base = _base_0, | 3622 | _base_0.__index = _base_0 |
| 3766 | __name = "MoreThings" | 3623 | end |
| 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 | ||
| 3637 | local self = _class_0; | ||
| 3638 | secret = 123 | ||
| 3639 | log = function(msg) | ||
| 3640 | return print("LOG:", msg) | ||
| 3782 | end | 3641 | end |
| 3642 | MoreThings = _class_0 | ||
| 3783 | assert(self == self) | 3643 | assert(self == self) |
| 3784 | assert(self.__class == self.__class) | 3644 | assert(self.__class == self.__class) |
| 3785 | local some_instance_method | 3645 | local 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 |
| 3815 | end | 3675 | end |
| 3816 | do | 3676 | local _class_0 |
| 3817 | local _class_0 | 3677 | local _base_0 = { } |
| 3818 | local _base_0 = { } | 3678 | if _base_0.__index == nil then |
| 3819 | if _base_0.__index == nil then | 3679 | _base_0.__index = _base_0 |
| 3820 | _base_0.__index = _base_0 | 3680 | end |
| 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 | 3699 | Something = _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 | ||
| 3841 | end | ||
| 3842 | local new | 3700 | local new |
| 3843 | new = function(self, fieldA, fieldB) | 3701 | new = function(self, fieldA, fieldB) |
| 3844 | self.fieldA = fieldA | 3702 | self.fieldA = fieldA |
| @@ -3849,33 +3707,31 @@ local obj = new({ }, 123, "abc") | |||
| 3849 | print(obj) | 3707 | print(obj) |
| 3850 | local x | 3708 | local x |
| 3851 | local Bucket | 3709 | local Bucket |
| 3852 | do | 3710 | local _class_0 |
| 3853 | local _class_0 | 3711 | local _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, | 3717 | if _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 | ||
| 3878 | end | 3719 | end |
| 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 | ||
| 3733 | Bucket = _class_0 | ||
| 3734 | x = _class_0 | ||
| 3879 | local BigBucket | 3735 | local BigBucket |
| 3880 | do | 3736 | do |
| 3881 | local _class_0 | 3737 | local _class_0 |
| @@ -3927,27 +3783,25 @@ do | |||
| 3927 | end | 3783 | end |
| 3928 | assert(Bucket.__name == "BigBucket") | 3784 | assert(Bucket.__name == "BigBucket") |
| 3929 | local x | 3785 | local x |
| 3930 | do | 3786 | local _class_0 |
| 3931 | local _class_0 | 3787 | local _base_0 = { } |
| 3932 | local _base_0 = { } | 3788 | if _base_0.__index == nil then |
| 3933 | if _base_0.__index == nil then | 3789 | _base_0.__index = _base_0 |
| 3934 | _base_0.__index = _base_0 | 3790 | end |
| 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, | 3804 | x = _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 | ||
| 3950 | end | ||
| 3951 | local MyIndex = { | 3805 | local MyIndex = { |
| 3952 | __index = { | 3806 | __index = { |
| 3953 | var = 1 | 3807 | var = 1 |
| @@ -4030,19 +3884,15 @@ end | |||
| 4030 | local y = Y() | 3884 | local y = Y() |
| 4031 | y:func() | 3885 | y:func() |
| 4032 | assert(y.__class.__parent ~= X) | 3886 | assert(y.__class.__parent ~= X) |
| 4033 | do | 3887 | local _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() | 3891 | print(_with_0.name) |
| 4038 | print(_with_0.name) | ||
| 4039 | end | ||
| 4040 | local file | 3892 | local file |
| 4041 | do | 3893 | local _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") | 3895 | file = _with_0 |
| 4044 | file = _with_0 | ||
| 4045 | end | ||
| 4046 | local create_person | 3896 | local create_person |
| 4047 | create_person = function(name, relatives) | 3897 | create_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 | }) |
| 4061 | do | 3911 | local str = "ä½ å¥½" |
| 4062 | local str = "ä½ å¥½" | 3912 | print("原始:", str) |
| 4063 | print("原始:", str) | 3913 | print("大写:", str:upper()) |
| 4064 | print("大写:", str:upper()) | 3914 | local _with_0 = tb |
| 4065 | end | 3915 | _with_0[1] = 1 |
| 4066 | do | 3916 | print(_with_0[2]) |
| 4067 | local _with_0 = tb | 3917 | do |
| 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] | 3921 | end |
| 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" | ||
| 4076 | end | ||
| 4077 | do | 3923 | do |
| 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("<", "<"):gsub(">", ">"), { |
| 37 | local result, err = to_lua(code:gsub("<", "<"):gsub(">", ">"), { | 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 | |||
| 113 | if false then | 113 | if false then |
| 114 | _ = one | 114 | _ = one |
| 115 | else | 115 | else |
| 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 |
| 129 | end | 127 | end |
| @@ -131,33 +129,27 @@ local out | |||
| 131 | if false then | 129 | if false then |
| 132 | out = one | 130 | out = one |
| 133 | else | 131 | else |
| 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 |
| 147 | end | 143 | end |
| 148 | local kzy | 144 | local kzy |
| 149 | kzy = function() | 145 | kzy = 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 |
| 163 | end | 155 | end |
| @@ -314,12 +306,10 @@ do | |||
| 314 | end | 306 | end |
| 315 | end | 307 | end |
| 316 | do | 308 | do |
| 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 |
| 324 | end | 314 | end |
| 325 | do | 315 | do |
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 |
| 132 | end | 132 | end |
| 133 | do | 133 | do |
| 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 | ||
| 139 | end | 137 | end |
| 140 | do | 138 | do |
| 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 | ||
| 457 | end | 451 | end |
| 458 | do | 452 | do |
| 459 | local v1, v2, v3, v4 | 453 | local v1, v2, v3, v4 |
| @@ -483,11 +477,9 @@ do | |||
| 483 | end | 477 | end |
| 484 | do | 478 | do |
| 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 | ||
| 491 | end | 483 | end |
| 492 | do | 484 | do |
| 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 |
| 522 | end | 512 | end |
| 523 | do | 513 | do |
| @@ -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 |
| 649 | end | 637 | end |
| 650 | return nil | 638 | return 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" |
| 4 | end | 4 | end |
| 5 | do | 5 | do |
| 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 | ||
| 29 | end | 27 | end |
| 30 | do | 28 | do |
| 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 | |||
| 30 | end | 30 | end |
| 31 | if indent then | 31 | if 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 | ||
| 43 | end | 41 | end |
| 44 | do | 42 | do |
| 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 | ||
| 81 | end | 77 | end |
| 82 | do | 78 | do |
| 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 | ||
| 99 | end | 93 | end |
| 100 | do | 94 | do |
| 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 | ||
| 145 | end | 141 | end |
| 146 | do | 142 | do |
| 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 | |||
| 297 | do | 297 | do |
| 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 @@ | |||
| 1 | assert(item == nil) | 1 | do |
| 2 | assert(item == nil) | ||
| 3 | end | ||
| 2 | local v = (item == nil) | 4 | local v = (item == nil) |
| 3 | if f1() then | 5 | if f1() then |
| 4 | print("OK") | 6 | print("OK") |
| @@ -9,86 +11,86 @@ end | |||
| 9 | local item | 11 | local item |
| 10 | do | 12 | do |
| 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 | ||
| 27 | end | 25 | end |
| 28 | if (x == "Apple" or x == "Pig" or x == "Dog") then | 26 | if (x == "Apple" or x == "Pig" or x == "Dog") then |
| 29 | print("exist") | 27 | print("exist") |
| 30 | end | 28 | end |
| 31 | local _list_0 = (function() | 29 | do |
| 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 | ||
| 57 | end)() | ||
| 58 | for _index_0 = 1, #_list_0 do | ||
| 59 | local _ = _list_0[_index_0] | ||
| 60 | print(_) | ||
| 61 | end | 61 | end |
| 62 | local _list_1 = (function() | 62 | do |
| 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 | ||
| 88 | end)() | ||
| 89 | for _index_0 = 1, #_list_1 do | ||
| 90 | local _ = _list_1[_index_0] | ||
| 91 | print(_) | ||
| 92 | end | 94 | end |
| 93 | local val | 95 | local val |
| 94 | do | 96 | do |
| @@ -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 |
| 136 | end | 138 | end |
| 137 | (1 + 2):call(123) | 139 | do |
| 140 | (1 + 2):call(123) | ||
| 141 | end | ||
| 138 | local res = (1 + 2) | 142 | local res = (1 + 2) |
| 139 | local f | 143 | local f |
| 140 | f = function(x) | 144 | f = function(x) |
| @@ -210,40 +214,44 @@ local a = ((((_({ | |||
| 210 | return self * 2 | 214 | return self * 2 |
| 211 | end)):filter(function(self) | 215 | end)):filter(function(self) |
| 212 | return self > 3 | 216 | return self > 3 |
| 213 | end)):value(); | 217 | end)):value() |
| 214 | ((((_({ | 218 | do |
| 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) |
| 223 | end)):filter(function(self) | 227 | return self * 2 |
| 224 | return self > 3 | 228 | end)):filter(function(self) |
| 225 | end)):each(function(self) | 229 | return self > 3 |
| 226 | return print(self) | 230 | end)):each(function(self) |
| 227 | end) | 231 | return print(self) |
| 232 | end) | ||
| 233 | end | ||
| 228 | local result = ((((((origin.transform.root.gameObject:Parents()):Descendants()):SelectEnable()):SelectVisible()):TagEqual("fx")):Where(function(x) | 234 | local 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)") |
| 230 | end)):Destroy() | 236 | end)):Destroy() |
| 231 | do | 237 | do |
| 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 | ||
| 247 | end | 255 | end |
| 248 | origin.transform.root.gameObject:Parents():Descendants():SelectEnable():SelectVisible():TagEqual("fx"):Where(function(x) | 256 | origin.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 | })) |
| 280 | print("current line: " .. tostring(268)) | 288 | print("current line: " .. tostring(268)) |
| 289 | do | ||
| 281 | -- TODO | 290 | -- TODO |
| 291 | end | ||
| 282 | do | 292 | do |
| 283 | print(1) | 293 | print(1) |
| 284 | end | 294 | end |
| @@ -293,5 +303,7 @@ _1 = function() | |||
| 293 | end | 303 | end |
| 294 | return _accum_0 | 304 | return _accum_0 |
| 295 | end | 305 | end |
| 296 | print('abc') | 306 | do |
| 297 | return 123 | 307 | print('abc') |
| 308 | return 123 | ||
| 309 | end | ||
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 | |||
| 48 | end | 48 | end |
| 49 | do | 49 | do |
| 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 |
| 65 | end | 63 | end |
| 66 | setmetatable(a.b, { }) | 64 | setmetatable(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 |
| 95 | end | 93 | end |
| 96 | return nil | 94 | return 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 @@ | |||
| 1 | do | 1 | do |
| 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 |
| 11 | end | 9 | end |
| 12 | do | 10 | do |
| 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 |
| 22 | end | 18 | end |
| 23 | do | 19 | do |
| @@ -50,23 +46,21 @@ do | |||
| 50 | end | 46 | end |
| 51 | do | 47 | do |
| 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)()) |
| 85 | end | 79 | end |
| 86 | do | 80 | do |
| 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) | ||
| 99 | end | 89 | end |
| 100 | do | 90 | do |
| 101 | local a = 1 + 2 + (function() | 91 | local a = 1 + 2 + (function() |
| @@ -137,18 +127,16 @@ do | |||
| 137 | end | 127 | end |
| 138 | do | 128 | do |
| 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 | |||
| 15 | print(fn()) | 15 | print(fn()) |
| 16 | print(x:val()); | 16 | print(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 |
| 25 | end)() | 23 | end)() |
| 26 | return nil | 24 | return 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 | |||
| 45 | end | 45 | end |
| 46 | do | 46 | do |
| 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 |
| 56 | end | 54 | end |
| 57 | fix(this) | 55 | fix(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 |
| 171 | end | 167 | end |
| @@ -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 | ||
| 290 | end | 282 | end |
| 291 | do | 283 | do |
| 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 |
| 316 | end | 306 | end |
| 317 | do | 307 | do |
| 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 |
| 381 | end | 367 | end |
| 382 | do | 368 | do |
| 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 |
| 400 | end | 384 | end |
| 401 | do | 385 | do |
| 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 |
| 435 | end | 417 | end |
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 | |||
| 217 | end | 217 | end |
| 218 | do | 218 | do |
| 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 | ||
| 229 | end | 225 | end |
| 230 | do | 226 | do |
| 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 | |||
| 430 | end | 430 | end |
| 431 | do | 431 | do |
| 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 | ||
| 457 | end | 453 | end |
| 458 | do | 454 | do |
| 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 | ||
| 481 | end | 473 | end |
| 482 | do | 474 | do |
| 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 | ||
| 537 | end | 525 | end |
| 538 | do | 526 | do |
| 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 | ||
| 584 | end | 568 | end |
| 585 | local template <const> = { | 569 | local 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 |
| 116 | end | 114 | end |
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) |
| 14 | for _u8ba1_u6570 = 1, 10 do | 14 | for _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) |
| 41 | end | 47 | end |
| 42 | do | 48 | do |
| 43 | _u6253_u5370(123) | 49 | do |
| 50 | _u6253_u5370(123) | ||
| 51 | end | ||
| 44 | end | 52 | end |
| 45 | do | 53 | do |
| 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 | ||
| 113 | end | 119 | end |
| 114 | return nil | 120 | return 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 | |||
| 14 | do | 14 | do |
| 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 | ||
| 22 | end | 20 | end |
| 23 | do | 21 | do |
| 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 | ||
| 31 | end | 27 | end |
| 32 | do | 28 | do |
| 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)()) |
| 32 | end | 32 | end |
| 33 | do | 33 | do |
| 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 |
| 50 | end | 48 | end |
| 51 | do | 49 | do |
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 | ||
| 123 | end | 121 | end |
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("ä½ å¥½") | |||
| 497 | local _u53d8_u91cfyyy | 497 | local _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 | ||
| 524 | end | 522 | end |
| 525 | do | 523 | do |
| 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 | |||
| 113 | if false then | 113 | if false then |
| 114 | __u65e0_u6548_u53d8_u91cf = _u4e00 | 114 | __u65e0_u6548_u53d8_u91cf = _u4e00 |
| 115 | else | 115 | else |
| 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 |
| 131 | end | 127 | end |
| @@ -133,35 +129,27 @@ local _u8f93_u51fa | |||
| 133 | if false then | 129 | if false then |
| 134 | _u8f93_u51fa = _u4e00 | 130 | _u8f93_u51fa = _u4e00 |
| 135 | else | 131 | else |
| 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 |
| 151 | end | 143 | end |
| 152 | local _u53d8_u91cf | 144 | local _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 |
| 167 | end | 155 | end |
| @@ -319,12 +307,10 @@ do | |||
| 319 | end | 307 | end |
| 320 | end | 308 | end |
| 321 | do | 309 | do |
| 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 |
| 329 | end | 315 | end |
| 330 | do | 316 | do |
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 |
| 128 | end | 128 | end |
| 129 | do | 129 | do |
| 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 | ||
| 135 | end | 133 | end |
| 136 | do | 134 | do |
| 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 | ||
| 444 | end | 438 | end |
| 445 | do | 439 | do |
| 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 | |||
| 470 | end | 464 | end |
| 471 | do | 465 | do |
| 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 | ||
| 478 | end | 470 | end |
| 479 | do | 471 | do |
| 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 |
| 509 | end | 499 | end |
| 510 | do | 500 | do |
| @@ -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 |
| 636 | end | 624 | end |
| 637 | return nil | 625 | return 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 = "📉" |
| 4 | end | 4 | end |
| 5 | do | 5 | do |
| 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 | ||
| 29 | end | 27 | end |
| 30 | do | 28 | do |
| 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 | |||
| 30 | end | 30 | end |
| 31 | if _u7f29_u8fdb then | 31 | if _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 | ||
| 43 | end | 41 | end |
| 44 | do | 42 | do |
| 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 | ||
| 145 | end | 141 | end |
| 146 | do | 142 | do |
| 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 | |||
| 297 | do | 297 | do |
| 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 @@ | |||
| 1 | assert(_u5bf9_u8c61 == nil) | 1 | do |
| 2 | assert(_u5bf9_u8c61 == nil) | ||
| 3 | end | ||
| 2 | local _u7ed3_u679c = (_u5bf9_u8c61 == nil) | 4 | local _u7ed3_u679c = (_u5bf9_u8c61 == nil) |
| 3 | if _u51fd_u65701() then | 5 | if _u51fd_u65701() then |
| 4 | _u6253_u5370("没问题") | 6 | _u6253_u5370("没问题") |
| @@ -9,89 +11,89 @@ end | |||
| 9 | local _u5bf9_u8c61 | 11 | local _u5bf9_u8c61 |
| 10 | do | 12 | do |
| 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 | ||
| 30 | end | 28 | end |
| 31 | if (_u53d8_u91cfx == "ðŸŽ" or _u53d8_u91cfx == "ðŸ·" or _u53d8_u91cfx == "ðŸ¶") then | 29 | if (_u53d8_u91cfx == "ðŸŽ" or _u53d8_u91cfx == "ðŸ·" or _u53d8_u91cfx == "ðŸ¶") then |
| 32 | _u6253_u5370("å˜åœ¨") | 30 | _u6253_u5370("å˜åœ¨") |
| 33 | end | 31 | end |
| 34 | local _list_0 = (function() | 32 | do |
| 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 | ||
| 60 | end)() | ||
| 61 | for _index_0 = 1, #_list_0 do | ||
| 62 | local _ = _list_0[_index_0] | ||
| 63 | _u6253_u5370(_) | ||
| 64 | end | 64 | end |
| 65 | local _list_1 = (function() | 65 | do |
| 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 | ||
| 91 | end)() | ||
| 92 | for _index_0 = 1, #_list_1 do | ||
| 93 | local _ = _list_1[_index_0] | ||
| 94 | _u6253_u5370(_) | ||
| 95 | end | 97 | end |
| 96 | local _u503c | 98 | local _u503c |
| 97 | do | 99 | do |
| @@ -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 |
| 139 | end | 141 | end |
| 140 | local _call_0 = (1 + 2) | 142 | do |
| 141 | _call_0["调用"](_call_0, 123) | 143 | local _call_0 = (1 + 2) |
| 144 | _call_0["调用"](_call_0, 123) | ||
| 145 | end | ||
| 142 | _u7ed3_u679c = (1 + 2) | 146 | _u7ed3_u679c = (1 + 2) |
| 143 | local f | 147 | local f |
| 144 | f = function(_u53c2_u6570x) | 148 | f = function(_u53c2_u6570x) |
| @@ -203,7 +207,7 @@ local function dummy() | |||
| 203 | end | 207 | end |
| 204 | -- 这有个注释 | 208 | -- 这有个注释 |
| 205 | local _ = require('下划线') | 209 | local _ = require('下划线') |
| 206 | local _call_1 = (_({ | 210 | local _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 |
| 217 | end) | 221 | end) |
| 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 |
| 220 | end) | 224 | end) |
| 221 | local _u7ed3_u679ca = _call_1["å–值"](_call_1) | 225 | local _u7ed3_u679ca = _call_0["å–值"](_call_0) |
| 222 | local _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 | ||
| 233 | end) | ||
| 234 | _call_2 = _call_2["过滤"](_call_2, function(self) | ||
| 235 | return self > 3 | ||
| 236 | end) | ||
| 237 | _call_2["æ¯ä¸€ä¸ª"](_call_2, function(self) | ||
| 238 | return _u6253_u5370(self) | ||
| 239 | end) | ||
| 240 | local _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, "(克隆)") | ||
| 249 | end) | ||
| 250 | _u7ed3_u679c = _call_3["æ‘§æ¯"](_call_3) | ||
| 251 | do | 226 | do |
| 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) | 245 | end |
| 246 | local _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, "(克隆)") | ||
| 255 | end) | ||
| 256 | _u7ed3_u679c = _call_1["æ‘§æ¯"](_call_1) | ||
| 257 | do | ||
| 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 | ||
| 269 | end | 277 | end |
| 270 | local _call_0 = _u539f_u70b9["å˜æ¢"]["æ ¹èŠ‚ç‚¹"]["游æˆå¯¹è±¡"] | 278 | local _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)) |
| 313 | do | ||
| 305 | -- 待实现 | 314 | -- 待实现 |
| 315 | end | ||
| 306 | do | 316 | do |
| 307 | _u6253_u5370(1) | 317 | _u6253_u5370(1) |
| 308 | end | 318 | end |
| @@ -317,5 +327,7 @@ _1 = function() | |||
| 317 | end | 327 | end |
| 318 | return _accum_0 | 328 | return _accum_0 |
| 319 | end | 329 | end |
| 320 | _u6253_u5370('abc') | 330 | do |
| 321 | return 123 | 331 | _u6253_u5370('abc') |
| 332 | return 123 | ||
| 333 | end | ||
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 | |||
| 48 | end | 48 | end |
| 49 | do | 49 | do |
| 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 |
| 65 | end | 63 | end |
| 66 | setmetatable(_u53d8_u91cfa["å˜é‡b"], { }) | 64 | setmetatable(_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 |
| 141 | end | 139 | end |
| 142 | return nil | 140 | return 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 @@ | |||
| 1 | do | 1 | do |
| 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 |
| 11 | end | 9 | end |
| 12 | do | 10 | do |
| 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 |
| 22 | end | 18 | end |
| 23 | do | 19 | do |
| @@ -50,23 +46,21 @@ do | |||
| 50 | end | 46 | end |
| 51 | do | 47 | do |
| 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)()) |
| 85 | end | 79 | end |
| 86 | do | 80 | do |
| 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["å—æ®µ"]) | ||
| 99 | end | 89 | end |
| 100 | do | 90 | do |
| 101 | local _u53d8_u91cfa = 1 + 2 + (function() | 91 | local _u53d8_u91cfa = 1 + 2 + (function() |
| @@ -138,18 +128,16 @@ do | |||
| 138 | end | 128 | end |
| 139 | do | 129 | do |
| 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 |
| 25 | end)() | 23 | end)() |
| 26 | return nil | 24 | return 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 | |||
| 45 | end | 45 | end |
| 46 | do | 46 | do |
| 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 |
| 56 | end | 54 | end |
| 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 |
| 171 | end | 167 | end |
| @@ -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 | ||
| 290 | end | 282 | end |
| 291 | do | 283 | do |
| 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 |
| 316 | end | 306 | end |
| 317 | do | 307 | do |
| 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 |
| 381 | end | 367 | end |
| 382 | do | 368 | do |
| 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 |
| 400 | end | 384 | end |
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 | |||
| 235 | end | 235 | end |
| 236 | do | 236 | do |
| 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 | ||
| 247 | end | 243 | end |
| 248 | do | 244 | do |
| 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, ...) | |||
| 46 | end | 46 | end |
| 47 | local _anon_func_6 = function(_u51fd_u6570, setmetatable) | 47 | local _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 | ||
| 73 | end | 71 | end |
| 74 | local _anon_func_7 = function(_u51fd_u6570, setmetatable, ...) | 72 | local _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 | ||
| 100 | end | 96 | end |
| 101 | local _anon_func_8 = function(_u8868, pairs) | 97 | local _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 |
| 10 | end | 10 | end |
| 11 | do | 11 | do |
| 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 | ||
| 22 | end | 20 | end |
| 23 | do | 21 | do |
| 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 | ||
| 30 | end | 26 | end |
| 31 | do | 27 | do |
| 32 | local _u53d8_u91cfx = 5 + (function() | 28 | local _u53d8_u91cfx = 5 + (function() |
| @@ -45,14 +41,12 @@ do | |||
| 45 | } | 41 | } |
| 46 | end | 42 | end |
| 47 | do | 43 | do |
| 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 | ||
| 56 | end | 50 | end |
| 57 | do | 51 | do |
| 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 | ||
| 90 | end | 82 | end |
| 91 | do | 83 | do |
| 92 | local _u53d8_u91cfx = "ä½ å¥½" | 84 | local _u53d8_u91cfx = "ä½ å¥½" |
| 93 | _u53d8_u91cfx["大写"](_u53d8_u91cfx) | 85 | _u53d8_u91cfx["大写"](_u53d8_u91cfx) |
| 94 | end | 86 | end |
| 95 | do | 87 | do |
| 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 | ||
| 100 | end | 90 | end |
| 101 | do | 91 | do |
| 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 | ||
| 106 | end | 94 | end |
| 107 | do | 95 | do |
| 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 | ||
| 114 | end | 100 | end |
| 115 | do | 101 | do |
| 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 | ||
| 120 | end | 104 | end |
| 121 | do | 105 | do |
| 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 | ||
| 127 | end | 109 | end |
| 128 | do | 110 | do |
| 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 | ||
| 137 | end | 115 | end |
| 138 | do | 116 | do |
| 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 | ||
| 147 | end | 121 | end |
| 148 | do | 122 | do |
| 149 | local _ | 123 | local _ |
| @@ -153,44 +127,38 @@ do | |||
| 153 | end | 127 | end |
| 154 | end | 128 | end |
| 155 | do | 129 | do |
| 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 | ||
| 161 | end | 133 | end |
| 162 | do | 134 | do |
| 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 | ||
| 168 | end | 138 | end |
| 169 | do | 139 | do |
| 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 | } | ||
| 194 | end | 162 | end |
| 195 | do | 163 | do |
| 196 | do | 164 | do |
| @@ -207,16 +175,14 @@ do | |||
| 207 | end | 175 | end |
| 208 | end | 176 | end |
| 209 | do | 177 | do |
| 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 |
| 221 | end | 187 | end |
| 222 | return nil | 188 | return 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 |
| 321 | end | 321 | end |
| 322 | local _anon_func_14 = function(setmetatable) | 322 | local _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 | ||
| 345 | end | 343 | end |
| 346 | local _anon_func_15 = function(tb) | 344 | local _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, ...) | |||
| 46 | end | 46 | end |
| 47 | local _anon_func_6 = function(func, setmetatable) | 47 | local _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 | ||
| 73 | end | 71 | end |
| 74 | local _anon_func_7 = function(func, setmetatable, ...) | 72 | local _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 | ||
| 100 | end | 96 | end |
| 101 | local _anon_func_8 = function(pairs, tb) | 97 | local _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 |
| 10 | end | 10 | end |
| 11 | do | 11 | do |
| 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 | ||
| 22 | end | 20 | end |
| 23 | do | 21 | do |
| 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 | ||
| 30 | end | 26 | end |
| 31 | do | 27 | do |
| 32 | local x = 5 + (function() | 28 | local x = 5 + (function() |
| @@ -45,12 +41,10 @@ do | |||
| 45 | } | 41 | } |
| 46 | end | 42 | end |
| 47 | do | 43 | do |
| 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 | ||
| 54 | end | 48 | end |
| 55 | do | 49 | do |
| 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 | ||
| 88 | end | 80 | end |
| 89 | do | 81 | do |
| 90 | local x = "hello" | 82 | local x = "hello" |
| 91 | x:upper() | 83 | x:upper() |
| 92 | end | 84 | end |
| 93 | do | 85 | do |
| 94 | do | 86 | local k = "jo" |
| 95 | local k = "jo" | 87 | print(k:upper()) |
| 96 | print(k:upper()) | ||
| 97 | end | ||
| 98 | end | 88 | end |
| 99 | do | 89 | do |
| 100 | do | 90 | local a, b, c = "", "", "" |
| 101 | local a, b, c = "", "", "" | 91 | print(a:upper()) |
| 102 | print(a:upper()) | ||
| 103 | end | ||
| 104 | end | 92 | end |
| 105 | do | 93 | do |
| 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 | ||
| 112 | end | 98 | end |
| 113 | do | 99 | do |
| 114 | do | 100 | local _with_0 = j |
| 115 | local _with_0 = j | 101 | print(_with_0:upper()) |
| 116 | print(_with_0:upper()) | ||
| 117 | end | ||
| 118 | end | 102 | end |
| 119 | do | 103 | do |
| 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 | ||
| 125 | end | 107 | end |
| 126 | do | 108 | do |
| 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 | ||
| 135 | end | 113 | end |
| 136 | do | 114 | do |
| 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 | ||
| 145 | end | 119 | end |
| 146 | do | 120 | do |
| 147 | local _ | 121 | local _ |
| @@ -151,43 +125,37 @@ do | |||
| 151 | end | 125 | end |
| 152 | end | 126 | end |
| 153 | do | 127 | do |
| 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 | ||
| 158 | end | 130 | end |
| 159 | do | 131 | do |
| 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 | ||
| 165 | end | 135 | end |
| 166 | do | 136 | do |
| 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 | } | ||
| 191 | end | 159 | end |
| 192 | do | 160 | do |
| 193 | do | 161 | do |
| @@ -204,16 +172,14 @@ do | |||
| 204 | end | 172 | end |
| 205 | end | 173 | end |
| 206 | do | 174 | do |
| 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 |
| 218 | end | 184 | end |
| 219 | return nil | 185 | return nil |
diff --git a/src/yuescript/yue_compiler.cpp b/src/yuescript/yue_compiler.cpp index 1864846..ae6c0e4 100644 --- a/src/yuescript/yue_compiler.cpp +++ b/src/yuescript/yue_compiler.cpp | |||
| @@ -75,7 +75,7 @@ static std::unordered_set<std::string> Metamethods = { | |||
| 75 | "close"s // Lua 5.4 | 75 | "close"s // Lua 5.4 |
| 76 | }; | 76 | }; |
| 77 | 77 | ||
| 78 | const std::string_view version = "0.23.0"sv; | 78 | const std::string_view version = "0.23.1"sv; |
| 79 | const std::string_view extension = "yue"sv; | 79 | const std::string_view extension = "yue"sv; |
| 80 | 80 | ||
| 81 | class CompileError : public std::logic_error { | 81 | class CompileError : public std::logic_error { |
| @@ -431,6 +431,7 @@ private: | |||
| 431 | }; | 431 | }; |
| 432 | struct Scope { | 432 | struct Scope { |
| 433 | GlobalMode mode = GlobalMode::None; | 433 | GlobalMode mode = GlobalMode::None; |
| 434 | bool lastStatement = false; | ||
| 434 | std::unique_ptr<std::unordered_map<std::string, VarType>> vars; | 435 | std::unique_ptr<std::unordered_map<std::string, VarType>> vars; |
| 435 | std::unique_ptr<std::unordered_set<std::string>> allows; | 436 | std::unique_ptr<std::unordered_set<std::string>> allows; |
| 436 | std::unique_ptr<std::unordered_set<std::string>> globals; | 437 | std::unique_ptr<std::unordered_set<std::string>> globals; |
| @@ -1854,12 +1855,17 @@ private: | |||
| 1854 | preAssignment->expList.set(preExplist); | 1855 | preAssignment->expList.set(preExplist); |
| 1855 | str_list temp; | 1856 | str_list temp; |
| 1856 | temp.push_back(getPreDefineLine(assignment)); | 1857 | temp.push_back(getPreDefineLine(assignment)); |
| 1857 | temp.push_back(indent() + "do"s + nll(assignment)); | 1858 | bool needScope = !currentScope().lastStatement; |
| 1858 | pushScope(); | 1859 | if (needScope) { |
| 1860 | temp.push_back(indent() + "do"s + nll(assignment)); | ||
| 1861 | pushScope(); | ||
| 1862 | } | ||
| 1859 | transformAssignmentCommon(preAssignment, temp); | 1863 | transformAssignmentCommon(preAssignment, temp); |
| 1860 | transformAssignment(assignment, temp); | 1864 | transformAssignment(assignment, temp); |
| 1861 | popScope(); | 1865 | if (needScope) { |
| 1862 | temp.push_back(indent() + "end"s + nll(assignment)); | 1866 | popScope(); |
| 1867 | temp.push_back(indent() + "end"s + nll(assignment)); | ||
| 1868 | } | ||
| 1863 | out.push_back(join(temp)); | 1869 | out.push_back(join(temp)); |
| 1864 | return; | 1870 | return; |
| 1865 | BLOCK_END | 1871 | BLOCK_END |
| @@ -1906,11 +1912,14 @@ private: | |||
| 1906 | } | 1912 | } |
| 1907 | } | 1913 | } |
| 1908 | auto varName = singleVariableFrom(tmpChain, AccessType::Write); | 1914 | auto varName = singleVariableFrom(tmpChain, AccessType::Write); |
| 1909 | bool isScoped = false; | 1915 | bool needScope = !currentScope().lastStatement; |
| 1916 | bool extraScoped = false; | ||
| 1910 | if (varName.empty() || !isLocal(varName)) { | 1917 | if (varName.empty() || !isLocal(varName)) { |
| 1911 | isScoped = true; | 1918 | if (needScope) { |
| 1912 | temp.push_back(indent() + "do"s + nll(x)); | 1919 | extraScoped = true; |
| 1913 | pushScope(); | 1920 | temp.push_back(indent() + "do"s + nll(x)); |
| 1921 | pushScope(); | ||
| 1922 | } | ||
| 1914 | auto objVar = getUnusedName("_obj_"sv); | 1923 | auto objVar = getUnusedName("_obj_"sv); |
| 1915 | auto newAssignment = x->new_ptr<ExpListAssign_t>(); | 1924 | auto newAssignment = x->new_ptr<ExpListAssign_t>(); |
| 1916 | newAssignment->expList.set(toAst<ExpList_t>(objVar, x)); | 1925 | newAssignment->expList.set(toAst<ExpList_t>(objVar, x)); |
| @@ -1929,7 +1938,7 @@ private: | |||
| 1929 | assign->values.push_back(*vit); | 1938 | assign->values.push_back(*vit); |
| 1930 | newAssignment->action.set(assign); | 1939 | newAssignment->action.set(assign); |
| 1931 | transformAssignment(newAssignment, temp); | 1940 | transformAssignment(newAssignment, temp); |
| 1932 | if (isScoped) { | 1941 | if (extraScoped) { |
| 1933 | popScope(); | 1942 | popScope(); |
| 1934 | temp.push_back(indent() + "end"s + nlr(x)); | 1943 | temp.push_back(indent() + "end"s + nlr(x)); |
| 1935 | } | 1944 | } |
| @@ -2126,6 +2135,8 @@ private: | |||
| 2126 | } else { | 2135 | } else { |
| 2127 | auto x = assignment; | 2136 | auto x = assignment; |
| 2128 | str_list temp; | 2137 | str_list temp; |
| 2138 | bool needScope = !currentScope().lastStatement; | ||
| 2139 | bool extraScope = false; | ||
| 2129 | if (info.extraScope) { | 2140 | if (info.extraScope) { |
| 2130 | str_list defs; | 2141 | str_list defs; |
| 2131 | for (auto& destruct : info.destructures) { | 2142 | for (auto& destruct : info.destructures) { |
| @@ -2144,8 +2155,11 @@ private: | |||
| 2144 | } | 2155 | } |
| 2145 | temp.push_back(indent() + "local "s + join(defs, ", "sv) + nll(x)); | 2156 | temp.push_back(indent() + "local "s + join(defs, ", "sv) + nll(x)); |
| 2146 | } | 2157 | } |
| 2147 | temp.push_back(indent() + "do"s + nll(x)); | 2158 | if (needScope) { |
| 2148 | pushScope(); | 2159 | extraScope = true; |
| 2160 | temp.push_back(indent() + "do"s + nll(x)); | ||
| 2161 | pushScope(); | ||
| 2162 | } | ||
| 2149 | } | 2163 | } |
| 2150 | if (info.assignment) { | 2164 | if (info.assignment) { |
| 2151 | transformAssignmentCommon(info.assignment, temp); | 2165 | transformAssignmentCommon(info.assignment, temp); |
| @@ -2355,7 +2369,7 @@ private: | |||
| 2355 | temp.push_back(clearBuf()); | 2369 | temp.push_back(clearBuf()); |
| 2356 | } | 2370 | } |
| 2357 | } | 2371 | } |
| 2358 | if (info.extraScope) { | 2372 | if (extraScope) { |
| 2359 | popScope(); | 2373 | popScope(); |
| 2360 | temp.push_back(indent() + "end"s + nlr(x)); | 2374 | temp.push_back(indent() + "end"s + nlr(x)); |
| 2361 | } | 2375 | } |
| @@ -3202,6 +3216,7 @@ private: | |||
| 3202 | auto asmt = firstIfCond->assignment.get(); | 3216 | auto asmt = firstIfCond->assignment.get(); |
| 3203 | bool storingValue = false; | 3217 | bool storingValue = false; |
| 3204 | ast_ptr<false, ExpListAssign_t> extraAssignment; | 3218 | ast_ptr<false, ExpListAssign_t> extraAssignment; |
| 3219 | bool extraScope = false; | ||
| 3205 | if (asmt) { | 3220 | if (asmt) { |
| 3206 | auto exp = firstIfCond->condition.get(); | 3221 | auto exp = firstIfCond->condition.get(); |
| 3207 | auto x = exp; | 3222 | auto x = exp; |
| @@ -3218,8 +3233,11 @@ private: | |||
| 3218 | } | 3233 | } |
| 3219 | if (storingValue) { | 3234 | if (storingValue) { |
| 3220 | if (usage != ExpUsage::Closure) { | 3235 | if (usage != ExpUsage::Closure) { |
| 3221 | temp.push_back(indent() + "do"s + nll(asmt)); | 3236 | if (!currentScope().lastStatement) { |
| 3222 | pushScope(); | 3237 | extraScope = true; |
| 3238 | temp.push_back(indent() + "do"s + nll(asmt)); | ||
| 3239 | pushScope(); | ||
| 3240 | } | ||
| 3223 | } | 3241 | } |
| 3224 | auto expList = toAst<ExpList_t>(desVar, x); | 3242 | auto expList = toAst<ExpList_t>(desVar, x); |
| 3225 | auto assignment = x->new_ptr<ExpListAssign_t>(); | 3243 | auto assignment = x->new_ptr<ExpListAssign_t>(); |
| @@ -3248,8 +3266,11 @@ private: | |||
| 3248 | if (!isDefined(var)) { | 3266 | if (!isDefined(var)) { |
| 3249 | storingValue = true; | 3267 | storingValue = true; |
| 3250 | if (usage != ExpUsage::Closure) { | 3268 | if (usage != ExpUsage::Closure) { |
| 3251 | temp.push_back(indent() + "do"s + nll(asmt)); | 3269 | if (!currentScope().lastStatement) { |
| 3252 | pushScope(); | 3270 | extraScope = true; |
| 3271 | temp.push_back(indent() + "do"s + nll(asmt)); | ||
| 3272 | pushScope(); | ||
| 3273 | } | ||
| 3253 | } | 3274 | } |
| 3254 | } | 3275 | } |
| 3255 | auto expList = x->new_ptr<ExpList_t>(); | 3276 | auto expList = x->new_ptr<ExpList_t>(); |
| @@ -3295,7 +3316,7 @@ private: | |||
| 3295 | break; | 3316 | break; |
| 3296 | } | 3317 | } |
| 3297 | } | 3318 | } |
| 3298 | if (storingValue && usage != ExpUsage::Closure) { | 3319 | if (extraScope) { |
| 3299 | popScope(); | 3320 | popScope(); |
| 3300 | temp.push_back(indent() + "end"s + nlr(nodes.front())); | 3321 | temp.push_back(indent() + "end"s + nlr(nodes.front())); |
| 3301 | } | 3322 | } |
| @@ -3823,9 +3844,12 @@ private: | |||
| 3823 | auto objVar = singleVariableFrom(left, AccessType::Read); | 3844 | auto objVar = singleVariableFrom(left, AccessType::Read); |
| 3824 | auto prepareValue = [&](bool forAssignment = false) { | 3845 | auto prepareValue = [&](bool forAssignment = false) { |
| 3825 | if (objVar.empty() || !isLocal(objVar)) { | 3846 | if (objVar.empty() || !isLocal(objVar)) { |
| 3847 | bool extraScope = !currentScope().lastStatement; | ||
| 3826 | if (forAssignment) { | 3848 | if (forAssignment) { |
| 3827 | temp.push_back(indent() + "do"s + nll(x)); | 3849 | if (extraScope) { |
| 3828 | pushScope(); | 3850 | temp.push_back(indent() + "do"s + nll(x)); |
| 3851 | pushScope(); | ||
| 3852 | } | ||
| 3829 | } | 3853 | } |
| 3830 | objVar = getUnusedName("_exp_"sv); | 3854 | objVar = getUnusedName("_exp_"sv); |
| 3831 | auto expList = toAst<ExpList_t>(objVar, x); | 3855 | auto expList = toAst<ExpList_t>(objVar, x); |
| @@ -3835,7 +3859,7 @@ private: | |||
| 3835 | assignment->expList.set(expList); | 3859 | assignment->expList.set(expList); |
| 3836 | assignment->action.set(assign); | 3860 | assignment->action.set(assign); |
| 3837 | transformAssignment(assignment, temp); | 3861 | transformAssignment(assignment, temp); |
| 3838 | return forAssignment; | 3862 | return extraScope; |
| 3839 | } | 3863 | } |
| 3840 | return false; | 3864 | return false; |
| 3841 | }; | 3865 | }; |
| @@ -4531,6 +4555,7 @@ private: | |||
| 4531 | if (!nodes.empty()) { | 4555 | if (!nodes.empty()) { |
| 4532 | str_list temp; | 4556 | str_list temp; |
| 4533 | for (auto node : nodes) { | 4557 | for (auto node : nodes) { |
| 4558 | currentScope().lastStatement = (node == nodes.back()) && currentScope().mode == GlobalMode::None; | ||
| 4534 | transformStatement(static_cast<Statement_t*>(node), temp); | 4559 | transformStatement(static_cast<Statement_t*>(node), temp); |
| 4535 | if (isRoot && !_rootDefs.empty()) { | 4560 | if (isRoot && !_rootDefs.empty()) { |
| 4536 | auto last = std::move(temp.back()); | 4561 | auto last = std::move(temp.back()); |
| @@ -5166,12 +5191,14 @@ private: | |||
| 5166 | auto objVar = singleVariableFrom(partOne, AccessType::Read); | 5191 | auto objVar = singleVariableFrom(partOne, AccessType::Read); |
| 5167 | bool isScoped = false; | 5192 | bool isScoped = false; |
| 5168 | if (objVar.empty() || !isLocal(objVar)) { | 5193 | if (objVar.empty() || !isLocal(objVar)) { |
| 5169 | switch (usage) { | 5194 | if (!currentScope().lastStatement) { |
| 5170 | case ExpUsage::Common: | 5195 | switch (usage) { |
| 5171 | case ExpUsage::Assignment: | 5196 | case ExpUsage::Common: |
| 5172 | isScoped = true; | 5197 | case ExpUsage::Assignment: |
| 5173 | break; | 5198 | isScoped = true; |
| 5174 | default: break; | 5199 | break; |
| 5200 | default: break; | ||
| 5201 | } | ||
| 5175 | } | 5202 | } |
| 5176 | if (isScoped) { | 5203 | if (isScoped) { |
| 5177 | temp.push_back(indent() + "do"s + nll(x)); | 5204 | temp.push_back(indent() + "do"s + nll(x)); |
| @@ -5302,10 +5329,13 @@ private: | |||
| 5302 | auto x = chainList.front(); | 5329 | auto x = chainList.front(); |
| 5303 | str_list temp; | 5330 | str_list temp; |
| 5304 | std::string* funcStart = nullptr; | 5331 | std::string* funcStart = nullptr; |
| 5332 | bool isScoped = !currentScope().lastStatement; | ||
| 5305 | switch (usage) { | 5333 | switch (usage) { |
| 5306 | case ExpUsage::Assignment: | 5334 | case ExpUsage::Assignment: |
| 5307 | temp.push_back(indent() + "do"s + nll(x)); | 5335 | if (isScoped) { |
| 5308 | pushScope(); | 5336 | temp.push_back(indent() + "do"s + nll(x)); |
| 5337 | pushScope(); | ||
| 5338 | } | ||
| 5309 | break; | 5339 | break; |
| 5310 | case ExpUsage::Closure: | 5340 | case ExpUsage::Closure: |
| 5311 | pushAnonFunctionScope(); | 5341 | pushAnonFunctionScope(); |
| @@ -5378,8 +5408,10 @@ private: | |||
| 5378 | } | 5408 | } |
| 5379 | switch (usage) { | 5409 | switch (usage) { |
| 5380 | case ExpUsage::Assignment: | 5410 | case ExpUsage::Assignment: |
| 5381 | popScope(); | 5411 | if (isScoped) { |
| 5382 | temp.push_back(indent() + "end"s + nlr(x)); | 5412 | popScope(); |
| 5413 | temp.push_back(indent() + "end"s + nlr(x)); | ||
| 5414 | } | ||
| 5383 | break; | 5415 | break; |
| 5384 | case ExpUsage::Closure: | 5416 | case ExpUsage::Closure: |
| 5385 | popScope(); | 5417 | popScope(); |
| @@ -5432,6 +5464,7 @@ private: | |||
| 5432 | case id<ColonChainItem_t>(): { | 5464 | case id<ColonChainItem_t>(): { |
| 5433 | auto colon = static_cast<ColonChainItem_t*>(*opIt); | 5465 | auto colon = static_cast<ColonChainItem_t*>(*opIt); |
| 5434 | auto meta = colon->name.to<Metamethod_t>(); | 5466 | auto meta = colon->name.to<Metamethod_t>(); |
| 5467 | bool isScoped = !currentScope().lastStatement; | ||
| 5435 | switch (meta->item->get_id()) { | 5468 | switch (meta->item->get_id()) { |
| 5436 | case id<Name_t>(): { | 5469 | case id<Name_t>(): { |
| 5437 | auto name = _parser.toString(meta->item); | 5470 | auto name = _parser.toString(meta->item); |
| @@ -5457,8 +5490,10 @@ private: | |||
| 5457 | funcStart = &temp.emplace_back(); | 5490 | funcStart = &temp.emplace_back(); |
| 5458 | pushScope(); | 5491 | pushScope(); |
| 5459 | } else if (usage != ExpUsage::Return) { | 5492 | } else if (usage != ExpUsage::Return) { |
| 5460 | temp.push_back(indent() + "do"s + nll(x)); | 5493 | if (isScoped) { |
| 5461 | pushScope(); | 5494 | temp.push_back(indent() + "do"s + nll(x)); |
| 5495 | pushScope(); | ||
| 5496 | } | ||
| 5462 | } | 5497 | } |
| 5463 | auto var = getUnusedName("_obj_"sv); | 5498 | auto var = getUnusedName("_obj_"sv); |
| 5464 | auto target = toAst<Exp_t>(var, x); | 5499 | auto target = toAst<Exp_t>(var, x); |
| @@ -5513,14 +5548,18 @@ private: | |||
| 5513 | assign->values.push_back(newChainExp); | 5548 | assign->values.push_back(newChainExp); |
| 5514 | assignment->action.set(assign); | 5549 | assignment->action.set(assign); |
| 5515 | transformAssignment(assignment, temp); | 5550 | transformAssignment(assignment, temp); |
| 5516 | popScope(); | 5551 | if (isScoped) { |
| 5517 | temp.push_back(indent() + "end"s + nlr(x)); | 5552 | popScope(); |
| 5553 | temp.push_back(indent() + "end"s + nlr(x)); | ||
| 5554 | } | ||
| 5518 | break; | 5555 | break; |
| 5519 | } | 5556 | } |
| 5520 | case ExpUsage::Common: | 5557 | case ExpUsage::Common: |
| 5521 | transformExp(newChainExp, temp, usage); | 5558 | transformExp(newChainExp, temp, usage); |
| 5522 | popScope(); | 5559 | if (isScoped) { |
| 5523 | temp.push_back(indent() + "end"s + nlr(x)); | 5560 | popScope(); |
| 5561 | temp.push_back(indent() + "end"s + nlr(x)); | ||
| 5562 | } | ||
| 5524 | break; | 5563 | break; |
| 5525 | } | 5564 | } |
| 5526 | out.push_back(join(temp)); | 5565 | out.push_back(join(temp)); |
| @@ -6060,36 +6099,6 @@ private: | |||
| 6060 | if (auto blockEnd = info.node.as<BlockEnd_t>()) { | 6099 | if (auto blockEnd = info.node.as<BlockEnd_t>()) { |
| 6061 | auto block = blockEnd->block.get(); | 6100 | auto block = blockEnd->block.get(); |
| 6062 | info.node.set(block); | 6101 | info.node.set(block); |
| 6063 | for (auto stmt_ : block->statements.objects()) { | ||
| 6064 | auto stmt = static_cast<Statement_t*>(stmt_); | ||
| 6065 | if (auto global = stmt->content.as<Global_t>()) { | ||
| 6066 | if (global->item.is<GlobalOp_t>()) { | ||
| 6067 | throw CompileError("can not use global statement with wildcard operator in macro"sv, x); | ||
| 6068 | } | ||
| 6069 | } else if (auto local = stmt->content.as<Local_t>()) { | ||
| 6070 | if (local->item.is<LocalFlag_t>()) { | ||
| 6071 | throw CompileError("can not use local statement with wildcard operator in macro"sv, x); | ||
| 6072 | } | ||
| 6073 | } else if (auto localAttrib = stmt->content.as<LocalAttrib_t>()) { | ||
| 6074 | if (localAttrib->attrib.is<CloseAttrib_t>()) { | ||
| 6075 | throw CompileError("can not use close attribute statement in macro"sv, x); | ||
| 6076 | } | ||
| 6077 | } else if (stmt->content.as<Backcall_t>()) { | ||
| 6078 | throw CompileError("can not use back call statement in macro"sv, x); | ||
| 6079 | } else if (auto expListAssign = stmt->content.as<ExpListAssign_t>(); | ||
| 6080 | expListAssign && expListAssign->action && expListAssign->action.is<Assign_t>()) { | ||
| 6081 | BLOCK_START | ||
| 6082 | auto unary = singleUnaryExpFrom(expListAssign->expList->exprs.back()); | ||
| 6083 | BREAK_IF(!unary->ops.empty()); | ||
| 6084 | auto value = static_cast<Value_t*>(unary->expos.front()); | ||
| 6085 | auto simpleValue = value->item.as<SimpleValue_t>(); | ||
| 6086 | BREAK_IF(!simpleValue); | ||
| 6087 | auto varArg = simpleValue->value.as<VarArg_t>(); | ||
| 6088 | BREAK_IF(!varArg); | ||
| 6089 | throw CompileError("can not use variadic arguments assignment statement in macro"sv, x); | ||
| 6090 | BLOCK_END | ||
| 6091 | } | ||
| 6092 | } | ||
| 6093 | } | 6102 | } |
| 6094 | return {info.node, std::move(info.codes), Empty, std::move(localVars)}; | 6103 | return {info.node, std::move(info.codes), Empty, std::move(localVars)}; |
| 6095 | } else { | 6104 | } else { |
| @@ -6118,7 +6127,15 @@ private: | |||
| 6118 | return; | 6127 | return; |
| 6119 | } | 6128 | } |
| 6120 | if (usage == ExpUsage::Common || (usage == ExpUsage::Return && node.is<Block_t>())) { | 6129 | if (usage == ExpUsage::Common || (usage == ExpUsage::Return && node.is<Block_t>())) { |
| 6121 | transformBlock(node.to<Block_t>(), out, usage, assignList); | 6130 | if (node.to<Block_t>()->statements.empty()) { |
| 6131 | out.push_back(Empty); | ||
| 6132 | } else { | ||
| 6133 | auto doBody = node->new_ptr<Body_t>(); | ||
| 6134 | doBody->content.set(node); | ||
| 6135 | auto doNode = node->new_ptr<Do_t>(); | ||
| 6136 | doNode->body.set(doBody); | ||
| 6137 | transformDo(doNode, out, usage, assignList); | ||
| 6138 | } | ||
| 6122 | } else { | 6139 | } else { |
| 6123 | auto x = chainValue; | 6140 | auto x = chainValue; |
| 6124 | switch (usage) { | 6141 | switch (usage) { |
| @@ -6428,6 +6445,7 @@ private: | |||
| 6428 | } | 6445 | } |
| 6429 | if (varName.empty()) { | 6446 | if (varName.empty()) { |
| 6430 | str_list temp; | 6447 | str_list temp; |
| 6448 | bool isScoped = !currentScope().lastStatement; | ||
| 6431 | if (usage == ExpUsage::Closure) { | 6449 | if (usage == ExpUsage::Closure) { |
| 6432 | if (transformAsUpValueFunc(newExp(unary_exp, unary_exp), out)) { | 6450 | if (transformAsUpValueFunc(newExp(unary_exp, unary_exp), out)) { |
| 6433 | return; | 6451 | return; |
| @@ -6436,8 +6454,10 @@ private: | |||
| 6436 | pushAnonVarArg(); | 6454 | pushAnonVarArg(); |
| 6437 | pushScope(); | 6455 | pushScope(); |
| 6438 | } else if (usage == ExpUsage::Assignment) { | 6456 | } else if (usage == ExpUsage::Assignment) { |
| 6439 | temp.push_back(indent() + "do"s + nll(x)); | 6457 | if (isScoped) { |
| 6440 | pushScope(); | 6458 | temp.push_back(indent() + "do"s + nll(x)); |
| 6459 | pushScope(); | ||
| 6460 | } | ||
| 6441 | } | 6461 | } |
| 6442 | auto newUnaryExp = x->new_ptr<UnaryExp_t>(); | 6462 | auto newUnaryExp = x->new_ptr<UnaryExp_t>(); |
| 6443 | newUnaryExp->ops.dup(unary_exp->ops); | 6463 | newUnaryExp->ops.dup(unary_exp->ops); |
| @@ -6485,8 +6505,10 @@ private: | |||
| 6485 | popAnonVarArg(); | 6505 | popAnonVarArg(); |
| 6486 | popFunctionScope(); | 6506 | popFunctionScope(); |
| 6487 | } else if (usage == ExpUsage::Assignment) { | 6507 | } else if (usage == ExpUsage::Assignment) { |
| 6488 | popScope(); | 6508 | if (isScoped) { |
| 6489 | temp.push_back(indent() + "end"s + nll(x)); | 6509 | popScope(); |
| 6510 | temp.push_back(indent() + "end"s + nll(x)); | ||
| 6511 | } | ||
| 6490 | out.push_back(join(temp)); | 6512 | out.push_back(join(temp)); |
| 6491 | } else { | 6513 | } else { |
| 6492 | out.push_back(join(temp)); | 6514 | out.push_back(join(temp)); |
| @@ -6573,6 +6595,7 @@ private: | |||
| 6573 | 6595 | ||
| 6574 | void transformSpreadTable(const node_container& values, str_list& out, ExpUsage usage, ExpList_t* assignList = nullptr) { | 6596 | void transformSpreadTable(const node_container& values, str_list& out, ExpUsage usage, ExpList_t* assignList = nullptr) { |
| 6575 | auto x = values.front(); | 6597 | auto x = values.front(); |
| 6598 | bool extraScope = false; | ||
| 6576 | switch (usage) { | 6599 | switch (usage) { |
| 6577 | case ExpUsage::Closure: { | 6600 | case ExpUsage::Closure: { |
| 6578 | auto tableLit = x->new_ptr<TableLit_t>(); | 6601 | auto tableLit = x->new_ptr<TableLit_t>(); |
| @@ -6590,7 +6613,10 @@ private: | |||
| 6590 | break; | 6613 | break; |
| 6591 | } | 6614 | } |
| 6592 | case ExpUsage::Assignment: | 6615 | case ExpUsage::Assignment: |
| 6593 | pushScope(); | 6616 | if (!currentScope().lastStatement) { |
| 6617 | extraScope = true; | ||
| 6618 | pushScope(); | ||
| 6619 | } | ||
| 6594 | break; | 6620 | break; |
| 6595 | default: | 6621 | default: |
| 6596 | break; | 6622 | break; |
| @@ -6850,9 +6876,11 @@ private: | |||
| 6850 | assignment->expList.set(assignList); | 6876 | assignment->expList.set(assignList); |
| 6851 | assignment->action.set(assign); | 6877 | assignment->action.set(assign); |
| 6852 | transformAssignment(assignment, temp); | 6878 | transformAssignment(assignment, temp); |
| 6853 | popScope(); | 6879 | if (extraScope) popScope(); |
| 6854 | out.push_back(join(temp)); | 6880 | out.push_back(join(temp)); |
| 6855 | out.back() = indent() + "do"s + nll(x) + out.back() + indent() + "end"s + nlr(x); | 6881 | if (extraScope) { |
| 6882 | out.back() = indent() + "do"s + nll(x) + out.back() + indent() + "end"s + nlr(x); | ||
| 6883 | } | ||
| 6856 | break; | 6884 | break; |
| 6857 | } | 6885 | } |
| 6858 | case ExpUsage::Return: | 6886 | case ExpUsage::Return: |
| @@ -7107,6 +7135,7 @@ private: | |||
| 7107 | if (!def || def->defVal) { | 7135 | if (!def || def->defVal) { |
| 7108 | throw CompileError("invalid comprehension expression", comp->items.front()); | 7136 | throw CompileError("invalid comprehension expression", comp->items.front()); |
| 7109 | } | 7137 | } |
| 7138 | bool extraScope = false; | ||
| 7110 | switch (usage) { | 7139 | switch (usage) { |
| 7111 | case ExpUsage::Closure: { | 7140 | case ExpUsage::Closure: { |
| 7112 | auto simpleValue = x->new_ptr<SimpleValue_t>(); | 7141 | auto simpleValue = x->new_ptr<SimpleValue_t>(); |
| @@ -7120,7 +7149,10 @@ private: | |||
| 7120 | break; | 7149 | break; |
| 7121 | } | 7150 | } |
| 7122 | case ExpUsage::Assignment: | 7151 | case ExpUsage::Assignment: |
| 7123 | pushScope(); | 7152 | if (!currentScope().lastStatement) { |
| 7153 | extraScope = true; | ||
| 7154 | pushScope(); | ||
| 7155 | } | ||
| 7124 | break; | 7156 | break; |
| 7125 | default: | 7157 | default: |
| 7126 | break; | 7158 | break; |
| @@ -7191,8 +7223,11 @@ private: | |||
| 7191 | assignment->expList.set(assignList); | 7223 | assignment->expList.set(assignList); |
| 7192 | assignment->action.set(assign); | 7224 | assignment->action.set(assign); |
| 7193 | transformAssignment(assignment, temp); | 7225 | transformAssignment(assignment, temp); |
| 7194 | popScope(); | 7226 | out.back().append(temp.back()); |
| 7195 | out.back() = indent() + "do"s + nll(comp) + out.back() + temp.back() + indent() + "end"s + nlr(comp); | 7227 | if (extraScope) { |
| 7228 | popScope(); | ||
| 7229 | out.back() = indent() + "do"s + nll(comp) + out.back() + indent() + "end"s + nlr(comp); | ||
| 7230 | } | ||
| 7196 | break; | 7231 | break; |
| 7197 | } | 7232 | } |
| 7198 | case ExpUsage::Return: | 7233 | case ExpUsage::Return: |
| @@ -7204,13 +7239,14 @@ private: | |||
| 7204 | } | 7239 | } |
| 7205 | } | 7240 | } |
| 7206 | 7241 | ||
| 7207 | bool transformForEachHead(AssignableNameList_t* nameList, ast_node* loopTarget, str_list& out, bool isStatement = false) { | 7242 | bool transformForEachHead(AssignableNameList_t* nameList, ast_node* loopTarget, str_list& out, bool inClosure) { |
| 7208 | auto x = nameList; | 7243 | auto x = nameList; |
| 7209 | str_list temp; | 7244 | str_list temp; |
| 7210 | str_list vars; | 7245 | str_list vars; |
| 7211 | str_list varBefore, varAfter; | 7246 | str_list varBefore, varAfter; |
| 7212 | std::string varConstAfter; | 7247 | std::string varConstAfter; |
| 7213 | bool extraScope = false; | 7248 | bool extraScope = false; |
| 7249 | bool needScope = !currentScope().lastStatement; | ||
| 7214 | std::list<std::pair<ast_node*, ast_ptr<false, ast_node>>> destructPairs; | 7250 | std::list<std::pair<ast_node*, ast_ptr<false, ast_node>>> destructPairs; |
| 7215 | for (auto _item : nameList->items.objects()) { | 7251 | for (auto _item : nameList->items.objects()) { |
| 7216 | auto item = static_cast<NameOrDestructure_t*>(_item)->item.get(); | 7252 | auto item = static_cast<NameOrDestructure_t*>(_item)->item.get(); |
| @@ -7287,7 +7323,7 @@ private: | |||
| 7287 | } | 7323 | } |
| 7288 | if (listVar.empty()) { | 7324 | if (listVar.empty()) { |
| 7289 | std::string prefix; | 7325 | std::string prefix; |
| 7290 | if (isStatement) { | 7326 | if (!inClosure && needScope) { |
| 7291 | extraScope = true; | 7327 | extraScope = true; |
| 7292 | prefix = indent() + "do"s + nll(x); | 7328 | prefix = indent() + "do"s + nll(x); |
| 7293 | pushScope(); | 7329 | pushScope(); |
| @@ -7300,7 +7336,7 @@ private: | |||
| 7300 | std::string maxVar; | 7336 | std::string maxVar; |
| 7301 | if (!stopValue.empty()) { | 7337 | if (!stopValue.empty()) { |
| 7302 | std::string prefix; | 7338 | std::string prefix; |
| 7303 | if (isStatement && !extraScope) { | 7339 | if (!extraScope && !inClosure && needScope) { |
| 7304 | extraScope = true; | 7340 | extraScope = true; |
| 7305 | prefix = indent() + "do"s + nll(x); | 7341 | prefix = indent() + "do"s + nll(x); |
| 7306 | pushScope(); | 7342 | pushScope(); |
| @@ -7376,7 +7412,7 @@ private: | |||
| 7376 | } | 7412 | } |
| 7377 | 7413 | ||
| 7378 | void transformCompForEach(CompForEach_t* comp, str_list& out) { | 7414 | void transformCompForEach(CompForEach_t* comp, str_list& out) { |
| 7379 | transformForEachHead(comp->nameList, comp->loopValue, out); | 7415 | transformForEachHead(comp->nameList, comp->loopValue, out, true); |
| 7380 | } | 7416 | } |
| 7381 | 7417 | ||
| 7382 | void transformInvokeArgs(InvokeArgs_t* invokeArgs, str_list& out) { | 7418 | void transformInvokeArgs(InvokeArgs_t* invokeArgs, str_list& out) { |
| @@ -7741,9 +7777,12 @@ private: | |||
| 7741 | void transformForInPlace(For_t* forNode, str_list& out, ExpList_t* assignExpList = nullptr) { | 7777 | void transformForInPlace(For_t* forNode, str_list& out, ExpList_t* assignExpList = nullptr) { |
| 7742 | auto x = forNode; | 7778 | auto x = forNode; |
| 7743 | str_list temp; | 7779 | str_list temp; |
| 7780 | bool isScoped = !currentScope().lastStatement; | ||
| 7744 | if (assignExpList) { | 7781 | if (assignExpList) { |
| 7745 | _buf << indent() << "do"sv << nll(forNode); | 7782 | if (isScoped) { |
| 7746 | pushScope(); | 7783 | _buf << indent() << "do"sv << nll(forNode); |
| 7784 | pushScope(); | ||
| 7785 | } | ||
| 7747 | auto accum = transformForInner(forNode, temp); | 7786 | auto accum = transformForInner(forNode, temp); |
| 7748 | auto assign = x->new_ptr<Assign_t>(); | 7787 | auto assign = x->new_ptr<Assign_t>(); |
| 7749 | assign->values.push_back(toAst<Exp_t>(accum, x)); | 7788 | assign->values.push_back(toAst<Exp_t>(accum, x)); |
| @@ -7751,8 +7790,10 @@ private: | |||
| 7751 | assignment->expList.set(assignExpList); | 7790 | assignment->expList.set(assignExpList); |
| 7752 | assignment->action.set(assign); | 7791 | assignment->action.set(assign); |
| 7753 | transformAssignment(assignment, temp); | 7792 | transformAssignment(assignment, temp); |
| 7754 | popScope(); | 7793 | if (isScoped) { |
| 7755 | temp.push_back(indent() + "end"s + nlr(forNode)); | 7794 | popScope(); |
| 7795 | temp.push_back(indent() + "end"s + nlr(forNode)); | ||
| 7796 | } | ||
| 7756 | } else { | 7797 | } else { |
| 7757 | auto accum = transformForInner(forNode, temp); | 7798 | auto accum = transformForInner(forNode, temp); |
| 7758 | auto returnNode = x->new_ptr<Return_t>(); | 7799 | auto returnNode = x->new_ptr<Return_t>(); |
| @@ -7783,11 +7824,11 @@ private: | |||
| 7783 | 7824 | ||
| 7784 | void transformForEach(ForEach_t* forEach, str_list& out) { | 7825 | void transformForEach(ForEach_t* forEach, str_list& out) { |
| 7785 | str_list temp; | 7826 | str_list temp; |
| 7786 | bool extraScope = transformForEachHead(forEach->nameList, forEach->loopValue, temp, true); | 7827 | bool extraScoped = transformForEachHead(forEach->nameList, forEach->loopValue, temp, false); |
| 7787 | transformLoopBody(forEach->body, temp, Empty, ExpUsage::Common); | 7828 | transformLoopBody(forEach->body, temp, Empty, ExpUsage::Common); |
| 7788 | popScope(); | 7829 | popScope(); |
| 7789 | out.push_back(temp.front() + temp.back() + indent() + "end"s + nlr(forEach)); | 7830 | out.push_back(temp.front() + temp.back() + indent() + "end"s + nlr(forEach)); |
| 7790 | if (extraScope) { | 7831 | if (extraScoped) { |
| 7791 | popScope(); | 7832 | popScope(); |
| 7792 | out.back().append(indent() + "end"s + nlr(forEach)); | 7833 | out.back().append(indent() + "end"s + nlr(forEach)); |
| 7793 | } | 7834 | } |
| @@ -7802,7 +7843,7 @@ private: | |||
| 7802 | _buf << indent() << "local "sv << accum << " = { }"sv << nll(forEach); | 7843 | _buf << indent() << "local "sv << accum << " = { }"sv << nll(forEach); |
| 7803 | _buf << indent() << "local "sv << len << " = 1"sv << nll(forEach); | 7844 | _buf << indent() << "local "sv << len << " = 1"sv << nll(forEach); |
| 7804 | out.push_back(clearBuf()); | 7845 | out.push_back(clearBuf()); |
| 7805 | transformForEachHead(forEach->nameList, forEach->loopValue, out); | 7846 | transformForEachHead(forEach->nameList, forEach->loopValue, out, true); |
| 7806 | auto expList = toAst<ExpList_t>(accum + '[' + len + ']', x); | 7847 | auto expList = toAst<ExpList_t>(accum + '[' + len + ']', x); |
| 7807 | auto lenLine = len + " = "s + len + " + 1"s + nlr(forEach->body); | 7848 | auto lenLine = len + " = "s + len + " + 1"s + nlr(forEach->body); |
| 7808 | transformLoopBody(forEach->body, out, lenLine, ExpUsage::Assignment, expList); | 7849 | transformLoopBody(forEach->body, out, lenLine, ExpUsage::Assignment, expList); |
| @@ -7835,9 +7876,12 @@ private: | |||
| 7835 | void transformForEachInPlace(ForEach_t* forEach, str_list& out, ExpList_t* assignExpList = nullptr) { | 7876 | void transformForEachInPlace(ForEach_t* forEach, str_list& out, ExpList_t* assignExpList = nullptr) { |
| 7836 | auto x = forEach; | 7877 | auto x = forEach; |
| 7837 | str_list temp; | 7878 | str_list temp; |
| 7879 | bool isScoped = !currentScope().lastStatement; | ||
| 7838 | if (assignExpList) { | 7880 | if (assignExpList) { |
| 7839 | _buf << indent() << "do"sv << nll(forEach); | 7881 | if (isScoped) { |
| 7840 | pushScope(); | 7882 | _buf << indent() << "do"sv << nll(forEach); |
| 7883 | pushScope(); | ||
| 7884 | } | ||
| 7841 | auto accum = transformForEachInner(forEach, temp); | 7885 | auto accum = transformForEachInner(forEach, temp); |
| 7842 | auto assign = x->new_ptr<Assign_t>(); | 7886 | auto assign = x->new_ptr<Assign_t>(); |
| 7843 | assign->values.push_back(toAst<Exp_t>(accum, x)); | 7887 | assign->values.push_back(toAst<Exp_t>(accum, x)); |
| @@ -7845,8 +7889,10 @@ private: | |||
| 7845 | assignment->expList.set(assignExpList); | 7889 | assignment->expList.set(assignExpList); |
| 7846 | assignment->action.set(assign); | 7890 | assignment->action.set(assign); |
| 7847 | transformAssignment(assignment, temp); | 7891 | transformAssignment(assignment, temp); |
| 7848 | popScope(); | 7892 | if (isScoped) { |
| 7849 | temp.push_back(indent() + "end"s + nlr(forEach)); | 7893 | popScope(); |
| 7894 | temp.push_back(indent() + "end"s + nlr(forEach)); | ||
| 7895 | } | ||
| 7850 | } else { | 7896 | } else { |
| 7851 | auto accum = transformForEachInner(forEach, temp); | 7897 | auto accum = transformForEachInner(forEach, temp); |
| 7852 | auto returnNode = x->new_ptr<Return_t>(); | 7898 | auto returnNode = x->new_ptr<Return_t>(); |
| @@ -8035,6 +8081,7 @@ private: | |||
| 8035 | std::string className; | 8081 | std::string className; |
| 8036 | std::string assignItem; | 8082 | std::string assignItem; |
| 8037 | std::string classTextName; | 8083 | std::string classTextName; |
| 8084 | bool isScoped = !currentScope().lastStatement; | ||
| 8038 | if (assignable) { | 8085 | if (assignable) { |
| 8039 | if (!isAssignable(assignable)) { | 8086 | if (!isAssignable(assignable)) { |
| 8040 | throw CompileError("left hand expression is not assignable"sv, assignable); | 8087 | throw CompileError("left hand expression is not assignable"sv, assignable); |
| @@ -8078,8 +8125,10 @@ private: | |||
| 8078 | } | 8125 | } |
| 8079 | } | 8126 | } |
| 8080 | } | 8127 | } |
| 8081 | temp.push_back(indent() + "do"s + nll(classDecl)); | 8128 | if (isScoped) { |
| 8082 | pushScope(); | 8129 | temp.push_back(indent() + "do"s + nll(classDecl)); |
| 8130 | pushScope(); | ||
| 8131 | } | ||
| 8083 | auto classVar = getUnusedName("_class_"sv); | 8132 | auto classVar = getUnusedName("_class_"sv); |
| 8084 | addToScope(classVar); | 8133 | addToScope(classVar); |
| 8085 | temp.push_back(indent() + "local "s + classVar + nll(classDecl)); | 8134 | temp.push_back(indent() + "local "s + classVar + nll(classDecl)); |
| @@ -8295,8 +8344,10 @@ private: | |||
| 8295 | default: break; | 8344 | default: break; |
| 8296 | } | 8345 | } |
| 8297 | temp.push_back(clearBuf()); | 8346 | temp.push_back(clearBuf()); |
| 8298 | popScope(); | 8347 | if (isScoped) { |
| 8299 | temp.push_back(indent() + "end"s + nlr(classDecl)); | 8348 | popScope(); |
| 8349 | temp.push_back(indent() + "end"s + nlr(classDecl)); | ||
| 8350 | } | ||
| 8300 | out.push_back(join(temp)); | 8351 | out.push_back(join(temp)); |
| 8301 | } | 8352 | } |
| 8302 | 8353 | ||
| @@ -8469,7 +8520,8 @@ private: | |||
| 8469 | auto x = with; | 8520 | auto x = with; |
| 8470 | str_list temp; | 8521 | str_list temp; |
| 8471 | std::string withVar; | 8522 | std::string withVar; |
| 8472 | bool scoped = false; | 8523 | bool needScope = !currentScope().lastStatement && !returnValue; |
| 8524 | bool extraScope = false; | ||
| 8473 | if (with->assigns) { | 8525 | if (with->assigns) { |
| 8474 | auto vars = getAssignVars(with); | 8526 | auto vars = getAssignVars(with); |
| 8475 | if (vars.front().empty() || isDeclaredAsGlobal(vars.front())) { | 8527 | if (vars.front().empty() || isDeclaredAsGlobal(vars.front())) { |
| @@ -8486,8 +8538,8 @@ private: | |||
| 8486 | auto assign = x->new_ptr<Assign_t>(); | 8538 | auto assign = x->new_ptr<Assign_t>(); |
| 8487 | assign->values.push_back(with->assigns->values.objects().front()); | 8539 | assign->values.push_back(with->assigns->values.objects().front()); |
| 8488 | assignment->action.set(assign); | 8540 | assignment->action.set(assign); |
| 8489 | if (!returnValue) { | 8541 | if (needScope) { |
| 8490 | scoped = true; | 8542 | extraScope = true; |
| 8491 | temp.push_back(indent() + "do"s + nll(with)); | 8543 | temp.push_back(indent() + "do"s + nll(with)); |
| 8492 | pushScope(); | 8544 | pushScope(); |
| 8493 | } | 8545 | } |
| @@ -8512,8 +8564,8 @@ private: | |||
| 8512 | auto assignment = x->new_ptr<ExpListAssign_t>(); | 8564 | auto assignment = x->new_ptr<ExpListAssign_t>(); |
| 8513 | assignment->expList.set(with->valueList); | 8565 | assignment->expList.set(with->valueList); |
| 8514 | assignment->action.set(with->assigns); | 8566 | assignment->action.set(with->assigns); |
| 8515 | if (!returnValue) { | 8567 | if (needScope) { |
| 8516 | scoped = true; | 8568 | extraScope = true; |
| 8517 | temp.push_back(indent() + "do"s + nll(with)); | 8569 | temp.push_back(indent() + "do"s + nll(with)); |
| 8518 | pushScope(); | 8570 | pushScope(); |
| 8519 | } | 8571 | } |
| @@ -8528,17 +8580,17 @@ private: | |||
| 8528 | auto assign = x->new_ptr<Assign_t>(); | 8580 | auto assign = x->new_ptr<Assign_t>(); |
| 8529 | assign->values.dup(with->valueList->exprs); | 8581 | assign->values.dup(with->valueList->exprs); |
| 8530 | assignment->action.set(assign); | 8582 | assignment->action.set(assign); |
| 8531 | if (!returnValue) { | 8583 | if (needScope) { |
| 8532 | scoped = true; | 8584 | extraScope = true; |
| 8533 | temp.push_back(indent() + "do"s + nll(with)); | 8585 | temp.push_back(indent() + "do"s + nll(with)); |
| 8534 | pushScope(); | 8586 | pushScope(); |
| 8535 | } | 8587 | } |
| 8536 | transformAssignment(assignment, temp); | 8588 | transformAssignment(assignment, temp); |
| 8537 | } | 8589 | } |
| 8538 | } | 8590 | } |
| 8539 | if (!with->eop && !scoped && !returnValue) { | 8591 | if (needScope && !with->eop && !extraScope) { |
| 8540 | pushScope(); | 8592 | pushScope(); |
| 8541 | scoped = traversal::Stop == with->body->traverse([&](ast_node* node) { | 8593 | extraScope = traversal::Stop == with->body->traverse([&](ast_node* node) { |
| 8542 | if (auto statement = ast_cast<Statement_t>(node)) { | 8594 | if (auto statement = ast_cast<Statement_t>(node)) { |
| 8543 | ClassDecl_t* clsDecl = nullptr; | 8595 | ClassDecl_t* clsDecl = nullptr; |
| 8544 | if (auto assignment = assignmentFrom(statement)) { | 8596 | if (auto assignment = assignmentFrom(statement)) { |
| @@ -8576,7 +8628,7 @@ private: | |||
| 8576 | return traversal::Continue; | 8628 | return traversal::Continue; |
| 8577 | }); | 8629 | }); |
| 8578 | popScope(); | 8630 | popScope(); |
| 8579 | if (scoped) { | 8631 | if (extraScope) { |
| 8580 | temp.push_back(indent() + "do"s + nll(with)); | 8632 | temp.push_back(indent() + "do"s + nll(with)); |
| 8581 | pushScope(); | 8633 | pushScope(); |
| 8582 | } | 8634 | } |
| @@ -8606,7 +8658,7 @@ private: | |||
| 8606 | temp.push_back(indent() + "return "s + withVar + nll(with)); | 8658 | temp.push_back(indent() + "return "s + withVar + nll(with)); |
| 8607 | } | 8659 | } |
| 8608 | } | 8660 | } |
| 8609 | if (scoped) { | 8661 | if (extraScope) { |
| 8610 | popScope(); | 8662 | popScope(); |
| 8611 | temp.push_back(indent() + "end"s + nll(with)); | 8663 | temp.push_back(indent() + "end"s + nll(with)); |
| 8612 | } | 8664 | } |
| @@ -8863,6 +8915,7 @@ private: | |||
| 8863 | } | 8915 | } |
| 8864 | 8916 | ||
| 8865 | void transformTblComprehension(TblComprehension_t* comp, str_list& out, ExpUsage usage, ExpList_t* assignList = nullptr) { | 8917 | void transformTblComprehension(TblComprehension_t* comp, str_list& out, ExpUsage usage, ExpList_t* assignList = nullptr) { |
| 8918 | bool extraScope = false; | ||
| 8866 | switch (usage) { | 8919 | switch (usage) { |
| 8867 | case ExpUsage::Closure: { | 8920 | case ExpUsage::Closure: { |
| 8868 | auto simpleValue = comp->new_ptr<SimpleValue_t>(); | 8921 | auto simpleValue = comp->new_ptr<SimpleValue_t>(); |
| @@ -8876,7 +8929,10 @@ private: | |||
| 8876 | break; | 8929 | break; |
| 8877 | } | 8930 | } |
| 8878 | case ExpUsage::Assignment: | 8931 | case ExpUsage::Assignment: |
| 8879 | pushScope(); | 8932 | if (!currentScope().lastStatement) { |
| 8933 | extraScope = true; | ||
| 8934 | pushScope(); | ||
| 8935 | } | ||
| 8880 | break; | 8936 | break; |
| 8881 | default: | 8937 | default: |
| 8882 | break; | 8938 | break; |
| @@ -8944,9 +9000,11 @@ private: | |||
| 8944 | assignment->action.set(assign); | 9000 | assignment->action.set(assign); |
| 8945 | transformAssignment(assignment, temp); | 9001 | transformAssignment(assignment, temp); |
| 8946 | out.back().append(temp.back()); | 9002 | out.back().append(temp.back()); |
| 8947 | popScope(); | 9003 | if (extraScope) { |
| 8948 | out.back().insert(0, indent() + "do"s + nll(comp)); | 9004 | popScope(); |
| 8949 | out.back().append(indent() + "end"s + nlr(comp)); | 9005 | out.back().insert(0, indent() + "do"s + nll(comp)); |
| 9006 | out.back().append(indent() + "end"s + nlr(comp)); | ||
| 9007 | } | ||
| 8950 | break; | 9008 | break; |
| 8951 | } | 9009 | } |
| 8952 | case ExpUsage::Return: | 9010 | case ExpUsage::Return: |
| @@ -8986,18 +9044,20 @@ private: | |||
| 8986 | pushAnonFunctionScope(); | 9044 | pushAnonFunctionScope(); |
| 8987 | pushAnonVarArg(); | 9045 | pushAnonVarArg(); |
| 8988 | funcStart = &temp.emplace_back(); | 9046 | funcStart = &temp.emplace_back(); |
| 9047 | pushScope(); | ||
| 8989 | } else { | 9048 | } else { |
| 8990 | temp.push_back(indent() + "do"s + nll(doNode)); | 9049 | temp.push_back(indent() + "do"s + nll(doNode)); |
| 9050 | pushScope(); | ||
| 8991 | } | 9051 | } |
| 8992 | pushScope(); | ||
| 8993 | transformBody(doNode->body, temp, usage, assignList); | 9052 | transformBody(doNode->body, temp, usage, assignList); |
| 8994 | popScope(); | ||
| 8995 | if (usage == ExpUsage::Closure) { | 9053 | if (usage == ExpUsage::Closure) { |
| 9054 | popScope(); | ||
| 8996 | *funcStart = anonFuncStart() + nll(doNode); | 9055 | *funcStart = anonFuncStart() + nll(doNode); |
| 8997 | temp.push_back(indent() + anonFuncEnd()); | 9056 | temp.push_back(indent() + anonFuncEnd()); |
| 8998 | popAnonVarArg(); | 9057 | popAnonVarArg(); |
| 8999 | popFunctionScope(); | 9058 | popFunctionScope(); |
| 9000 | } else { | 9059 | } else { |
| 9060 | popScope(); | ||
| 9001 | temp.push_back(indent() + "end"s + nlr(doNode)); | 9061 | temp.push_back(indent() + "end"s + nlr(doNode)); |
| 9002 | } | 9062 | } |
| 9003 | out.push_back(join(temp)); | 9063 | out.push_back(join(temp)); |
| @@ -9225,13 +9285,17 @@ private: | |||
| 9225 | default: YUEE("AST node mismatch", name); break; | 9285 | default: YUEE("AST node mismatch", name); break; |
| 9226 | } | 9286 | } |
| 9227 | } | 9287 | } |
| 9288 | bool extraScope = false; | ||
| 9228 | if (objAssign) { | 9289 | if (objAssign) { |
| 9229 | auto preDef = toLocalDecl(transformAssignDefs(expList, DefOp::Mark)); | 9290 | auto preDef = toLocalDecl(transformAssignDefs(expList, DefOp::Mark)); |
| 9230 | if (!preDef.empty()) { | 9291 | if (!preDef.empty()) { |
| 9231 | temp.push_back(preDef + nll(importNode)); | 9292 | temp.push_back(preDef + nll(importNode)); |
| 9232 | } | 9293 | } |
| 9233 | temp.push_back(indent() + "do"s + nll(importNode)); | 9294 | if (!currentScope().lastStatement) { |
| 9234 | pushScope(); | 9295 | extraScope = true; |
| 9296 | temp.push_back(indent() + "do"s + nll(importNode)); | ||
| 9297 | pushScope(); | ||
| 9298 | } | ||
| 9235 | transformAssignment(objAssign, temp); | 9299 | transformAssignment(objAssign, temp); |
| 9236 | } | 9300 | } |
| 9237 | auto assignment = x->new_ptr<ExpListAssign_t>(); | 9301 | auto assignment = x->new_ptr<ExpListAssign_t>(); |
| @@ -9239,8 +9303,10 @@ private: | |||
| 9239 | assignment->action.set(assign); | 9303 | assignment->action.set(assign); |
| 9240 | transformAssignment(assignment, temp); | 9304 | transformAssignment(assignment, temp); |
| 9241 | if (objAssign) { | 9305 | if (objAssign) { |
| 9242 | popScope(); | 9306 | if (extraScope) { |
| 9243 | temp.push_back(indent() + "end"s + nlr(importNode)); | 9307 | popScope(); |
| 9308 | temp.push_back(indent() + "end"s + nlr(importNode)); | ||
| 9309 | } | ||
| 9244 | } | 9310 | } |
| 9245 | out.push_back(join(temp)); | 9311 | out.push_back(join(temp)); |
| 9246 | auto vars = getAssignVars(assignment); | 9312 | auto vars = getAssignVars(assignment); |
| @@ -9485,9 +9551,13 @@ private: | |||
| 9485 | void transformWhileInPlace(While_t* whileNode, str_list& out, ExpList_t* expList = nullptr) { | 9551 | void transformWhileInPlace(While_t* whileNode, str_list& out, ExpList_t* expList = nullptr) { |
| 9486 | auto x = whileNode; | 9552 | auto x = whileNode; |
| 9487 | str_list temp; | 9553 | str_list temp; |
| 9554 | bool extraScope = false; | ||
| 9488 | if (expList) { | 9555 | if (expList) { |
| 9489 | temp.push_back(indent() + "do"s + nll(whileNode)); | 9556 | if (!currentScope().lastStatement) { |
| 9490 | pushScope(); | 9557 | extraScope = true; |
| 9558 | temp.push_back(indent() + "do"s + nll(whileNode)); | ||
| 9559 | pushScope(); | ||
| 9560 | } | ||
| 9491 | } | 9561 | } |
| 9492 | auto accumVar = getUnusedName("_accum_"sv); | 9562 | auto accumVar = getUnusedName("_accum_"sv); |
| 9493 | addToScope(accumVar); | 9563 | addToScope(accumVar); |
| @@ -9511,11 +9581,11 @@ private: | |||
| 9511 | assignment->expList.set(expList); | 9581 | assignment->expList.set(expList); |
| 9512 | assignment->action.set(assign); | 9582 | assignment->action.set(assign); |
| 9513 | transformAssignment(assignment, temp); | 9583 | transformAssignment(assignment, temp); |
| 9514 | popScope(); | 9584 | if (extraScope) popScope(); |
| 9515 | } else { | 9585 | } else { |
| 9516 | temp.push_back(indent() + "return "s + accumVar + nlr(whileNode)); | 9586 | temp.push_back(indent() + "return "s + accumVar + nlr(whileNode)); |
| 9517 | } | 9587 | } |
| 9518 | if (expList) { | 9588 | if (expList && extraScope) { |
| 9519 | temp.push_back(indent() + "end"s + nlr(whileNode)); | 9589 | temp.push_back(indent() + "end"s + nlr(whileNode)); |
| 9520 | } | 9590 | } |
| 9521 | out.push_back(join(temp)); | 9591 | out.push_back(join(temp)); |
| @@ -9589,6 +9659,7 @@ private: | |||
| 9589 | void transformSwitch(Switch_t* switchNode, str_list& out, ExpUsage usage, ExpList_t* assignList = nullptr) { | 9659 | void transformSwitch(Switch_t* switchNode, str_list& out, ExpUsage usage, ExpList_t* assignList = nullptr) { |
| 9590 | auto x = switchNode; | 9660 | auto x = switchNode; |
| 9591 | str_list temp; | 9661 | str_list temp; |
| 9662 | bool needScope = !currentScope().lastStatement; | ||
| 9592 | std::string* funcStart = nullptr; | 9663 | std::string* funcStart = nullptr; |
| 9593 | if (usage == ExpUsage::Closure) { | 9664 | if (usage == ExpUsage::Closure) { |
| 9594 | auto simpleValue = x->new_ptr<SimpleValue_t>(); | 9665 | auto simpleValue = x->new_ptr<SimpleValue_t>(); |
| @@ -9605,9 +9676,11 @@ private: | |||
| 9605 | auto objVar = singleVariableFrom(switchNode->target, AccessType::Read); | 9676 | auto objVar = singleVariableFrom(switchNode->target, AccessType::Read); |
| 9606 | if (objVar.empty() || !isLocal(objVar)) { | 9677 | if (objVar.empty() || !isLocal(objVar)) { |
| 9607 | if (usage == ExpUsage::Common || usage == ExpUsage::Assignment) { | 9678 | if (usage == ExpUsage::Common || usage == ExpUsage::Assignment) { |
| 9608 | extraScope = true; | 9679 | if (needScope) { |
| 9609 | temp.push_back(indent() + "do"s + nll(x)); | 9680 | extraScope = true; |
| 9610 | pushScope(); | 9681 | temp.push_back(indent() + "do"s + nll(x)); |
| 9682 | pushScope(); | ||
| 9683 | } | ||
| 9611 | } | 9684 | } |
| 9612 | objVar = getUnusedName("_exp_"sv); | 9685 | objVar = getUnusedName("_exp_"sv); |
| 9613 | auto expList = toAst<ExpList_t>(objVar, x); | 9686 | auto expList = toAst<ExpList_t>(objVar, x); |
| @@ -9640,7 +9713,7 @@ private: | |||
| 9640 | addScope++; | 9713 | addScope++; |
| 9641 | } | 9714 | } |
| 9642 | if (tabCheckVar.empty()) { | 9715 | if (tabCheckVar.empty()) { |
| 9643 | if (!extraScope) { | 9716 | if (!extraScope && needScope) { |
| 9644 | temp.push_back(indent() + "do"s + nll(branch)); | 9717 | temp.push_back(indent() + "do"s + nll(branch)); |
| 9645 | pushScope(); | 9718 | pushScope(); |
| 9646 | extraScope = true; | 9719 | extraScope = true; |
