mirror of
https://github.com/leafo/moonscript.git
synced 2024-11-22 02:44:23 +00:00
wrap class declaration in do instead of anonymous function
This commit is contained in:
parent
15dab06d31
commit
b6987fe6d8
@ -20,7 +20,7 @@ local concat, insert = table.concat, table.insert
|
||||
local pos_to_line, get_closest_line, trim = util.pos_to_line, util.get_closest_line, util.trim
|
||||
local mtype = util.moon.type
|
||||
local Line, Lines
|
||||
Lines = (function()
|
||||
do
|
||||
local _parent_0 = nil
|
||||
local _base_0 = {
|
||||
mark_pos = function(self, pos, line)
|
||||
@ -143,9 +143,9 @@ Lines = (function()
|
||||
if _parent_0 and _parent_0.__inherited then
|
||||
_parent_0.__inherited(_parent_0, _class_0)
|
||||
end
|
||||
return _class_0
|
||||
end)()
|
||||
Line = (function()
|
||||
Lines = _class_0
|
||||
end
|
||||
do
|
||||
local _parent_0 = nil
|
||||
local _base_0 = {
|
||||
pos = nil,
|
||||
@ -251,9 +251,9 @@ Line = (function()
|
||||
if _parent_0 and _parent_0.__inherited then
|
||||
_parent_0.__inherited(_parent_0, _class_0)
|
||||
end
|
||||
return _class_0
|
||||
end)()
|
||||
Block = (function()
|
||||
Line = _class_0
|
||||
end
|
||||
do
|
||||
local _parent_0 = nil
|
||||
local _base_0 = {
|
||||
header = "do",
|
||||
@ -578,9 +578,9 @@ Block = (function()
|
||||
if _parent_0 and _parent_0.__inherited then
|
||||
_parent_0.__inherited(_parent_0, _class_0)
|
||||
end
|
||||
return _class_0
|
||||
end)()
|
||||
RootBlock = (function()
|
||||
Block = _class_0
|
||||
end
|
||||
do
|
||||
local _parent_0 = Block
|
||||
local _base_0 = {
|
||||
__tostring = function(self)
|
||||
@ -636,8 +636,8 @@ RootBlock = (function()
|
||||
if _parent_0 and _parent_0.__inherited then
|
||||
_parent_0.__inherited(_parent_0, _class_0)
|
||||
end
|
||||
return _class_0
|
||||
end)()
|
||||
RootBlock = _class_0
|
||||
end
|
||||
format_error = function(msg, pos, file_str)
|
||||
local line = pos_to_line(file_str, pos)
|
||||
local line_str
|
||||
|
@ -9,7 +9,7 @@ Set = function(items)
|
||||
end
|
||||
return self
|
||||
end
|
||||
Stack = (function()
|
||||
do
|
||||
local _parent_0 = nil
|
||||
local _base_0 = {
|
||||
__tostring = function(self)
|
||||
@ -63,8 +63,8 @@ Stack = (function()
|
||||
if _parent_0 and _parent_0.__inherited then
|
||||
_parent_0.__inherited(_parent_0, _class_0)
|
||||
end
|
||||
return _class_0
|
||||
end)()
|
||||
Stack = _class_0
|
||||
end
|
||||
lua_keywords = Set({
|
||||
'and',
|
||||
'break',
|
||||
|
@ -6,7 +6,7 @@ local reversed = util.reversed
|
||||
local ntype, build, smart_node, is_slice, value_is_singular = types.ntype, types.build, types.smart_node, types.is_slice, types.value_is_singular
|
||||
local insert = table.insert
|
||||
local implicitly_return
|
||||
LocalName = (function()
|
||||
do
|
||||
local _parent_0 = nil
|
||||
local _base_0 = {
|
||||
get_name = function(self)
|
||||
@ -44,9 +44,9 @@ LocalName = (function()
|
||||
if _parent_0 and _parent_0.__inherited then
|
||||
_parent_0.__inherited(_parent_0, _class_0)
|
||||
end
|
||||
return _class_0
|
||||
end)()
|
||||
NameProxy = (function()
|
||||
LocalName = _class_0
|
||||
end
|
||||
do
|
||||
local _parent_0 = nil
|
||||
local _base_0 = {
|
||||
get_name = function(self, scope)
|
||||
@ -134,9 +134,9 @@ NameProxy = (function()
|
||||
if _parent_0 and _parent_0.__inherited then
|
||||
_parent_0.__inherited(_parent_0, _class_0)
|
||||
end
|
||||
return _class_0
|
||||
end)()
|
||||
Run = (function()
|
||||
NameProxy = _class_0
|
||||
end
|
||||
do
|
||||
local _parent_0 = nil
|
||||
local _base_0 = {
|
||||
call = function(self, state)
|
||||
@ -174,8 +174,8 @@ Run = (function()
|
||||
if _parent_0 and _parent_0.__inherited then
|
||||
_parent_0.__inherited(_parent_0, _class_0)
|
||||
end
|
||||
return _class_0
|
||||
end)()
|
||||
Run = _class_0
|
||||
end
|
||||
local apply_to_last
|
||||
apply_to_last = function(stms, fn)
|
||||
local last_exp_id = 0
|
||||
@ -340,7 +340,7 @@ with_continue_listener = function(body)
|
||||
}
|
||||
end
|
||||
local Transformer
|
||||
Transformer = (function()
|
||||
do
|
||||
local _parent_0 = nil
|
||||
local _base_0 = {
|
||||
transform = function(self, scope, node, ...)
|
||||
@ -408,8 +408,8 @@ Transformer = (function()
|
||||
if _parent_0 and _parent_0.__inherited then
|
||||
_parent_0.__inherited(_parent_0, _class_0)
|
||||
end
|
||||
return _class_0
|
||||
end)()
|
||||
Transformer = _class_0
|
||||
end
|
||||
local construct_comprehension
|
||||
construct_comprehension = function(inner, clauses)
|
||||
local current_stms = inner
|
||||
@ -1197,7 +1197,7 @@ Statement = Transformer({
|
||||
})
|
||||
}
|
||||
}),
|
||||
cls_name
|
||||
_with_0.assign_one(name, cls_name)
|
||||
}
|
||||
hoist_declarations(out_body)
|
||||
value = _with_0.group({
|
||||
@ -1206,14 +1206,7 @@ Statement = Transformer({
|
||||
name
|
||||
}
|
||||
}),
|
||||
_with_0.assign({
|
||||
names = {
|
||||
name
|
||||
},
|
||||
values = {
|
||||
_with_0.block_exp(out_body)
|
||||
}
|
||||
}),
|
||||
_with_0["do"](out_body),
|
||||
(function()
|
||||
if ret then
|
||||
return ret(name)
|
||||
@ -1225,7 +1218,7 @@ Statement = Transformer({
|
||||
end
|
||||
})
|
||||
local Accumulator
|
||||
Accumulator = (function()
|
||||
do
|
||||
local _parent_0 = nil
|
||||
local _base_0 = {
|
||||
body_idx = {
|
||||
@ -1332,8 +1325,8 @@ Accumulator = (function()
|
||||
if _parent_0 and _parent_0.__inherited then
|
||||
_parent_0.__inherited(_parent_0, _class_0)
|
||||
end
|
||||
return _class_0
|
||||
end)()
|
||||
Accumulator = _class_0
|
||||
end
|
||||
local default_accumulator
|
||||
default_accumulator = function(self, node)
|
||||
return Accumulator():convert(node)
|
||||
|
@ -609,17 +609,15 @@ Statement = Transformer {
|
||||
}
|
||||
}
|
||||
|
||||
cls_name
|
||||
.assign_one name, cls_name
|
||||
}
|
||||
|
||||
hoist_declarations out_body
|
||||
|
||||
value = .group {
|
||||
.declare names: {name}
|
||||
.assign {
|
||||
names: {name}
|
||||
values: {.block_exp out_body}
|
||||
}
|
||||
.do out_body
|
||||
|
||||
if ret
|
||||
ret name
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
local Hello
|
||||
Hello = (function()
|
||||
do
|
||||
local _parent_0 = nil
|
||||
local _base_0 = {
|
||||
hello = function(self)
|
||||
@ -40,13 +40,13 @@ Hello = (function()
|
||||
if _parent_0 and _parent_0.__inherited then
|
||||
_parent_0.__inherited(_parent_0, _class_0)
|
||||
end
|
||||
return _class_0
|
||||
end)()
|
||||
Hello = _class_0
|
||||
end
|
||||
local x = Hello(1, 2)
|
||||
x:hello()
|
||||
print(x)
|
||||
local Simple
|
||||
Simple = (function()
|
||||
do
|
||||
local _parent_0 = nil
|
||||
local _base_0 = {
|
||||
cool = function(self)
|
||||
@ -85,10 +85,10 @@ Simple = (function()
|
||||
if _parent_0 and _parent_0.__inherited then
|
||||
_parent_0.__inherited(_parent_0, _class_0)
|
||||
end
|
||||
return _class_0
|
||||
end)()
|
||||
Simple = _class_0
|
||||
end
|
||||
local Yikes
|
||||
Yikes = (function()
|
||||
do
|
||||
local _parent_0 = Simple
|
||||
local _base_0 = { }
|
||||
_base_0.__index = _base_0
|
||||
@ -121,12 +121,12 @@ Yikes = (function()
|
||||
if _parent_0 and _parent_0.__inherited then
|
||||
_parent_0.__inherited(_parent_0, _class_0)
|
||||
end
|
||||
return _class_0
|
||||
end)()
|
||||
Yikes = _class_0
|
||||
end
|
||||
x = Yikes()
|
||||
x:cool()
|
||||
local Hi
|
||||
Hi = (function()
|
||||
do
|
||||
local _parent_0 = nil
|
||||
local _base_0 = {
|
||||
cool = function(self, num)
|
||||
@ -163,9 +163,9 @@ Hi = (function()
|
||||
if _parent_0 and _parent_0.__inherited then
|
||||
_parent_0.__inherited(_parent_0, _class_0)
|
||||
end
|
||||
return _class_0
|
||||
end)()
|
||||
Simple = (function()
|
||||
Hi = _class_0
|
||||
end
|
||||
do
|
||||
local _parent_0 = Hi
|
||||
local _base_0 = {
|
||||
cool = function(self)
|
||||
@ -202,13 +202,13 @@ Simple = (function()
|
||||
if _parent_0 and _parent_0.__inherited then
|
||||
_parent_0.__inherited(_parent_0, _class_0)
|
||||
end
|
||||
return _class_0
|
||||
end)()
|
||||
Simple = _class_0
|
||||
end
|
||||
x = Simple()
|
||||
x:cool()
|
||||
print(x.__class == Simple)
|
||||
local Okay
|
||||
Okay = (function()
|
||||
do
|
||||
local _parent_0 = nil
|
||||
local _base_0 = {
|
||||
something = 20323
|
||||
@ -245,10 +245,10 @@ Okay = (function()
|
||||
if _parent_0 and _parent_0.__inherited then
|
||||
_parent_0.__inherited(_parent_0, _class_0)
|
||||
end
|
||||
return _class_0
|
||||
end)()
|
||||
Okay = _class_0
|
||||
end
|
||||
local Biggie
|
||||
Biggie = (function()
|
||||
do
|
||||
local _parent_0 = Okay
|
||||
local _base_0 = {
|
||||
something = function(self)
|
||||
@ -289,10 +289,10 @@ Biggie = (function()
|
||||
if _parent_0 and _parent_0.__inherited then
|
||||
_parent_0.__inherited(_parent_0, _class_0)
|
||||
end
|
||||
return _class_0
|
||||
end)()
|
||||
Biggie = _class_0
|
||||
end
|
||||
local Yeah
|
||||
Yeah = (function()
|
||||
do
|
||||
local _parent_0 = nil
|
||||
local _base_0 = {
|
||||
okay = function(self)
|
||||
@ -331,10 +331,10 @@ Yeah = (function()
|
||||
if _parent_0 and _parent_0.__inherited then
|
||||
_parent_0.__inherited(_parent_0, _class_0)
|
||||
end
|
||||
return _class_0
|
||||
end)()
|
||||
Yeah = _class_0
|
||||
end
|
||||
local What
|
||||
What = (function()
|
||||
do
|
||||
local _parent_0 = nil
|
||||
local _base_0 = {
|
||||
something = function(self)
|
||||
@ -373,9 +373,9 @@ What = (function()
|
||||
if _parent_0 and _parent_0.__inherited then
|
||||
_parent_0.__inherited(_parent_0, _class_0)
|
||||
end
|
||||
return _class_0
|
||||
end)()
|
||||
Hello = (function()
|
||||
What = _class_0
|
||||
end
|
||||
do
|
||||
local _parent_0 = What
|
||||
local _base_0 = {
|
||||
val = 2323,
|
||||
@ -421,8 +421,8 @@ Hello = (function()
|
||||
if _parent_0 and _parent_0.__inherited then
|
||||
_parent_0.__inherited(_parent_0, _class_0)
|
||||
end
|
||||
return _class_0
|
||||
end)()
|
||||
Hello = _class_0
|
||||
end
|
||||
do
|
||||
local _with_0 = Hello()
|
||||
x = _with_0:something()
|
||||
@ -430,7 +430,7 @@ do
|
||||
x()
|
||||
end
|
||||
local CoolSuper
|
||||
CoolSuper = (function()
|
||||
do
|
||||
local _parent_0 = nil
|
||||
local _base_0 = {
|
||||
hi = function(self)
|
||||
@ -475,8 +475,8 @@ CoolSuper = (function()
|
||||
if _parent_0 and _parent_0.__inherited then
|
||||
_parent_0.__inherited(_parent_0, _class_0)
|
||||
end
|
||||
return _class_0
|
||||
end)()
|
||||
CoolSuper = _class_0
|
||||
end
|
||||
x = self.hello
|
||||
x = self.__class.hello
|
||||
self:hello("world")
|
||||
@ -487,7 +487,7 @@ xx = function(hello, world, cool)
|
||||
self.hello, self.__class.world = hello, world
|
||||
end
|
||||
local ClassMan
|
||||
ClassMan = (function()
|
||||
do
|
||||
local _parent_0 = nil
|
||||
local _base_0 = {
|
||||
blue = function(self) end,
|
||||
@ -530,8 +530,8 @@ ClassMan = (function()
|
||||
if _parent_0 and _parent_0.__inherited then
|
||||
_parent_0.__inherited(_parent_0, _class_0)
|
||||
end
|
||||
return _class_0
|
||||
end)()
|
||||
ClassMan = _class_0
|
||||
end
|
||||
x = self
|
||||
local y = self.__class
|
||||
self(something)
|
||||
@ -541,7 +541,7 @@ self = 343
|
||||
self.hello(2, 3, 4)
|
||||
local _ = hello[self].world
|
||||
local Whacko
|
||||
Whacko = (function()
|
||||
do
|
||||
local hello
|
||||
local _parent_0 = nil
|
||||
local _base_0 = { }
|
||||
@ -587,13 +587,13 @@ Whacko = (function()
|
||||
if _parent_0 and _parent_0.__inherited then
|
||||
_parent_0.__inherited(_parent_0, _class_0)
|
||||
end
|
||||
return _class_0
|
||||
end)()
|
||||
Whacko = _class_0
|
||||
end
|
||||
print("hello")
|
||||
local yyy
|
||||
yyy = function()
|
||||
local Cool
|
||||
Cool = (function()
|
||||
do
|
||||
local _parent_0 = nil
|
||||
local _base_0 = { }
|
||||
_base_0.__index = _base_0
|
||||
@ -630,7 +630,7 @@ yyy = function()
|
||||
if _parent_0 and _parent_0.__inherited then
|
||||
_parent_0.__inherited(_parent_0, _class_0)
|
||||
end
|
||||
return _class_0
|
||||
end)()
|
||||
Cool = _class_0
|
||||
end
|
||||
return Cool
|
||||
end
|
@ -1,6 +1,6 @@
|
||||
a, b, c = 223, 343
|
||||
cool = "dad"
|
||||
Something = (function()
|
||||
do
|
||||
local _parent_0 = nil
|
||||
local _base_0 = {
|
||||
umm = "cool"
|
||||
@ -37,8 +37,8 @@ Something = (function()
|
||||
if _parent_0 and _parent_0.__inherited then
|
||||
_parent_0.__inherited(_parent_0, _class_0)
|
||||
end
|
||||
return _class_0
|
||||
end)()
|
||||
Something = _class_0
|
||||
end
|
||||
local What
|
||||
if this then
|
||||
What = 232
|
||||
|
Loading…
Reference in New Issue
Block a user