diff options
| author | Li Jin <dragon-fly@qq.com> | 2024-03-21 09:14:34 +0800 |
|---|---|---|
| committer | Li Jin <dragon-fly@qq.com> | 2024-03-21 09:14:34 +0800 |
| commit | 4a3cc26c6dfd74e61c8b6480038d6a292ea86e47 (patch) | |
| tree | 9554b94cfc15e4acee0c2e60b63af16f1b828207 /spec/outputs/codes_from_doc.lua | |
| parent | 80b65520da432843f0c63431a1867bd2620bc4ac (diff) | |
| download | yuescript-4a3cc26c6dfd74e61c8b6480038d6a292ea86e47.tar.gz yuescript-4a3cc26c6dfd74e61c8b6480038d6a292ea86e47.tar.bz2 yuescript-4a3cc26c6dfd74e61c8b6480038d6a292ea86e47.zip | |
remove redundant 'do' blocks in code generation.
Diffstat (limited to 'spec/outputs/codes_from_doc.lua')
| -rw-r--r-- | spec/outputs/codes_from_doc.lua | 2250 |
1 files changed, 1048 insertions, 1202 deletions
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) |
