Skip to content

Commit b6987fe

Browse files
committed
wrap class declaration in do instead of anonymous function
1 parent 15dab06 commit b6987fe

File tree

6 files changed

+80
-89
lines changed

6 files changed

+80
-89
lines changed

moonscript/compile.lua

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ local concat, insert = table.concat, table.insert
2020
local pos_to_line, get_closest_line, trim = util.pos_to_line, util.get_closest_line, util.trim
2121
local mtype = util.moon.type
2222
local Line, Lines
23-
Lines = (function()
23+
do
2424
local _parent_0 = nil
2525
local _base_0 = {
2626
mark_pos = function(self, pos, line)
@@ -143,9 +143,9 @@ Lines = (function()
143143
if _parent_0 and _parent_0.__inherited then
144144
_parent_0.__inherited(_parent_0, _class_0)
145145
end
146-
return _class_0
147-
end)()
148-
Line = (function()
146+
Lines = _class_0
147+
end
148+
do
149149
local _parent_0 = nil
150150
local _base_0 = {
151151
pos = nil,
@@ -251,9 +251,9 @@ Line = (function()
251251
if _parent_0 and _parent_0.__inherited then
252252
_parent_0.__inherited(_parent_0, _class_0)
253253
end
254-
return _class_0
255-
end)()
256-
Block = (function()
254+
Line = _class_0
255+
end
256+
do
257257
local _parent_0 = nil
258258
local _base_0 = {
259259
header = "do",
@@ -578,9 +578,9 @@ Block = (function()
578578
if _parent_0 and _parent_0.__inherited then
579579
_parent_0.__inherited(_parent_0, _class_0)
580580
end
581-
return _class_0
582-
end)()
583-
RootBlock = (function()
581+
Block = _class_0
582+
end
583+
do
584584
local _parent_0 = Block
585585
local _base_0 = {
586586
__tostring = function(self)
@@ -636,8 +636,8 @@ RootBlock = (function()
636636
if _parent_0 and _parent_0.__inherited then
637637
_parent_0.__inherited(_parent_0, _class_0)
638638
end
639-
return _class_0
640-
end)()
639+
RootBlock = _class_0
640+
end
641641
format_error = function(msg, pos, file_str)
642642
local line = pos_to_line(file_str, pos)
643643
local line_str

moonscript/data.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Set = function(items)
99
end
1010
return self
1111
end
12-
Stack = (function()
12+
do
1313
local _parent_0 = nil
1414
local _base_0 = {
1515
__tostring = function(self)
@@ -63,8 +63,8 @@ Stack = (function()
6363
if _parent_0 and _parent_0.__inherited then
6464
_parent_0.__inherited(_parent_0, _class_0)
6565
end
66-
return _class_0
67-
end)()
66+
Stack = _class_0
67+
end
6868
lua_keywords = Set({
6969
'and',
7070
'break',

moonscript/transform.lua

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ local reversed = util.reversed
66
local ntype, build, smart_node, is_slice, value_is_singular = types.ntype, types.build, types.smart_node, types.is_slice, types.value_is_singular
77
local insert = table.insert
88
local implicitly_return
9-
LocalName = (function()
9+
do
1010
local _parent_0 = nil
1111
local _base_0 = {
1212
get_name = function(self)
@@ -44,9 +44,9 @@ LocalName = (function()
4444
if _parent_0 and _parent_0.__inherited then
4545
_parent_0.__inherited(_parent_0, _class_0)
4646
end
47-
return _class_0
48-
end)()
49-
NameProxy = (function()
47+
LocalName = _class_0
48+
end
49+
do
5050
local _parent_0 = nil
5151
local _base_0 = {
5252
get_name = function(self, scope)
@@ -134,9 +134,9 @@ NameProxy = (function()
134134
if _parent_0 and _parent_0.__inherited then
135135
_parent_0.__inherited(_parent_0, _class_0)
136136
end
137-
return _class_0
138-
end)()
139-
Run = (function()
137+
NameProxy = _class_0
138+
end
139+
do
140140
local _parent_0 = nil
141141
local _base_0 = {
142142
call = function(self, state)
@@ -174,8 +174,8 @@ Run = (function()
174174
if _parent_0 and _parent_0.__inherited then
175175
_parent_0.__inherited(_parent_0, _class_0)
176176
end
177-
return _class_0
178-
end)()
177+
Run = _class_0
178+
end
179179
local apply_to_last
180180
apply_to_last = function(stms, fn)
181181
local last_exp_id = 0
@@ -340,7 +340,7 @@ with_continue_listener = function(body)
340340
}
341341
end
342342
local Transformer
343-
Transformer = (function()
343+
do
344344
local _parent_0 = nil
345345
local _base_0 = {
346346
transform = function(self, scope, node, ...)
@@ -408,8 +408,8 @@ Transformer = (function()
408408
if _parent_0 and _parent_0.__inherited then
409409
_parent_0.__inherited(_parent_0, _class_0)
410410
end
411-
return _class_0
412-
end)()
411+
Transformer = _class_0
412+
end
413413
local construct_comprehension
414414
construct_comprehension = function(inner, clauses)
415415
local current_stms = inner
@@ -1197,7 +1197,7 @@ Statement = Transformer({
11971197
})
11981198
}
11991199
}),
1200-
cls_name
1200+
_with_0.assign_one(name, cls_name)
12011201
}
12021202
hoist_declarations(out_body)
12031203
value = _with_0.group({
@@ -1206,14 +1206,7 @@ Statement = Transformer({
12061206
name
12071207
}
12081208
}),
1209-
_with_0.assign({
1210-
names = {
1211-
name
1212-
},
1213-
values = {
1214-
_with_0.block_exp(out_body)
1215-
}
1216-
}),
1209+
_with_0["do"](out_body),
12171210
(function()
12181211
if ret then
12191212
return ret(name)
@@ -1225,7 +1218,7 @@ Statement = Transformer({
12251218
end
12261219
})
12271220
local Accumulator
1228-
Accumulator = (function()
1221+
do
12291222
local _parent_0 = nil
12301223
local _base_0 = {
12311224
body_idx = {
@@ -1332,8 +1325,8 @@ Accumulator = (function()
13321325
if _parent_0 and _parent_0.__inherited then
13331326
_parent_0.__inherited(_parent_0, _class_0)
13341327
end
1335-
return _class_0
1336-
end)()
1328+
Accumulator = _class_0
1329+
end
13371330
local default_accumulator
13381331
default_accumulator = function(self, node)
13391332
return Accumulator():convert(node)

moonscript/transform.moon

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -609,17 +609,15 @@ Statement = Transformer {
609609
}
610610
}
611611

612-
cls_name
612+
.assign_one name, cls_name
613613
}
614614

615615
hoist_declarations out_body
616616

617617
value = .group {
618618
.declare names: {name}
619-
.assign {
620-
names: {name}
621-
values: {.block_exp out_body}
622-
}
619+
.do out_body
620+
623621
if ret
624622
ret name
625623
}

0 commit comments

Comments
 (0)