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