diff options
| author | Li Jin <dragon-fly@qq.com> | 2021-10-31 17:29:45 +0800 |
|---|---|---|
| committer | Li Jin <dragon-fly@qq.com> | 2021-10-31 17:29:45 +0800 |
| commit | aed806476fe50899c0f01750175531ac41267b9d (patch) | |
| tree | c46f212a2987a9088b03e2c0225f18cd9a5d4265 /spec/outputs/switch.lua | |
| parent | 60a979e224f26117f5be82bfca757a2483cef0fd (diff) | |
| download | yuescript-aed806476fe50899c0f01750175531ac41267b9d.tar.gz yuescript-aed806476fe50899c0f01750175531ac41267b9d.tar.bz2 yuescript-aed806476fe50899c0f01750175531ac41267b9d.zip | |
partially fix issue #69, fix a few case the generated code leaks some temp variables.
Diffstat (limited to 'spec/outputs/switch.lua')
| -rw-r--r-- | spec/outputs/switch.lua | 110 |
1 files changed, 63 insertions, 47 deletions
diff --git a/spec/outputs/switch.lua b/spec/outputs/switch.lua index 1c8839f..81f6d5a 100644 --- a/spec/outputs/switch.lua +++ b/spec/outputs/switch.lua | |||
| @@ -1,70 +1,86 @@ | |||
| 1 | local _exp_0 = value | 1 | do |
| 2 | if "cool" == _exp_0 then | 2 | local _exp_0 = value |
| 3 | print("hello world") | 3 | if "cool" == _exp_0 then |
| 4 | print("hello world") | ||
| 5 | end | ||
| 4 | end | 6 | end |
| 5 | local _exp_1 = value | 7 | do |
| 6 | if "cool" == _exp_1 then | 8 | local _exp_0 = value |
| 7 | print("hello world") | 9 | if "cool" == _exp_0 then |
| 8 | else | 10 | print("hello world") |
| 9 | print("okay rad") | 11 | else |
| 12 | print("okay rad") | ||
| 13 | end | ||
| 10 | end | 14 | end |
| 11 | local _exp_2 = value | 15 | do |
| 12 | if "cool" == _exp_2 then | 16 | local _exp_0 = value |
| 13 | print("hello world") | 17 | if "cool" == _exp_0 then |
| 14 | elseif "yeah" == _exp_2 then | 18 | print("hello world") |
| 15 | local _ = [[FFFF]] + [[MMMM]] | 19 | elseif "yeah" == _exp_0 then |
| 16 | elseif (2323 + 32434) == _exp_2 then | 20 | local _ = [[FFFF]] + [[MMMM]] |
| 17 | print("okay") | 21 | elseif (2323 + 32434) == _exp_0 then |
| 18 | else | 22 | print("okay") |
| 19 | print("okay rad") | 23 | else |
| 24 | print("okay rad") | ||
| 25 | end | ||
| 20 | end | 26 | end |
| 21 | local out | 27 | local out |
| 22 | local _exp_3 = value | 28 | do |
| 23 | if "cool" == _exp_3 then | 29 | local _exp_0 = value |
| 24 | out = print("hello world") | 30 | if "cool" == _exp_0 then |
| 25 | else | 31 | out = print("hello world") |
| 26 | out = print("okay rad") | 32 | else |
| 33 | out = print("okay rad") | ||
| 34 | end | ||
| 27 | end | 35 | end |
| 28 | local _exp_4 = value | 36 | do |
| 29 | if "cool" == _exp_4 then | 37 | local _exp_0 = value |
| 30 | out = xxxx | 38 | if "cool" == _exp_0 then |
| 31 | elseif "umm" == _exp_4 then | 39 | out = xxxx |
| 32 | out = 34340 | 40 | elseif "umm" == _exp_0 then |
| 33 | else | 41 | out = 34340 |
| 34 | out = error("this failed big time") | 42 | else |
| 43 | out = error("this failed big time") | ||
| 44 | end | ||
| 35 | end | 45 | end |
| 36 | do | 46 | do |
| 37 | local _with_0 = something | 47 | local _with_0 = something |
| 38 | local _exp_5 = _with_0:value() | 48 | do |
| 39 | if _with_0.okay == _exp_5 then | 49 | local _exp_0 = _with_0:value() |
| 40 | local _ = "world" | 50 | if _with_0.okay == _exp_0 then |
| 41 | else | 51 | local _ = "world" |
| 42 | local _ = "yesh" | 52 | else |
| 53 | local _ = "yesh" | ||
| 54 | end | ||
| 43 | end | 55 | end |
| 44 | end | 56 | end |
| 45 | fix(this) | 57 | fix(this) |
| 46 | call_func((function() | 58 | call_func((function() |
| 47 | local _exp_5 = something | 59 | local _exp_0 = something |
| 48 | if 1 == _exp_5 then | 60 | if 1 == _exp_0 then |
| 49 | return "yes" | 61 | return "yes" |
| 50 | else | 62 | else |
| 51 | return "no" | 63 | return "no" |
| 52 | end | 64 | end |
| 53 | end)()) | 65 | end)()) |
| 54 | local _exp_5 = hi | 66 | do |
| 55 | if (hello or world) == _exp_5 then | 67 | local _exp_0 = hi |
| 56 | local _ = greene | 68 | if (hello or world) == _exp_0 then |
| 69 | local _ = greene | ||
| 70 | end | ||
| 57 | end | 71 | end |
| 58 | local _exp_6 = hi | 72 | do |
| 59 | if "one" == _exp_6 or "two" == _exp_6 then | 73 | local _exp_0 = hi |
| 60 | print("cool") | 74 | if "one" == _exp_0 or "two" == _exp_0 then |
| 61 | elseif "dad" == _exp_6 then | 75 | print("cool") |
| 62 | local _ = no | 76 | elseif "dad" == _exp_0 then |
| 77 | local _ = no | ||
| 78 | end | ||
| 63 | end | 79 | end |
| 64 | local _exp_7 = hi | 80 | local _exp_0 = hi |
| 65 | if (3 + 1) == _exp_7 or hello() == _exp_7 or (function() | 81 | if (3 + 1) == _exp_0 or hello() == _exp_0 or (function() |
| 66 | return 4 | 82 | return 4 |
| 67 | end)() == _exp_7 then | 83 | end)() == _exp_0 then |
| 68 | return yello | 84 | return yello |
| 69 | else | 85 | else |
| 70 | return print("cool") | 86 | return print("cool") |
