aboutsummaryrefslogtreecommitdiff
path: root/spec/outputs/destructure.lua
diff options
context:
space:
mode:
authorLi Jin <dragon-fly@qq.com>2024-03-21 09:14:34 +0800
committerLi Jin <dragon-fly@qq.com>2024-03-21 09:14:34 +0800
commit4a3cc26c6dfd74e61c8b6480038d6a292ea86e47 (patch)
tree9554b94cfc15e4acee0c2e60b63af16f1b828207 /spec/outputs/destructure.lua
parent80b65520da432843f0c63431a1867bd2620bc4ac (diff)
downloadyuescript-4a3cc26c6dfd74e61c8b6480038d6a292ea86e47.tar.gz
yuescript-4a3cc26c6dfd74e61c8b6480038d6a292ea86e47.tar.bz2
yuescript-4a3cc26c6dfd74e61c8b6480038d6a292ea86e47.zip
remove redundant 'do' blocks in code generation.
Diffstat (limited to 'spec/outputs/destructure.lua')
-rw-r--r--spec/outputs/destructure.lua136
1 files changed, 62 insertions, 74 deletions
diff --git a/spec/outputs/destructure.lua b/spec/outputs/destructure.lua
index 38f21ff..224ed2d 100644
--- a/spec/outputs/destructure.lua
+++ b/spec/outputs/destructure.lua
@@ -131,11 +131,9 @@ do
131 end 131 end
132end 132end
133do 133do
134 do 134 local _with_0 = thing
135 local _with_0 = thing 135 local a, b = _with_0[1], _with_0[2]
136 local a, b = _with_0[1], _with_0[2] 136 print(a, b)
137 print(a, b)
138 end
139end 137end
140do 138do
141 local thing = nil 139 local thing = nil
@@ -314,11 +312,9 @@ do
314 _tmp_0 = _obj_0.func 312 _tmp_0 = _obj_0.func
315 end 313 end
316 if _tmp_0 == nil then 314 if _tmp_0 == nil then
317 do 315 local _obj_0 = item
318 local _obj_0 = item 316 if _obj_0 ~= nil then
319 if _obj_0 ~= nil then 317 _tmp_0 = _obj_0.defVal
320 _tmp_0 = _obj_0.defVal
321 end
322 end 318 end
323 end 319 end
324 a.b(function() 320 a.b(function()
@@ -449,11 +445,9 @@ do
449 end 445 end
450 local y1, y4 446 local y1, y4
451 local y2, y3 447 local y2, y3
452 do 448 local _obj_0, _obj_1 = f2()
453 local _obj_0, _obj_1 = f2() 449 y1, y4 = f1(), _obj_1
454 y1, y4 = f1(), _obj_1 450 y2, y3 = _obj_0.y2, _obj_0.y3
455 y2, y3 = _obj_0.y2, _obj_0.y3
456 end
457end 451end
458do 452do
459 local v1, v2, v3, v4 453 local v1, v2, v3, v4
@@ -483,11 +477,9 @@ do
483end 477end
484do 478do
485 local value, value_meta 479 local value, value_meta
486 do 480 local _obj_0 = tb
487 local _obj_0 = tb 481 value = _obj_0[name]
488 value = _obj_0[name] 482 value_meta = getmetatable(_obj_0)[name]
489 value_meta = getmetatable(_obj_0)[name]
490 end
491end 483end
492do 484do
493 local tostring, add 485 local tostring, add
@@ -500,24 +492,22 @@ do
500 end) 492 end)
501 end 493 end
502 end 494 end
503 do 495 local _exp_0 = tb
504 local _exp_0 = tb 496 local _type_0 = type(_exp_0)
505 local _type_0 = type(_exp_0) 497 local _tab_0 = "table" == _type_0 or "userdata" == _type_0
506 local _tab_0 = "table" == _type_0 or "userdata" == _type_0 498 if _tab_0 then
507 if _tab_0 then 499 local name, meta_field
508 local name, meta_field 500 do
509 do 501 local _obj_0 = getmetatable(_exp_0)
510 local _obj_0 = getmetatable(_exp_0) 502 name = _obj_0.__name
511 name = _obj_0.__name 503 meta_field = _obj_0["123"]
512 meta_field = _obj_0["123"] 504 if name == nil then
513 if name == nil then 505 name = "item"
514 name = "item"
515 end
516 end
517 if meta_field ~= nil then
518 print(name, meta_field)
519 end 506 end
520 end 507 end
508 if meta_field ~= nil then
509 print(name, meta_field)
510 end
521 end 511 end
522end 512end
523do 513do
@@ -599,52 +589,50 @@ do
599 print(add, field) 589 print(add, field)
600 end 590 end
601 end 591 end
602 do 592 local _exp_0 = tb
603 local _exp_0 = tb 593 local _type_0 = type(_exp_0)
604 local _type_0 = type(_exp_0) 594 local _tab_0 = "table" == _type_0 or "userdata" == _type_0
605 local _tab_0 = "table" == _type_0 or "userdata" == _type_0 595 if _tab_0 then
606 if _tab_0 then 596 do
607 do 597 local _obj_0 = _exp_0.c
608 local _obj_0 = _exp_0.c 598 local _type_1 = type(_obj_0)
609 local _type_1 = type(_obj_0) 599 if "table" == _type_1 or "userdata" == _type_1 then
610 if "table" == _type_1 or "userdata" == _type_1 then 600 do
611 do 601 local _obj_1 = getmetatable(_obj_0)
612 local _obj_1 = getmetatable(_obj_0) 602 local _type_2 = type(_obj_1)
613 local _type_2 = type(_obj_1) 603 if "table" == _type_2 or "userdata" == _type_2 then
614 if "table" == _type_2 or "userdata" == _type_2 then 604 meta_field = _obj_1["abc"]
615 meta_field = _obj_1["abc"]
616 end
617 end 605 end
618 end 606 end
619 end 607 end
620 if meta_field == nil then 608 end
621 meta_field = "def" 609 if meta_field == nil then
622 end 610 meta_field = "def"
611 end
612 do
613 local _obj_0 = getmetatable(_exp_0)
623 do 614 do
624 local _obj_0 = getmetatable(_exp_0) 615 local _obj_1 = _obj_0[ [[any string]]]
625 do 616 local _type_1 = type(_obj_1)
626 local _obj_1 = _obj_0[ [[any string]]] 617 if "table" == _type_1 or "userdata" == _type_1 then
627 local _type_1 = type(_obj_1) 618 abc = _obj_1.d
628 if "table" == _type_1 or "userdata" == _type_1 then
629 abc = _obj_1.d
630 end
631 end
632 do
633 local _obj_1 = _obj_0['str']
634 local _type_1 = type(_obj_1)
635 if "table" == _type_1 or "userdata" == _type_1 then
636 def = _obj_1.e
637 end
638 end
639 if abc == nil then
640 abc = 123
641 end 619 end
642 if def == nil then 620 end
643 def = { } 621 do
622 local _obj_1 = _obj_0['str']
623 local _type_1 = type(_obj_1)
624 if "table" == _type_1 or "userdata" == _type_1 then
625 def = _obj_1.e
644 end 626 end
645 end 627 end
646 print(meta_field, abc, def) 628 if abc == nil then
629 abc = 123
630 end
631 if def == nil then
632 def = { }
633 end
647 end 634 end
635 print(meta_field, abc, def)
648 end 636 end
649end 637end
650return nil 638return nil