diff options
| author | Li Jin <dragon-fly@qq.com> | 2024-03-21 09:14:34 +0800 |
|---|---|---|
| committer | Li Jin <dragon-fly@qq.com> | 2024-03-21 09:14:34 +0800 |
| commit | 4a3cc26c6dfd74e61c8b6480038d6a292ea86e47 (patch) | |
| tree | 9554b94cfc15e4acee0c2e60b63af16f1b828207 /spec/outputs/with.lua | |
| parent | 80b65520da432843f0c63431a1867bd2620bc4ac (diff) | |
| download | yuescript-4a3cc26c6dfd74e61c8b6480038d6a292ea86e47.tar.gz yuescript-4a3cc26c6dfd74e61c8b6480038d6a292ea86e47.tar.bz2 yuescript-4a3cc26c6dfd74e61c8b6480038d6a292ea86e47.zip | |
remove redundant 'do' blocks in code generation.
Diffstat (limited to 'spec/outputs/with.lua')
| -rw-r--r-- | spec/outputs/with.lua | 176 |
1 files changed, 71 insertions, 105 deletions
diff --git a/spec/outputs/with.lua b/spec/outputs/with.lua index 304d26e..b2a1c3b 100644 --- a/spec/outputs/with.lua +++ b/spec/outputs/with.lua | |||
| @@ -9,24 +9,20 @@ do | |||
| 9 | end | 9 | end |
| 10 | end | 10 | end |
| 11 | do | 11 | do |
| 12 | do | 12 | local _with_0 = leaf |
| 13 | local _with_0 = leaf | 13 | _with_0.world() |
| 14 | _with_0.world() | 14 | _with_0.world(1, 2, 3) |
| 15 | _with_0.world(1, 2, 3) | 15 | local g = _with_0.what.is.this |
| 16 | local g = _with_0.what.is.this | 16 | _with_0.hi(1, 2, 3) |
| 17 | _with_0.hi(1, 2, 3) | 17 | _with_0:hi(1, 2).world(2323) |
| 18 | _with_0:hi(1, 2).world(2323) | 18 | _with_0:hi("yeah", "man") |
| 19 | _with_0:hi("yeah", "man") | 19 | _with_0.world = 200 |
| 20 | _with_0.world = 200 | ||
| 21 | end | ||
| 22 | end | 20 | end |
| 23 | do | 21 | do |
| 24 | local zyzyzy | 22 | local zyzyzy |
| 25 | do | 23 | local _with_0 = something |
| 26 | local _with_0 = something | 24 | _with_0.set_state("hello world") |
| 27 | _with_0.set_state("hello world") | 25 | zyzyzy = _with_0 |
| 28 | zyzyzy = _with_0 | ||
| 29 | end | ||
| 30 | end | 26 | end |
| 31 | do | 27 | do |
| 32 | local x = 5 + (function() | 28 | local x = 5 + (function() |
| @@ -45,12 +41,10 @@ do | |||
| 45 | } | 41 | } |
| 46 | end | 42 | end |
| 47 | do | 43 | do |
| 48 | do | 44 | local _with_0 = foo |
| 49 | local _with_0 = foo | 45 | local _ = _with_0:prop("something").hello |
| 50 | local _ = _with_0:prop("something").hello | 46 | _with_0.prop:send(one) |
| 51 | _with_0.prop:send(one) | 47 | _with_0.prop:send(one) |
| 52 | _with_0.prop:send(one) | ||
| 53 | end | ||
| 54 | end | 48 | end |
| 55 | do | 49 | do |
| 56 | do | 50 | do |
| @@ -79,69 +73,49 @@ do | |||
| 79 | return a | 73 | return a |
| 80 | end)()) | 74 | end)()) |
| 81 | local p | 75 | local p |
| 82 | do | 76 | local _with_0 = 1 |
| 83 | local _with_0 = 1 | 77 | hello().x, world().y = _with_0, 2 |
| 84 | hello().x, world().y = _with_0, 2 | 78 | print(a + b) |
| 85 | print(a + b) | 79 | p = _with_0 |
| 86 | p = _with_0 | ||
| 87 | end | ||
| 88 | end | 80 | end |
| 89 | do | 81 | do |
| 90 | local x = "hello" | 82 | local x = "hello" |
| 91 | x:upper() | 83 | x:upper() |
| 92 | end | 84 | end |
| 93 | do | 85 | do |
| 94 | do | 86 | local k = "jo" |
| 95 | local k = "jo" | 87 | print(k:upper()) |
| 96 | print(k:upper()) | ||
| 97 | end | ||
| 98 | end | 88 | end |
| 99 | do | 89 | do |
| 100 | do | 90 | local a, b, c = "", "", "" |
| 101 | local a, b, c = "", "", "" | 91 | print(a:upper()) |
| 102 | print(a:upper()) | ||
| 103 | end | ||
| 104 | end | 92 | end |
| 105 | do | 93 | do |
| 106 | local a = "bunk" | 94 | local a = "bunk" |
| 107 | do | 95 | local b, c |
| 108 | local b, c | 96 | a, b, c = "", "", "" |
| 109 | a, b, c = "", "", "" | 97 | print(a:upper()) |
| 110 | print(a:upper()) | ||
| 111 | end | ||
| 112 | end | 98 | end |
| 113 | do | 99 | do |
| 114 | do | 100 | local _with_0 = j |
| 115 | local _with_0 = j | 101 | print(_with_0:upper()) |
| 116 | print(_with_0:upper()) | ||
| 117 | end | ||
| 118 | end | 102 | end |
| 119 | do | 103 | do |
| 120 | do | 104 | local _with_0 = "jo" |
| 121 | local _with_0 = "jo" | 105 | k.j = _with_0 |
| 122 | k.j = _with_0 | 106 | print(_with_0:upper()) |
| 123 | print(_with_0:upper()) | ||
| 124 | end | ||
| 125 | end | 107 | end |
| 126 | do | 108 | do |
| 127 | do | 109 | local _with_0 = a |
| 128 | local _with_0 = a | 110 | print(_with_0.b) |
| 129 | print(_with_0.b) | 111 | local _with_1 = _with_0.c |
| 130 | do | 112 | print(_with_1.d) |
| 131 | local _with_1 = _with_0.c | ||
| 132 | print(_with_1.d) | ||
| 133 | end | ||
| 134 | end | ||
| 135 | end | 113 | end |
| 136 | do | 114 | do |
| 137 | do | 115 | local _with_0 = a |
| 138 | local _with_0 = a | 116 | local _with_1 = 2 |
| 139 | do | 117 | _with_0.b = _with_1 |
| 140 | local _with_1 = 2 | 118 | print(_with_1.c) |
| 141 | _with_0.b = _with_1 | ||
| 142 | print(_with_1.c) | ||
| 143 | end | ||
| 144 | end | ||
| 145 | end | 119 | end |
| 146 | do | 120 | do |
| 147 | local _ | 121 | local _ |
| @@ -151,43 +125,37 @@ do | |||
| 151 | end | 125 | end |
| 152 | end | 126 | end |
| 153 | do | 127 | do |
| 154 | do | 128 | local _with_0 = tb |
| 155 | local _with_0 = tb | 129 | _with_0.x = item.field:func(123) |
| 156 | _with_0.x = item.field:func(123) | ||
| 157 | end | ||
| 158 | end | 130 | end |
| 159 | do | 131 | do |
| 160 | do | 132 | local _with_0 = dad |
| 161 | local _with_0 = dad | 133 | _with_0["if"]("yes") |
| 162 | _with_0["if"]("yes") | 134 | local y = _with_0["end"].of["function"] |
| 163 | local y = _with_0["end"].of["function"] | ||
| 164 | end | ||
| 165 | end | 135 | end |
| 166 | do | 136 | do |
| 137 | local _with_0 = tb | ||
| 167 | do | 138 | do |
| 168 | local _with_0 = tb | 139 | local _obj_0 = _with_0[2] |
| 169 | do | 140 | if _obj_0 ~= nil then |
| 170 | local _obj_0 = _with_0[2] | 141 | _with_0[1] = _obj_0:func() |
| 171 | if _obj_0 ~= nil then | ||
| 172 | _with_0[1] = _obj_0:func() | ||
| 173 | end | ||
| 174 | end | ||
| 175 | _with_0["%a-b-c%"] = 123 | ||
| 176 | _with_0[ [[x y z]]] = _with_0[var] | ||
| 177 | print(_with_0[_with_0[3]]) | ||
| 178 | do | ||
| 179 | local _with_1 = _with_0[4] | ||
| 180 | _with_1[1] = 1 | ||
| 181 | end | 142 | end |
| 182 | _with_0[#_with_0 + 1] = "abc" | ||
| 183 | _with_0[#_with_0 + 1] = { | ||
| 184 | type = "hello", | ||
| 185 | { | ||
| 186 | name = "xyz", | ||
| 187 | value = 998 | ||
| 188 | } | ||
| 189 | } | ||
| 190 | end | 143 | end |
| 144 | _with_0["%a-b-c%"] = 123 | ||
| 145 | _with_0[ [[x y z]]] = _with_0[var] | ||
| 146 | print(_with_0[_with_0[3]]) | ||
| 147 | do | ||
| 148 | local _with_1 = _with_0[4] | ||
| 149 | _with_1[1] = 1 | ||
| 150 | end | ||
| 151 | _with_0[#_with_0 + 1] = "abc" | ||
| 152 | _with_0[#_with_0 + 1] = { | ||
| 153 | type = "hello", | ||
| 154 | { | ||
| 155 | name = "xyz", | ||
| 156 | value = 998 | ||
| 157 | } | ||
| 158 | } | ||
| 191 | end | 159 | end |
| 192 | do | 160 | do |
| 193 | do | 161 | do |
| @@ -204,16 +172,14 @@ do | |||
| 204 | end | 172 | end |
| 205 | end | 173 | end |
| 206 | do | 174 | do |
| 207 | do | 175 | local mask = SolidRect({ |
| 208 | local mask = SolidRect({ | 176 | width = w, |
| 209 | width = w, | 177 | height = h, |
| 210 | height = h, | 178 | color = 0x66000000 |
| 211 | color = 0x66000000 | 179 | }) |
| 212 | }) | 180 | if mask ~= nil then |
| 213 | if mask ~= nil then | 181 | mask.touchEnabled = true |
| 214 | mask.touchEnabled = true | 182 | mask.swallowTouches = true |
| 215 | mask.swallowTouches = true | ||
| 216 | end | ||
| 217 | end | 183 | end |
| 218 | end | 184 | end |
| 219 | return nil | 185 | return nil |
