diff options
author | Li Jin <dragon-fly@qq.com> | 2022-07-24 22:13:08 +0800 |
---|---|---|
committer | Li Jin <dragon-fly@qq.com> | 2022-07-24 22:13:08 +0800 |
commit | 303834e1b1e6cd9cae64b66c2ae44dcd7185238f (patch) | |
tree | 519f6a1debcc5791d35e06dc5cbb1ce22f9cfd31 /spec/outputs | |
parent | eb367126bf3a4f5b0e51ccef93b7c7136bea170e (diff) | |
download | yuescript-303834e1b1e6cd9cae64b66c2ae44dcd7185238f.tar.gz yuescript-303834e1b1e6cd9cae64b66c2ae44dcd7185238f.tar.bz2 yuescript-303834e1b1e6cd9cae64b66c2ae44dcd7185238f.zip |
add option --target=5.1 to generate Lua 5.1 compatible codes. add const destructure. make import item const by default.
Diffstat (limited to 'spec/outputs')
-rw-r--r-- | spec/outputs/destructure.lua | 25 | ||||
-rw-r--r-- | spec/outputs/export.lua | 10 | ||||
-rw-r--r-- | spec/outputs/import.lua | 2 | ||||
-rw-r--r-- | spec/outputs/macro.lua | 3 | ||||
-rw-r--r-- | spec/outputs/metatable.lua | 1 | ||||
-rw-r--r-- | spec/outputs/syntax.lua | 10 | ||||
-rw-r--r-- | spec/outputs/tables.lua | 8 | ||||
-rw-r--r-- | spec/outputs/with.lua | 2 |
8 files changed, 44 insertions, 17 deletions
diff --git a/spec/outputs/destructure.lua b/spec/outputs/destructure.lua index 2fe4ba9..59ee358 100644 --- a/spec/outputs/destructure.lua +++ b/spec/outputs/destructure.lua | |||
@@ -26,7 +26,7 @@ do | |||
26 | local _obj_0 = yeah | 26 | local _obj_0 = yeah |
27 | a, b, c, d = _obj_0.a, _obj_0.b, _obj_0.c, _obj_0.d | 27 | a, b, c, d = _obj_0.a, _obj_0.b, _obj_0.c, _obj_0.d |
28 | end | 28 | end |
29 | local _ = two | 29 | b = two |
30 | a = one[1] | 30 | a = one[1] |
31 | c = nil | 31 | c = nil |
32 | b = one[1] | 32 | b = one[1] |
@@ -56,7 +56,10 @@ do | |||
56 | end | 56 | end |
57 | do | 57 | do |
58 | a = tbl | 58 | a = tbl |
59 | b, c = _.b, _.c | 59 | do |
60 | local _obj_0 = _ | ||
61 | b, c = _obj_0.b, _obj_0.c | ||
62 | end | ||
60 | end | 63 | end |
61 | do | 64 | do |
62 | b = _ | 65 | b = _ |
@@ -386,3 +389,21 @@ do | |||
386 | a.c = _tmp_1 | 389 | a.c = _tmp_1 |
387 | end | 390 | end |
388 | end | 391 | end |
392 | do | ||
393 | local width, height | ||
394 | do | ||
395 | local _obj_0 = View.size | ||
396 | width, height = _obj_0.width, _obj_0.height | ||
397 | end | ||
398 | local x, y | ||
399 | do | ||
400 | local _obj_0 = point | ||
401 | x, y = _obj_0.x, _obj_0.y | ||
402 | if x == nil then | ||
403 | x = 0.0 | ||
404 | end | ||
405 | if y == nil then | ||
406 | y = 0.0 | ||
407 | end | ||
408 | end | ||
409 | end | ||
diff --git a/spec/outputs/export.lua b/spec/outputs/export.lua index 84e5424..962f18c 100644 --- a/spec/outputs/export.lua +++ b/spec/outputs/export.lua | |||
@@ -134,7 +134,10 @@ f((function() | |||
134 | local _accum_0 = { } | 134 | local _accum_0 = { } |
135 | local _len_0 = 1 | 135 | local _len_0 = 1 |
136 | for k, v in pairs(tb) do | 136 | for k, v in pairs(tb) do |
137 | _accum_0[_len_0] = k, v | 137 | _accum_0[_len_0] = { |
138 | k, | ||
139 | v | ||
140 | } | ||
138 | _len_0 = _len_0 + 1 | 141 | _len_0 = _len_0 + 1 |
139 | end | 142 | end |
140 | return _accum_0 | 143 | return _accum_0 |
@@ -232,7 +235,10 @@ _ = tostring((function() | |||
232 | local _accum_0 = { } | 235 | local _accum_0 = { } |
233 | local _len_0 = 1 | 236 | local _len_0 = 1 |
234 | for k, v in pairs(tb) do | 237 | for k, v in pairs(tb) do |
235 | _accum_0[_len_0] = k, v | 238 | _accum_0[_len_0] = { |
239 | k, | ||
240 | v | ||
241 | } | ||
236 | _len_0 = _len_0 + 1 | 242 | _len_0 = _len_0 + 1 |
237 | end | 243 | end |
238 | return _accum_0 | 244 | return _accum_0 |
diff --git a/spec/outputs/import.lua b/spec/outputs/import.lua index 65e703f..6979e47 100644 --- a/spec/outputs/import.lua +++ b/spec/outputs/import.lua | |||
@@ -94,7 +94,7 @@ do | |||
94 | b = getmetatable(require("m")).__a | 94 | b = getmetatable(require("m")).__a |
95 | local _obj_0 = require("m") | 95 | local _obj_0 = require("m") |
96 | local f = _obj_0.e | 96 | local f = _obj_0.e |
97 | b = getmetatable(_obj_0).__a | 97 | c = getmetatable(_obj_0).__a |
98 | local d = require("m").c | 98 | local d = require("m").c |
99 | local g, i | 99 | local g, i |
100 | do | 100 | do |
diff --git a/spec/outputs/macro.lua b/spec/outputs/macro.lua index c19b2d7..fbc1d48 100644 --- a/spec/outputs/macro.lua +++ b/spec/outputs/macro.lua | |||
@@ -282,7 +282,8 @@ print("current line: " .. tostring(268)); | |||
282 | do | 282 | do |
283 | print(1) | 283 | print(1) |
284 | end | 284 | end |
285 | _ = function() | 285 | local _1 |
286 | _1 = function() | ||
286 | print(1) | 287 | print(1) |
287 | local _accum_0 = { } | 288 | local _accum_0 = { } |
288 | local _len_0 = 1 | 289 | local _len_0 = 1 |
diff --git a/spec/outputs/metatable.lua b/spec/outputs/metatable.lua index 935202c..2d72e1d 100644 --- a/spec/outputs/metatable.lua +++ b/spec/outputs/metatable.lua | |||
@@ -65,7 +65,6 @@ end | |||
65 | setmetatable(a.b, { }) | 65 | setmetatable(a.b, { }) |
66 | x.abc = 123 | 66 | x.abc = 123 |
67 | setmetatable(func(), mt) | 67 | setmetatable(func(), mt) |
68 | local _ = extra | ||
69 | setmetatable(b.c, mt) | 68 | setmetatable(b.c, mt) |
70 | a, d, e = 1, "abc" | 69 | a, d, e = 1, "abc" |
71 | local is_same = getmetatable(a).__index == getmetatable(a).__index | 70 | local is_same = getmetatable(a).__index == getmetatable(a).__index |
diff --git a/spec/outputs/syntax.lua b/spec/outputs/syntax.lua index 24b78c6..a4cb8e2 100644 --- a/spec/outputs/syntax.lua +++ b/spec/outputs/syntax.lua | |||
@@ -56,10 +56,10 @@ something("else") | |||
56 | _ = something([[hey]]) * 2 | 56 | _ = something([[hey]]) * 2 |
57 | _ = something([======[hey]======]) * 2 | 57 | _ = something([======[hey]======]) * 2 |
58 | _ = something[ [======[hey]======]] * 2 | 58 | _ = something[ [======[hey]======]] * 2 |
59 | _ = something('else'), 2 | 59 | _, _ = something('else'), 2 |
60 | _ = something("else"), 2 | 60 | _, _ = something("else"), 2 |
61 | _ = something([[else]]), 2 | 61 | _, _ = something([[else]]), 2 |
62 | _ = something[ [[else]]], 2 | 62 | _, _ = something[ [[else]]], 2 |
63 | something('else', 2) | 63 | something('else', 2) |
64 | something("else", 2) | 64 | something("else", 2) |
65 | something([[else]], 2) | 65 | something([[else]], 2) |
@@ -165,7 +165,7 @@ x = #{ | |||
165 | 2 | 165 | 2 |
166 | } | 166 | } |
167 | } | 167 | } |
168 | _ = hello, world | 168 | _, _ = hello, world |
169 | something:hello(what)(a, b) | 169 | something:hello(what)(a, b) |
170 | something:hello(what) | 170 | something:hello(what) |
171 | something.hello:world(a, b) | 171 | something.hello:world(a, b) |
diff --git a/spec/outputs/tables.lua b/spec/outputs/tables.lua index 1d28a43..e9df1c4 100644 --- a/spec/outputs/tables.lua +++ b/spec/outputs/tables.lua | |||
@@ -187,18 +187,18 @@ k = { | |||
187 | ["hello"] = "world", | 187 | ["hello"] = "world", |
188 | ["one"] = "zone" | 188 | ["one"] = "zone" |
189 | } | 189 | } |
190 | local f = "one", { | 190 | local f1, f2, f3 = "one", { |
191 | ["two"] = three | 191 | ["two"] = three |
192 | }, "four" | 192 | }, "four" |
193 | f = { | 193 | f1, f2 = { |
194 | ["two"] = three | 194 | ["two"] = three |
195 | }, "four" | 195 | }, "four" |
196 | f = { | 196 | f1 = { |
197 | "one", | 197 | "one", |
198 | ["two"] = three, | 198 | ["two"] = three, |
199 | "four" | 199 | "four" |
200 | } | 200 | } |
201 | local j = "one", { | 201 | local j1, j2, j3, j4 = "one", { |
202 | ["two"] = three, | 202 | ["two"] = three, |
203 | ["four"] = five | 203 | ["four"] = five |
204 | }, 6, 7 | 204 | }, 6, 7 |
diff --git a/spec/outputs/with.lua b/spec/outputs/with.lua index 9dcaca3..304d26e 100644 --- a/spec/outputs/with.lua +++ b/spec/outputs/with.lua | |||
@@ -54,7 +54,7 @@ do | |||
54 | end | 54 | end |
55 | do | 55 | do |
56 | do | 56 | do |
57 | local _with_0 = a, b | 57 | local _with_0 = a |
58 | print(_with_0.world) | 58 | print(_with_0.world) |
59 | end | 59 | end |
60 | local mod | 60 | local mod |