Skip to content

Commit 0848c1e

Browse files
committed
rebuild this sucker 😤
1 parent 642932c commit 0848c1e

File tree

8 files changed

+107
-79
lines changed

8 files changed

+107
-79
lines changed

moonscript/compile.lua

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,8 @@ do
306306
end
307307
end,
308308
declare = function(self, names)
309-
local undeclared = (function()
309+
local undeclared
310+
do
310311
local _accum_0 = { }
311312
local _len_0 = 1
312313
for _index_0 = 1, #names do
@@ -342,8 +343,8 @@ do
342343
break
343344
end
344345
end
345-
return _accum_0
346-
end)()
346+
undeclared = _accum_0
347+
end
347348
return undeclared
348349
end,
349350
whitelist_names = function(self, names)

moonscript/compile/value.lua

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ local value_compilers = {
5151
do
5252
local _with_0 = self:line()
5353
_with_0:append_list((function()
54-
local _list_0 = node
5554
local _accum_0 = { }
5655
local _len_0 = 1
56+
local _list_0 = node
5757
for _index_0 = 2, #_list_0 do
5858
local v = _list_0[_index_0]
5959
_accum_0[_len_0] = self:value(v)
@@ -128,7 +128,8 @@ local value_compilers = {
128128
local _, args, whitelist, arrow, block = unpack(node)
129129
local default_args = { }
130130
local self_args = { }
131-
local arg_names = (function()
131+
local arg_names
132+
do
132133
local _accum_0 = { }
133134
local _len_0 = 1
134135
for _index_0 = 1, #args do
@@ -149,8 +150,8 @@ local value_compilers = {
149150
_accum_0[_len_0] = _value_0
150151
_len_0 = _len_0 + 1
151152
end
152-
return _accum_0
153-
end)()
153+
arg_names = _accum_0
154+
end
154155
if arrow == "fat" then
155156
insert(arg_names, 1, "self")
156157
end
@@ -190,12 +191,16 @@ local value_compilers = {
190191
}
191192
})
192193
end
193-
local self_arg_values = { }
194-
local _len_0 = 1
195-
for _index_0 = 1, #self_args do
196-
local arg = self_args[_index_0]
197-
self_arg_values[_len_0] = arg[2]
198-
_len_0 = _len_0 + 1
194+
local self_arg_values
195+
do
196+
local _accum_0 = { }
197+
local _len_0 = 1
198+
for _index_0 = 1, #self_args do
199+
local arg = self_args[_index_0]
200+
_accum_0[_len_0] = arg[2]
201+
_len_0 = _len_0 + 1
202+
end
203+
self_arg_values = _accum_0
199204
end
200205
if #self_args > 0 then
201206
_with_0:stm({
@@ -206,12 +211,15 @@ local value_compilers = {
206211
end
207212
_with_0:stms(block)
208213
if #args > #arg_names then
209-
arg_names = { }
210-
local _len_1 = 1
211-
for _index_0 = 1, #args do
212-
local arg = args[_index_0]
213-
arg_names[_len_1] = arg[1]
214-
_len_1 = _len_1 + 1
214+
do
215+
local _accum_0 = { }
216+
local _len_0 = 1
217+
for _index_0 = 1, #args do
218+
local arg = args[_index_0]
219+
_accum_0[_len_0] = arg[1]
220+
_len_0 = _len_0 + 1
221+
end
222+
arg_names = _accum_0
215223
end
216224
end
217225
_with_0.header = "function(" .. concat(arg_names, ", ") .. ")"

moonscript/dump.lua

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,16 @@ flat_value = function(op, depth)
99
if type(op) ~= "table" then
1010
return tostring(op)
1111
end
12-
local items = { }
13-
local _len_0 = 1
14-
for _index_0 = 1, #op do
15-
local item = op[_index_0]
16-
items[_len_0] = flat_value(item, depth + 1)
17-
_len_0 = _len_0 + 1
12+
local items
13+
do
14+
local _accum_0 = { }
15+
local _len_0 = 1
16+
for _index_0 = 1, #op do
17+
local item = op[_index_0]
18+
_accum_0[_len_0] = flat_value(item, depth + 1)
19+
_len_0 = _len_0 + 1
20+
end
21+
items = _accum_0
1822
end
1923
local pos = op[-1]
2024
return "{" .. (pos and "[" .. pos .. "] " or "") .. table.concat(items, ", ") .. "}"

moonscript/errors.lua

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,17 @@ truncate_traceback = function(traceback, chunk_func)
4747
end
4848
stop = stop - 1
4949
end
50-
local _list_0 = traceback
51-
traceback = { }
52-
local _len_0 = 1
53-
local _max_0 = stop
54-
for _index_0 = 1, _max_0 < 0 and #_list_0 + _max_0 or _max_0 do
55-
local t = _list_0[_index_0]
56-
traceback[_len_0] = t
57-
_len_0 = _len_0 + 1
50+
do
51+
local _accum_0 = { }
52+
local _len_0 = 1
53+
local _list_0 = traceback
54+
local _max_0 = stop
55+
for _index_0 = 1, _max_0 < 0 and #_list_0 + _max_0 or _max_0 do
56+
local t = _list_0[_index_0]
57+
_accum_0[_len_0] = t
58+
_len_0 = _len_0 + 1
59+
end
60+
traceback = _accum_0
5861
end
5962
local rep = "function '" .. chunk_func .. "'"
6063
traceback[#traceback] = traceback[#traceback]:gsub(rep, "main chunk")

moonscript/transform.lua

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ Statement = Transformer({
317317
declare_glob = function(self, node)
318318
local names = extract_declarations(self)
319319
if node[2] == "^" then
320-
names = (function()
320+
do
321321
local _accum_0 = { }
322322
local _len_0 = 1
323323
for _index_0 = 1, #names do
@@ -337,8 +337,8 @@ Statement = Transformer({
337337
break
338338
end
339339
end
340-
return _accum_0
341-
end)()
340+
names = _accum_0
341+
end
342342
end
343343
return {
344344
"declare",
@@ -470,7 +470,8 @@ Statement = Transformer({
470470
end,
471471
import = function(self, node)
472472
local _, names, source = unpack(node)
473-
local table_values = (function()
473+
local table_values
474+
do
474475
local _accum_0 = { }
475476
local _len_0 = 1
476477
for _index_0 = 1, #names do
@@ -491,8 +492,8 @@ Statement = Transformer({
491492
_accum_0[_len_0] = _value_0
492493
_len_0 = _len_0 + 1
493494
end
494-
return _accum_0
495-
end)()
495+
table_values = _accum_0
496+
end
496497
local dest = {
497498
"table",
498499
table_values
@@ -566,9 +567,9 @@ Statement = Transformer({
566567
wrapped = build.group({
567568
build.declare({
568569
names = (function()
569-
local _list_0 = stm[2]
570570
local _accum_0 = { }
571571
local _len_0 = 1
572+
local _list_0 = stm[2]
572573
for _index_0 = 1, #_list_0 do
573574
local name = _list_0[_index_0]
574575
if type(name) == "string" then
@@ -684,7 +685,7 @@ Statement = Transformer({
684685
smart_node(node)
685686
local source = unpack(node.iter)
686687
local destructures = { }
687-
node.names = (function()
688+
do
688689
local _accum_0 = { }
689690
local _len_0 = 1
690691
for i, name in ipairs(node.names) do
@@ -699,8 +700,8 @@ Statement = Transformer({
699700
end
700701
_len_0 = _len_0 + 1
701702
end
702-
return _accum_0
703-
end)()
703+
node.names = _accum_0
704+
end
704705
if next(destructures) then
705706
insert(destructures, build.group(node.body))
706707
node.body = destructures
@@ -862,7 +863,7 @@ Statement = Transformer({
862863
end
863864
end
864865
local constructor
865-
properties = (function()
866+
do
866867
local _accum_0 = { }
867868
local _len_0 = 1
868869
for _index_0 = 1, #properties do
@@ -886,8 +887,8 @@ Statement = Transformer({
886887
break
887888
end
888889
end
889-
return _accum_0
890-
end)()
890+
properties = _accum_0
891+
end
891892
local parent_cls_name = NameProxy("parent")
892893
local base_name = NameProxy("base")
893894
local self_name = NameProxy("self")
@@ -1066,13 +1067,17 @@ Statement = Transformer({
10661067
end
10671068
return self:set("super", function(block, chain)
10681069
if chain then
1069-
local _list_0 = chain
1070-
local slice = { }
1071-
local _len_0 = 1
1072-
for _index_0 = 3, #_list_0 do
1073-
local item = _list_0[_index_0]
1074-
slice[_len_0] = item
1075-
_len_0 = _len_0 + 1
1070+
local slice
1071+
do
1072+
local _accum_0 = { }
1073+
local _len_0 = 1
1074+
local _list_0 = chain
1075+
for _index_0 = 3, #_list_0 do
1076+
local item = _list_0[_index_0]
1077+
_accum_0[_len_0] = item
1078+
_len_0 = _len_0 + 1
1079+
end
1080+
slice = _accum_0
10761081
end
10771082
local new_chain = {
10781083
"chain",

moonscript/transform/destructure.lua

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -198,31 +198,31 @@ split_assign = function(scope, assign)
198198
"_"
199199
}
200200
else
201-
name_slice = (function()
201+
do
202202
local _accum_0 = { }
203203
local _len_0 = 1
204204
for i = start, total_names do
205205
_accum_0[_len_0] = names[i]
206206
_len_0 = _len_0 + 1
207207
end
208-
return _accum_0
209-
end)()
208+
name_slice = _accum_0
209+
end
210210
end
211211
local value_slice
212212
if total_values < start then
213213
value_slice = {
214214
"nil"
215215
}
216216
else
217-
value_slice = (function()
217+
do
218218
local _accum_0 = { }
219219
local _len_0 = 1
220220
for i = start, total_values do
221221
_accum_0[_len_0] = values[i]
222222
_len_0 = _len_0 + 1
223223
end
224-
return _accum_0
225-
end)()
224+
value_slice = _accum_0
225+
end
226226
end
227227
insert(g, {
228228
"assign",

moonscript/transform/names.lua

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ do
4747
return self.name
4848
end,
4949
chain = function(self, ...)
50-
local items = (function(...)
50+
local items
51+
do
5152
local _accum_0 = { }
5253
local _len_0 = 1
5354
local _list_0 = {
@@ -65,8 +66,8 @@ do
6566
end
6667
_len_0 = _len_0 + 1
6768
end
68-
return _accum_0
69-
end)(...)
69+
items = _accum_0
70+
end
7071
return build.chain({
7172
base = self,
7273
unpack(items)

moonscript/util.lua

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -104,15 +104,16 @@ dump = function(what)
104104
end
105105
seen[what] = true
106106
depth = depth + 1
107-
local lines = (function()
107+
local lines
108+
do
108109
local _accum_0 = { }
109110
local _len_0 = 1
110111
for k, v in pairs(what) do
111112
_accum_0[_len_0] = (" "):rep(depth * 4) .. "[" .. tostring(k) .. "] = " .. _dump(v, depth)
112113
_len_0 = _len_0 + 1
113114
end
114-
return _accum_0
115-
end)()
115+
lines = _accum_0
116+
end
116117
seen[what] = false
117118
return "{\n" .. concat(lines) .. (" "):rep((depth - 1) * 4) .. "}\n"
118119
else
@@ -123,33 +124,38 @@ dump = function(what)
123124
end
124125
local debug_posmap
125126
debug_posmap = function(posmap, moon_code, lua_code)
126-
local tuples = { }
127-
local _len_0 = 1
128-
for k, v in pairs(posmap) do
129-
tuples[_len_0] = {
130-
k,
131-
v
132-
}
133-
_len_0 = _len_0 + 1
127+
local tuples
128+
do
129+
local _accum_0 = { }
130+
local _len_0 = 1
131+
for k, v in pairs(posmap) do
132+
_accum_0[_len_0] = {
133+
k,
134+
v
135+
}
136+
_len_0 = _len_0 + 1
137+
end
138+
tuples = _accum_0
134139
end
135140
table.sort(tuples, function(a, b)
136141
return a[1] < b[1]
137142
end)
138-
local lines = (function()
143+
local lines
144+
do
139145
local _accum_0 = { }
140-
local _len_1 = 1
146+
local _len_0 = 1
141147
for _index_0 = 1, #tuples do
142148
local pair = tuples[_index_0]
143149
local lua_line, pos = unpack(pair)
144150
local moon_line = pos_to_line(moon_code, pos)
145151
local lua_text = get_line(lua_code, lua_line)
146152
local moon_text = get_closest_line(moon_code, moon_line)
147153
local _value_0 = tostring(pos) .. "\t " .. tostring(lua_line) .. ":[ " .. tostring(trim(lua_text)) .. " ] >> " .. tostring(moon_line) .. ":[ " .. tostring(trim(moon_text)) .. " ]"
148-
_accum_0[_len_1] = _value_0
149-
_len_1 = _len_1 + 1
154+
_accum_0[_len_0] = _value_0
155+
_len_0 = _len_0 + 1
150156
end
151-
return _accum_0
152-
end)()
157+
lines = _accum_0
158+
end
153159
return concat(lines, "\n")
154160
end
155161
local setfenv = setfenv or function(fn, env)

0 commit comments

Comments
 (0)