moonscript/tests/outputs/class.lua
2011-10-01 22:35:34 -07:00

171 lines
3.7 KiB
Lua

local Hello
Hello = (function()
local _parent_0 = nil
local _base_0 = {
hello = function(self)
return print(self.test, self.world)
end,
__tostring = function(self)
return "hello world"
end
}
_base_0.__index = _base_0
if _parent_0 then
setmetatable(_base_0, getmetatable(_parent_0).__index)
end
local _class_0 = setmetatable({
__init = function(self, test, world)
self.test, self.world = test, world
return print("creating object..")
end
}, {
__index = _base_0,
__call = function(cls, ...)
local _self_0 = setmetatable({}, _base_0)
cls.__init(_self_0, ...)
return _self_0
end
})
_base_0.__class = _class_0
return _class_0
end)()
local x = Hello(1, 2)
x:hello()
print(x)
local Simple
Simple = (function()
local _parent_0 = nil
local _base_0 = {
cool = function(self)
return print("cool")
end
}
_base_0.__index = _base_0
if _parent_0 then
setmetatable(_base_0, getmetatable(_parent_0).__index)
end
local _class_0 = setmetatable({
__init = function(self, ...)
if _parent_0 then
return _parent_0.__init(self, ...)
end
end
}, {
__index = _base_0,
__call = function(cls, ...)
local _self_0 = setmetatable({}, _base_0)
cls.__init(_self_0, ...)
return _self_0
end
})
_base_0.__class = _class_0
return _class_0
end)()
local Yikes
Yikes = (function()
local _parent_0 = Simple
local _base_0 = { }
_base_0.__index = _base_0
if _parent_0 then
setmetatable(_base_0, getmetatable(_parent_0).__index)
end
local _class_0 = setmetatable({
__init = function(self)
return print("created hello")
end
}, {
__index = _base_0,
__call = function(cls, ...)
local _self_0 = setmetatable({}, _base_0)
cls.__init(_self_0, ...)
return _self_0
end
})
_base_0.__class = _class_0
return _class_0
end)()
x = Yikes()
x:cool()
local Hi
Hi = (function()
local _parent_0 = nil
local _base_0 = {
cool = function(self, num)
return print("num", num)
end
}
_base_0.__index = _base_0
if _parent_0 then
setmetatable(_base_0, getmetatable(_parent_0).__index)
end
local _class_0 = setmetatable({
__init = function(self, arg)
return print("init arg", arg)
end
}, {
__index = _base_0,
__call = function(cls, ...)
local _self_0 = setmetatable({}, _base_0)
cls.__init(_self_0, ...)
return _self_0
end
})
_base_0.__class = _class_0
return _class_0
end)()
Simple = (function()
local _parent_0 = Hi
local _base_0 = {
cool = function(self)
return _parent_0.cool(self, 120302)
end
}
_base_0.__index = _base_0
if _parent_0 then
setmetatable(_base_0, getmetatable(_parent_0).__index)
end
local _class_0 = setmetatable({
__init = function(self)
return _parent_0.__init(self, "man")
end
}, {
__index = _base_0,
__call = function(cls, ...)
local _self_0 = setmetatable({}, _base_0)
cls.__init(_self_0, ...)
return _self_0
end
})
_base_0.__class = _class_0
return _class_0
end)()
x = Simple()
x:cool()
print(x.__class == Simple)
local Okay
Okay = (function()
local _parent_0 = nil
local _base_0 = {
something = 20323
}
_base_0.__index = _base_0
if _parent_0 then
setmetatable(_base_0, getmetatable(_parent_0).__index)
end
local _class_0 = setmetatable({
__init = function(self, ...)
if _parent_0 then
return _parent_0.__init(self, ...)
end
end
}, {
__index = _base_0,
__call = function(cls, ...)
local _self_0 = setmetatable({}, _base_0)
cls.__init(_self_0, ...)
return _self_0
end
})
_base_0.__class = _class_0
return _class_0
end)()