rufus-lua-moon 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/vendor/lua/moon/init.moon +1 -1
- data/vendor/lua/moonscript/compile/statement.lua +26 -26
- data/vendor/lua/moonscript/compile/value.lua +24 -22
- data/vendor/lua/moonscript/compile.lua +165 -68
- data/vendor/lua/moonscript/data.lua +11 -6
- data/vendor/lua/moonscript/dump.lua +8 -3
- data/vendor/lua/moonscript/errors.lua +18 -6
- data/vendor/lua/moonscript/init.lua +37 -21
- data/vendor/lua/moonscript/line_tables.lua +1 -0
- data/vendor/lua/moonscript/parse.lua +34 -20
- data/vendor/lua/moonscript/transform/destructure.lua +234 -0
- data/vendor/lua/moonscript/transform/names.lua +144 -0
- data/vendor/lua/moonscript/transform.lua +230 -263
- data/vendor/lua/moonscript/types.lua +75 -31
- data/vendor/lua/moonscript/util.lua +102 -28
- data/vendor/lua/moonscript/version.lua +1 -1
- metadata +4 -2
- data/vendor/lua/moonscript/compile/format.lua +0 -49
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8f13af8210eb004073fdf11246d1356b14ba446d
|
4
|
+
data.tar.gz: 02f5ad9b840120561df6e3d32c1a3ca3cb260cfa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 36b11319d336fdd59eca5115a0b8dac529202e8fd6429e180ceda591de2ae0d7fecf0f92222a0906367b9f5467dcb161c99b740ec7a1f22c68745750987dcc75
|
7
|
+
data.tar.gz: 6cc4892809f47bd2c61ce32fc7c29159bd5af661da191c7fcf61ec046c551c6ed659eb2b7d03d5b4716154cfe5e32aef40caa66f80b3ec8e3179c3f95af83d25
|
data/vendor/lua/moon/init.moon
CHANGED
@@ -1,16 +1,13 @@
|
|
1
|
-
module("moonscript.compile", package.seeall)
|
2
1
|
local util = require("moonscript.util")
|
3
|
-
require("moonscript.
|
4
|
-
local
|
5
|
-
local transform = require("moonscript.transform")
|
6
|
-
local reversed = util.reversed
|
2
|
+
local data = require("moonscript.data")
|
3
|
+
local reversed, unpack = util.reversed, util.unpack
|
7
4
|
local ntype
|
8
5
|
do
|
9
6
|
local _table_0 = require("moonscript.types")
|
10
7
|
ntype = _table_0.ntype
|
11
8
|
end
|
12
9
|
local concat, insert = table.concat, table.insert
|
13
|
-
|
10
|
+
local statement_compilers = {
|
14
11
|
raw = function(self, node)
|
15
12
|
return self:add(node[2])
|
16
13
|
end,
|
@@ -29,12 +26,12 @@ line_compile = {
|
|
29
26
|
local _with_0 = self:line("local ")
|
30
27
|
_with_0:append_list((function()
|
31
28
|
local _accum_0 = { }
|
32
|
-
local _len_0 =
|
29
|
+
local _len_0 = 1
|
33
30
|
local _list_0 = undeclared
|
34
31
|
for _index_0 = 1, #_list_0 do
|
35
32
|
local name = _list_0[_index_0]
|
36
|
-
_len_0 = _len_0 + 1
|
37
33
|
_accum_0[_len_0] = self:name(name)
|
34
|
+
_len_0 = _len_0 + 1
|
38
35
|
end
|
39
36
|
return _accum_0
|
40
37
|
end)(), ", ")
|
@@ -49,12 +46,12 @@ line_compile = {
|
|
49
46
|
local _with_0 = self:line("local ")
|
50
47
|
_with_0:append_list((function()
|
51
48
|
local _accum_0 = { }
|
52
|
-
local _len_0 =
|
49
|
+
local _len_0 = 1
|
53
50
|
local _list_0 = names
|
54
51
|
for _index_0 = 1, #_list_0 do
|
55
52
|
local name = _list_0[_index_0]
|
56
|
-
_len_0 = _len_0 + 1
|
57
53
|
_accum_0[_len_0] = self:name(name)
|
54
|
+
_len_0 = _len_0 + 1
|
58
55
|
end
|
59
56
|
return _accum_0
|
60
57
|
end)(), ", ")
|
@@ -83,12 +80,12 @@ line_compile = {
|
|
83
80
|
end
|
84
81
|
_with_0:append_list((function()
|
85
82
|
local _accum_0 = { }
|
86
|
-
local _len_0 =
|
83
|
+
local _len_0 = 1
|
87
84
|
local _list_0 = names
|
88
85
|
for _index_0 = 1, #_list_0 do
|
89
86
|
local name = _list_0[_index_0]
|
90
|
-
_len_0 = _len_0 + 1
|
91
87
|
_accum_0[_len_0] = self:value(name)
|
88
|
+
_len_0 = _len_0 + 1
|
92
89
|
end
|
93
90
|
return _accum_0
|
94
91
|
end)(), ", ")
|
@@ -96,12 +93,12 @@ line_compile = {
|
|
96
93
|
_with_0:append(" = ")
|
97
94
|
_with_0:append_list((function()
|
98
95
|
local _accum_0 = { }
|
99
|
-
local _len_0 =
|
96
|
+
local _len_0 = 1
|
100
97
|
local _list_0 = values
|
101
98
|
for _index_0 = 1, #_list_0 do
|
102
99
|
local v = _list_0[_index_0]
|
103
|
-
_len_0 = _len_0 + 1
|
104
100
|
_accum_0[_len_0] = self:value(v)
|
101
|
+
_len_0 = _len_0 + 1
|
105
102
|
end
|
106
103
|
return _accum_0
|
107
104
|
end)(), ", ")
|
@@ -186,34 +183,34 @@ line_compile = {
|
|
186
183
|
do
|
187
184
|
local _with_0 = self:line()
|
188
185
|
_with_0:append("for ")
|
189
|
-
_with_0
|
186
|
+
loop = _with_0
|
187
|
+
end
|
188
|
+
do
|
189
|
+
local _with_0 = self:block(loop)
|
190
|
+
loop:append_list((function()
|
190
191
|
local _accum_0 = { }
|
191
|
-
local _len_0 =
|
192
|
+
local _len_0 = 1
|
192
193
|
local _list_0 = names
|
193
194
|
for _index_0 = 1, #_list_0 do
|
194
195
|
local name = _list_0[_index_0]
|
196
|
+
_accum_0[_len_0] = _with_0:name(name, false)
|
195
197
|
_len_0 = _len_0 + 1
|
196
|
-
_accum_0[_len_0] = self:name(name)
|
197
198
|
end
|
198
199
|
return _accum_0
|
199
200
|
end)(), ", ")
|
200
|
-
|
201
|
-
|
201
|
+
loop:append(" in ")
|
202
|
+
loop:append_list((function()
|
202
203
|
local _accum_0 = { }
|
203
|
-
local _len_0 =
|
204
|
+
local _len_0 = 1
|
204
205
|
local _list_0 = exps
|
205
206
|
for _index_0 = 1, #_list_0 do
|
206
207
|
local exp = _list_0[_index_0]
|
207
|
-
_len_0 = _len_0 + 1
|
208
208
|
_accum_0[_len_0] = self:value(exp)
|
209
|
+
_len_0 = _len_0 + 1
|
209
210
|
end
|
210
211
|
return _accum_0
|
211
212
|
end)(), ",")
|
212
|
-
|
213
|
-
loop = _with_0
|
214
|
-
end
|
215
|
-
do
|
216
|
-
local _with_0 = self:block(loop)
|
213
|
+
loop:append(" do")
|
217
214
|
_with_0:declare(names)
|
218
215
|
_with_0:stms(block)
|
219
216
|
return _with_0
|
@@ -247,3 +244,6 @@ line_compile = {
|
|
247
244
|
end
|
248
245
|
end
|
249
246
|
}
|
247
|
+
return {
|
248
|
+
statement_compilers = statement_compilers
|
249
|
+
}
|
@@ -1,15 +1,19 @@
|
|
1
|
-
module("moonscript.compile", package.seeall)
|
2
1
|
local util = require("moonscript.util")
|
3
2
|
local data = require("moonscript.data")
|
4
|
-
require("moonscript.compile.format")
|
5
3
|
local ntype
|
6
4
|
do
|
7
5
|
local _table_0 = require("moonscript.types")
|
8
6
|
ntype = _table_0.ntype
|
9
7
|
end
|
8
|
+
local user_error
|
9
|
+
do
|
10
|
+
local _table_0 = require("moonscript.errors")
|
11
|
+
user_error = _table_0.user_error
|
12
|
+
end
|
10
13
|
local concat, insert = table.concat, table.insert
|
14
|
+
local unpack = util.unpack
|
11
15
|
local table_delim = ","
|
12
|
-
|
16
|
+
local value_compilers = {
|
13
17
|
exp = function(self, node)
|
14
18
|
local _comp
|
15
19
|
_comp = function(i, value)
|
@@ -22,11 +26,11 @@ value_compile = {
|
|
22
26
|
local _with_0 = self:line()
|
23
27
|
_with_0:append_list((function()
|
24
28
|
local _accum_0 = { }
|
25
|
-
local _len_0 =
|
29
|
+
local _len_0 = 1
|
26
30
|
for i, v in ipairs(node) do
|
27
31
|
if i > 1 then
|
28
|
-
_len_0 = _len_0 + 1
|
29
32
|
_accum_0[_len_0] = _comp(i, v)
|
33
|
+
_len_0 = _len_0 + 1
|
30
34
|
end
|
31
35
|
end
|
32
36
|
return _accum_0
|
@@ -39,12 +43,12 @@ value_compile = {
|
|
39
43
|
local _with_0 = self:line()
|
40
44
|
_with_0:append_list((function()
|
41
45
|
local _accum_0 = { }
|
42
|
-
local _len_0 =
|
46
|
+
local _len_0 = 1
|
43
47
|
local _list_0 = node
|
44
48
|
for _index_0 = 2, #_list_0 do
|
45
49
|
local v = _list_0[_index_0]
|
46
|
-
_len_0 = _len_0 + 1
|
47
50
|
_accum_0[_len_0] = self:value(v)
|
51
|
+
_len_0 = _len_0 + 1
|
48
52
|
end
|
49
53
|
return _accum_0
|
50
54
|
end)(), ", ")
|
@@ -114,7 +118,7 @@ value_compile = {
|
|
114
118
|
local self_args = { }
|
115
119
|
local arg_names = (function()
|
116
120
|
local _accum_0 = { }
|
117
|
-
local _len_0 =
|
121
|
+
local _len_0 = 1
|
118
122
|
local _list_0 = args
|
119
123
|
for _index_0 = 1, #_list_0 do
|
120
124
|
local arg = _list_0[_index_0]
|
@@ -131,10 +135,8 @@ value_compile = {
|
|
131
135
|
insert(default_args, arg)
|
132
136
|
end
|
133
137
|
local _value_0 = name
|
134
|
-
|
135
|
-
|
136
|
-
_accum_0[_len_0] = _value_0
|
137
|
-
end
|
138
|
+
_accum_0[_len_0] = _value_0
|
139
|
+
_len_0 = _len_0 + 1
|
138
140
|
end
|
139
141
|
return _accum_0
|
140
142
|
end)()
|
@@ -181,12 +183,12 @@ value_compile = {
|
|
181
183
|
end
|
182
184
|
local self_arg_values = (function()
|
183
185
|
local _accum_0 = { }
|
184
|
-
local _len_0 =
|
186
|
+
local _len_0 = 1
|
185
187
|
local _list_2 = self_args
|
186
188
|
for _index_0 = 1, #_list_2 do
|
187
189
|
local arg = _list_2[_index_0]
|
188
|
-
_len_0 = _len_0 + 1
|
189
190
|
_accum_0[_len_0] = arg[2]
|
191
|
+
_len_0 = _len_0 + 1
|
190
192
|
end
|
191
193
|
return _accum_0
|
192
194
|
end)()
|
@@ -201,15 +203,12 @@ value_compile = {
|
|
201
203
|
if #args > #arg_names then
|
202
204
|
arg_names = (function()
|
203
205
|
local _accum_0 = { }
|
204
|
-
local _len_0 =
|
206
|
+
local _len_0 = 1
|
205
207
|
local _list_2 = args
|
206
208
|
for _index_0 = 1, #_list_2 do
|
207
209
|
local arg = _list_2[_index_0]
|
208
|
-
|
209
|
-
|
210
|
-
_len_0 = _len_0 + 1
|
211
|
-
_accum_0[_len_0] = _value_0
|
212
|
-
end
|
210
|
+
_accum_0[_len_0] = arg[1]
|
211
|
+
_len_0 = _len_0 + 1
|
213
212
|
end
|
214
213
|
return _accum_0
|
215
214
|
end)()
|
@@ -263,8 +262,8 @@ value_compile = {
|
|
263
262
|
minus = function(self, node)
|
264
263
|
return self:line("-", self:value(node[2]))
|
265
264
|
end,
|
266
|
-
temp_name = function(self, node)
|
267
|
-
return node:get_name(self)
|
265
|
+
temp_name = function(self, node, ...)
|
266
|
+
return node:get_name(self, ...)
|
268
267
|
end,
|
269
268
|
number = function(self, node)
|
270
269
|
return node[2]
|
@@ -298,3 +297,6 @@ value_compile = {
|
|
298
297
|
return tostring(value)
|
299
298
|
end
|
300
299
|
}
|
300
|
+
return {
|
301
|
+
value_compilers = value_compilers
|
302
|
+
}
|
@@ -1,25 +1,36 @@
|
|
1
|
-
module("moonscript.compile", package.seeall)
|
2
1
|
local util = require("moonscript.util")
|
3
2
|
local dump = require("moonscript.dump")
|
4
|
-
require("moonscript.compile.format")
|
5
|
-
require("moonscript.compile.statement")
|
6
|
-
require("moonscript.compile.value")
|
7
3
|
local transform = require("moonscript.transform")
|
8
|
-
local NameProxy, LocalName
|
4
|
+
local NameProxy, LocalName
|
5
|
+
do
|
6
|
+
local _table_0 = require("moonscript.transform.names")
|
7
|
+
NameProxy, LocalName = _table_0.NameProxy, _table_0.LocalName
|
8
|
+
end
|
9
9
|
local Set
|
10
10
|
do
|
11
11
|
local _table_0 = require("moonscript.data")
|
12
12
|
Set = _table_0.Set
|
13
13
|
end
|
14
|
-
local ntype
|
14
|
+
local ntype, has_value
|
15
15
|
do
|
16
16
|
local _table_0 = require("moonscript.types")
|
17
|
-
ntype = _table_0.ntype
|
17
|
+
ntype, has_value = _table_0.ntype, _table_0.has_value
|
18
|
+
end
|
19
|
+
local statement_compilers
|
20
|
+
do
|
21
|
+
local _table_0 = require("moonscript.compile.statement")
|
22
|
+
statement_compilers = _table_0.statement_compilers
|
23
|
+
end
|
24
|
+
local value_compilers
|
25
|
+
do
|
26
|
+
local _table_0 = require("moonscript.compile.value")
|
27
|
+
value_compilers = _table_0.value_compilers
|
18
28
|
end
|
19
29
|
local concat, insert = table.concat, table.insert
|
20
|
-
local pos_to_line, get_closest_line, trim = util.pos_to_line, util.get_closest_line, util.trim
|
30
|
+
local pos_to_line, get_closest_line, trim, unpack = util.pos_to_line, util.get_closest_line, util.trim, util.unpack
|
21
31
|
local mtype = util.moon.type
|
22
|
-
local
|
32
|
+
local indent_char = " "
|
33
|
+
local Line, DelayedLine, Lines, Block, RootBlock
|
23
34
|
do
|
24
35
|
local _parent_0 = nil
|
25
36
|
local _base_0 = {
|
@@ -51,13 +62,15 @@ do
|
|
51
62
|
end
|
52
63
|
local posmap = self.posmap
|
53
64
|
for i, l in ipairs(self) do
|
54
|
-
local _exp_0 =
|
55
|
-
if "
|
56
|
-
local _
|
57
|
-
_, line_no = l:flatten_posmap(line_no, out)
|
58
|
-
elseif "string" == _exp_0 then
|
65
|
+
local _exp_0 = mtype(l)
|
66
|
+
if "string" == _exp_0 or DelayedLine == _exp_0 then
|
59
67
|
line_no = line_no + 1
|
60
68
|
out[line_no] = posmap[i]
|
69
|
+
elseif Lines == _exp_0 then
|
70
|
+
local _
|
71
|
+
_, line_no = l:flatten_posmap(line_no, out)
|
72
|
+
else
|
73
|
+
error("Unknown item in Lines: " .. tostring(l))
|
61
74
|
end
|
62
75
|
end
|
63
76
|
return out, line_no
|
@@ -71,7 +84,12 @@ do
|
|
71
84
|
end
|
72
85
|
for i = 1, #self do
|
73
86
|
local l = self[i]
|
74
|
-
local
|
87
|
+
local t = mtype(l)
|
88
|
+
if t == DelayedLine then
|
89
|
+
l = l:render()
|
90
|
+
t = "string"
|
91
|
+
end
|
92
|
+
local _exp_0 = t
|
75
93
|
if "string" == _exp_0 then
|
76
94
|
if indent then
|
77
95
|
insert(buffer, indent)
|
@@ -85,8 +103,10 @@ do
|
|
85
103
|
end
|
86
104
|
insert(buffer, "\n")
|
87
105
|
local last = l
|
88
|
-
elseif
|
106
|
+
elseif Lines == _exp_0 then
|
89
107
|
l:flatten(indent and indent .. indent_char or indent_char, buffer)
|
108
|
+
else
|
109
|
+
error("Unknown item in Lines: " .. tostring(l))
|
90
110
|
end
|
91
111
|
end
|
92
112
|
return buffer
|
@@ -97,12 +117,12 @@ do
|
|
97
117
|
if "table" == type(t) then
|
98
118
|
return (function()
|
99
119
|
local _accum_0 = { }
|
100
|
-
local _len_0 =
|
120
|
+
local _len_0 = 1
|
101
121
|
local _list_0 = t
|
102
122
|
for _index_0 = 1, #_list_0 do
|
103
123
|
local v = _list_0[_index_0]
|
104
|
-
_len_0 = _len_0 + 1
|
105
124
|
_accum_0[_len_0] = strip(v)
|
125
|
+
_len_0 = _len_0 + 1
|
106
126
|
end
|
107
127
|
return _accum_0
|
108
128
|
end)()
|
@@ -156,7 +176,7 @@ do
|
|
156
176
|
end
|
157
177
|
local _list_0 = item
|
158
178
|
for _index_0 = 1, #_list_0 do
|
159
|
-
value = _list_0[_index_0]
|
179
|
+
local value = _list_0[_index_0]
|
160
180
|
self:_append_single(value)
|
161
181
|
end
|
162
182
|
else
|
@@ -253,6 +273,47 @@ do
|
|
253
273
|
end
|
254
274
|
Line = _class_0
|
255
275
|
end
|
276
|
+
do
|
277
|
+
local _parent_0 = nil
|
278
|
+
local _base_0 = {
|
279
|
+
prepare = function() end,
|
280
|
+
render = function(self)
|
281
|
+
self:prepare()
|
282
|
+
return concat(self)
|
283
|
+
end
|
284
|
+
}
|
285
|
+
_base_0.__index = _base_0
|
286
|
+
if _parent_0 then
|
287
|
+
setmetatable(_base_0, _parent_0.__base)
|
288
|
+
end
|
289
|
+
local _class_0 = setmetatable({
|
290
|
+
__init = function(self, fn)
|
291
|
+
self.prepare = fn
|
292
|
+
end,
|
293
|
+
__base = _base_0,
|
294
|
+
__name = "DelayedLine",
|
295
|
+
__parent = _parent_0
|
296
|
+
}, {
|
297
|
+
__index = function(cls, name)
|
298
|
+
local val = rawget(_base_0, name)
|
299
|
+
if val == nil and _parent_0 then
|
300
|
+
return _parent_0[name]
|
301
|
+
else
|
302
|
+
return val
|
303
|
+
end
|
304
|
+
end,
|
305
|
+
__call = function(cls, ...)
|
306
|
+
local _self_0 = setmetatable({}, _base_0)
|
307
|
+
cls.__init(_self_0, ...)
|
308
|
+
return _self_0
|
309
|
+
end
|
310
|
+
})
|
311
|
+
_base_0.__class = _class_0
|
312
|
+
if _parent_0 and _parent_0.__inherited then
|
313
|
+
_parent_0.__inherited(_parent_0, _class_0)
|
314
|
+
end
|
315
|
+
DelayedLine = _class_0
|
316
|
+
end
|
256
317
|
do
|
257
318
|
local _parent_0 = nil
|
258
319
|
local _base_0 = {
|
@@ -275,6 +336,9 @@ do
|
|
275
336
|
get = function(self, name)
|
276
337
|
return self._state[name]
|
277
338
|
end,
|
339
|
+
get_current = function(self, name)
|
340
|
+
return rawget(self._state, name)
|
341
|
+
end,
|
278
342
|
listen = function(self, name, fn)
|
279
343
|
self._listeners[name] = fn
|
280
344
|
end,
|
@@ -292,44 +356,58 @@ do
|
|
292
356
|
declare = function(self, names)
|
293
357
|
local undeclared = (function()
|
294
358
|
local _accum_0 = { }
|
295
|
-
local _len_0 =
|
359
|
+
local _len_0 = 1
|
296
360
|
local _list_0 = names
|
297
361
|
for _index_0 = 1, #_list_0 do
|
298
|
-
local
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
362
|
+
local _continue_0 = false
|
363
|
+
repeat
|
364
|
+
local name = _list_0[_index_0]
|
365
|
+
local is_local = false
|
366
|
+
local real_name
|
367
|
+
local _exp_0 = mtype(name)
|
368
|
+
if LocalName == _exp_0 then
|
369
|
+
is_local = true
|
370
|
+
real_name = name:get_name(self)
|
371
|
+
elseif NameProxy == _exp_0 then
|
372
|
+
real_name = name:get_name(self)
|
373
|
+
elseif "string" == _exp_0 then
|
374
|
+
real_name = name
|
375
|
+
end
|
376
|
+
if not (is_local or real_name and not self:has_name(real_name, true)) then
|
377
|
+
_continue_0 = true
|
378
|
+
break
|
379
|
+
end
|
380
|
+
self:put_name(real_name)
|
381
|
+
if self:name_exported(real_name) then
|
382
|
+
_continue_0 = true
|
383
|
+
break
|
384
|
+
end
|
385
|
+
local _value_0 = real_name
|
316
386
|
_accum_0[_len_0] = _value_0
|
387
|
+
_len_0 = _len_0 + 1
|
388
|
+
_continue_0 = true
|
389
|
+
until true
|
390
|
+
if not _continue_0 then
|
391
|
+
break
|
317
392
|
end
|
318
393
|
end
|
319
394
|
return _accum_0
|
320
395
|
end)()
|
321
|
-
local _list_0 = undeclared
|
322
|
-
for _index_0 = 1, #_list_0 do
|
323
|
-
local name = _list_0[_index_0]
|
324
|
-
self:put_name(name)
|
325
|
-
end
|
326
396
|
return undeclared
|
327
397
|
end,
|
328
398
|
whitelist_names = function(self, names)
|
329
399
|
self._name_whitelist = Set(names)
|
330
400
|
end,
|
401
|
+
name_exported = function(self, name)
|
402
|
+
if self.export_all then
|
403
|
+
return true
|
404
|
+
end
|
405
|
+
if self.export_proper and name:match("^%u") then
|
406
|
+
return true
|
407
|
+
end
|
408
|
+
end,
|
331
409
|
put_name = function(self, name, ...)
|
332
|
-
value = ...
|
410
|
+
local value = ...
|
333
411
|
if select("#", ...) == 0 then
|
334
412
|
value = true
|
335
413
|
end
|
@@ -339,13 +417,8 @@ do
|
|
339
417
|
self._names[name] = value
|
340
418
|
end,
|
341
419
|
has_name = function(self, name, skip_exports)
|
342
|
-
if not skip_exports then
|
343
|
-
|
344
|
-
return true
|
345
|
-
end
|
346
|
-
if self.export_proper and name:match("^[A-Z]") then
|
347
|
-
return true
|
348
|
-
end
|
420
|
+
if not skip_exports and self:name_exported(name) then
|
421
|
+
return true
|
349
422
|
end
|
350
423
|
local yes = self._names[name]
|
351
424
|
if yes == nil and self.parent then
|
@@ -419,14 +492,14 @@ do
|
|
419
492
|
end
|
420
493
|
end,
|
421
494
|
is_stm = function(self, node)
|
422
|
-
return
|
495
|
+
return statement_compilers[ntype(node)] ~= nil
|
423
496
|
end,
|
424
497
|
is_value = function(self, node)
|
425
498
|
local t = ntype(node)
|
426
|
-
return
|
499
|
+
return value_compilers[t] ~= nil or t == "value"
|
427
500
|
end,
|
428
|
-
name = function(self, node)
|
429
|
-
return self:value(node)
|
501
|
+
name = function(self, node, ...)
|
502
|
+
return self:value(node, ...)
|
430
503
|
end,
|
431
504
|
value = function(self, node, ...)
|
432
505
|
node = self.transform.value(node)
|
@@ -436,7 +509,7 @@ do
|
|
436
509
|
else
|
437
510
|
action = node[1]
|
438
511
|
end
|
439
|
-
local fn =
|
512
|
+
local fn = value_compilers[action]
|
440
513
|
if not fn then
|
441
514
|
error("Failed to compile value: " .. dump.value(node))
|
442
515
|
end
|
@@ -459,12 +532,12 @@ do
|
|
459
532
|
local _with_0 = Line()
|
460
533
|
_with_0:append_list((function()
|
461
534
|
local _accum_0 = { }
|
462
|
-
local _len_0 =
|
535
|
+
local _len_0 = 1
|
463
536
|
local _list_0 = values
|
464
537
|
for _index_0 = 1, #_list_0 do
|
465
538
|
local v = _list_0[_index_0]
|
466
|
-
_len_0 = _len_0 + 1
|
467
539
|
_accum_0[_len_0] = self:value(v)
|
540
|
+
_len_0 = _len_0 + 1
|
468
541
|
end
|
469
542
|
return _accum_0
|
470
543
|
end)(), delim)
|
@@ -478,7 +551,7 @@ do
|
|
478
551
|
node = self.transform.statement(node)
|
479
552
|
local result
|
480
553
|
do
|
481
|
-
local fn =
|
554
|
+
local fn = statement_compilers[ntype(node)]
|
482
555
|
if fn then
|
483
556
|
result = fn(self, node, ...)
|
484
557
|
else
|
@@ -509,11 +582,18 @@ do
|
|
509
582
|
if ret then
|
510
583
|
error("deprecated stms call, use transformer")
|
511
584
|
end
|
512
|
-
local
|
513
|
-
|
514
|
-
local
|
515
|
-
|
585
|
+
local current_stms, current_stm_i
|
586
|
+
do
|
587
|
+
local _obj_0 = self
|
588
|
+
current_stms, current_stm_i = _obj_0.current_stms, _obj_0.current_stm_i
|
516
589
|
end
|
590
|
+
self.current_stms = stms
|
591
|
+
for i = 1, #stms do
|
592
|
+
self.current_stm_i = i
|
593
|
+
self:stm(stms[i])
|
594
|
+
end
|
595
|
+
self.current_stms = current_stms
|
596
|
+
self.current_stm_i = current_stm_i
|
517
597
|
return nil
|
518
598
|
end,
|
519
599
|
splice = function(self, fn)
|
@@ -590,11 +670,7 @@ do
|
|
590
670
|
if not (self.options.implicitly_return_root == false) then
|
591
671
|
stms = transform.Statement.transformers.root_stms(self, stms)
|
592
672
|
end
|
593
|
-
|
594
|
-
for _index_0 = 1, #_list_0 do
|
595
|
-
local s = _list_0[_index_0]
|
596
|
-
self:stm(s)
|
597
|
-
end
|
673
|
+
return self:stms(stms)
|
598
674
|
end,
|
599
675
|
render = function(self)
|
600
676
|
local buffer = self._lines:flatten()
|
@@ -638,6 +714,7 @@ do
|
|
638
714
|
end
|
639
715
|
RootBlock = _class_0
|
640
716
|
end
|
717
|
+
local format_error
|
641
718
|
format_error = function(msg, pos, file_str)
|
642
719
|
local line = pos_to_line(file_str, pos)
|
643
720
|
local line_str
|
@@ -648,6 +725,7 @@ format_error = function(msg, pos, file_str)
|
|
648
725
|
(" [%d] >> %s"):format(line, trim(line_str))
|
649
726
|
}, "\n")
|
650
727
|
end
|
728
|
+
local value
|
651
729
|
value = function(value)
|
652
730
|
local out = nil
|
653
731
|
do
|
@@ -657,6 +735,7 @@ value = function(value)
|
|
657
735
|
end
|
658
736
|
return out
|
659
737
|
end
|
738
|
+
local tree
|
660
739
|
tree = function(tree, options)
|
661
740
|
if options == nil then
|
662
741
|
options = { }
|
@@ -689,3 +768,21 @@ tree = function(tree, options)
|
|
689
768
|
return lua_code, posmap
|
690
769
|
end
|
691
770
|
end
|
771
|
+
do
|
772
|
+
local _with_0 = require("moonscript.data")
|
773
|
+
local data = _with_0
|
774
|
+
for name, cls in pairs({
|
775
|
+
Line = Line,
|
776
|
+
Lines = Lines,
|
777
|
+
DelayedLine = DelayedLine
|
778
|
+
}) do
|
779
|
+
data[name] = cls
|
780
|
+
end
|
781
|
+
end
|
782
|
+
return {
|
783
|
+
tree = tree,
|
784
|
+
value = value,
|
785
|
+
format_error = format_error,
|
786
|
+
Block = Block,
|
787
|
+
RootBlock = RootBlock
|
788
|
+
}
|