mirror of
https://github.com/leafo/moonscript.git
synced 2024-11-22 02:44:23 +00:00
don't alter class constructor at all
This commit is contained in:
parent
a44c5ac27f
commit
af2c443807
@ -882,7 +882,7 @@ local Statement = Transformer({
|
||||
end
|
||||
end
|
||||
end
|
||||
local constructor = nil
|
||||
local constructor
|
||||
properties = (function()
|
||||
local _accum_0 = { }
|
||||
local _len_0 = 1
|
||||
@ -914,7 +914,7 @@ local Statement = Transformer({
|
||||
local base_name = NameProxy("base")
|
||||
local self_name = NameProxy("self")
|
||||
local cls_name = NameProxy("class")
|
||||
if not constructor then
|
||||
if not (constructor) then
|
||||
constructor = build.fndef({
|
||||
args = {
|
||||
{
|
||||
@ -939,9 +939,6 @@ local Statement = Transformer({
|
||||
})
|
||||
}
|
||||
})
|
||||
else
|
||||
smart_node(constructor)
|
||||
constructor.arrow = "fat"
|
||||
end
|
||||
local real_name = name or parent_assign and parent_assign[2][1]
|
||||
local _exp_0 = ntype(real_name)
|
||||
|
@ -482,7 +482,7 @@ Statement = Transformer {
|
||||
insert properties, tuple
|
||||
|
||||
-- find constructor
|
||||
constructor = nil
|
||||
local constructor
|
||||
properties = for tuple in *properties
|
||||
key = tuple[1]
|
||||
if key[1] == "key_literal" and key[2] == constructor_name
|
||||
@ -496,7 +496,7 @@ Statement = Transformer {
|
||||
self_name = NameProxy "self"
|
||||
cls_name = NameProxy "class"
|
||||
|
||||
if not constructor
|
||||
unless constructor
|
||||
constructor = build.fndef {
|
||||
args: {{"..."}}
|
||||
arrow: "fat"
|
||||
@ -509,9 +509,6 @@ Statement = Transformer {
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
smart_node constructor
|
||||
constructor.arrow = "fat"
|
||||
|
||||
real_name = name or parent_assign and parent_assign[2][1]
|
||||
real_name = switch ntype real_name
|
||||
|
@ -172,4 +172,7 @@ class Something
|
||||
|
||||
--
|
||||
|
||||
class X
|
||||
new: hi
|
||||
|
||||
nil
|
||||
|
@ -1030,4 +1030,37 @@ do
|
||||
end
|
||||
Something = _class_0
|
||||
end
|
||||
do
|
||||
local _parent_0 = nil
|
||||
local _base_0 = { }
|
||||
_base_0.__index = _base_0
|
||||
if _parent_0 then
|
||||
setmetatable(_base_0, _parent_0.__base)
|
||||
end
|
||||
local _class_0 = setmetatable({
|
||||
__init = hi,
|
||||
__base = _base_0,
|
||||
__name = "X",
|
||||
__parent = _parent_0
|
||||
}, {
|
||||
__index = function(cls, name)
|
||||
local val = rawget(_base_0, name)
|
||||
if val == nil and _parent_0 then
|
||||
return _parent_0[name]
|
||||
else
|
||||
return val
|
||||
end
|
||||
end,
|
||||
__call = function(cls, ...)
|
||||
local _self_0 = setmetatable({}, _base_0)
|
||||
cls.__init(_self_0, ...)
|
||||
return _self_0
|
||||
end
|
||||
})
|
||||
_base_0.__class = _class_0
|
||||
if _parent_0 and _parent_0.__inherited then
|
||||
_parent_0.__inherited(_parent_0, _class_0)
|
||||
end
|
||||
X = _class_0
|
||||
end
|
||||
return nil
|
Loading…
Reference in New Issue
Block a user