mirror of
https://github.com/leafo/moonscript.git
synced 2024-11-22 02:44:23 +00:00
d1059b8f98
Looking up a class property will now search the parent class properties if parent exists Classes have a few more built in properties: * __name holds the name of the class as it was defined as a string * __base holds the instance metatable as it was defined (not dynamic) * __parent holds the class's parent class if it exists (not dynamic) The way class inheritance is handled was CHANGED (uses __base instead of looking at __index of parents metatable). Make sure you recompile all your code if using class inheritance because old classes won't work with new ones.
69 lines
1.2 KiB
Lua
69 lines
1.2 KiB
Lua
a, b, c = 223, 343
|
|
cool = "dad"
|
|
Something = (function()
|
|
local _parent_0 = nil
|
|
local _base_0 = {
|
|
umm = "cool"
|
|
}
|
|
_base_0.__index = _base_0
|
|
if _parent_0 then
|
|
setmetatable(_base_0, _parent_0.__base)
|
|
end
|
|
local _class_0 = setmetatable({
|
|
__init = function(self, ...)
|
|
if _parent_0 then
|
|
return _parent_0.__init(self, ...)
|
|
end
|
|
end,
|
|
__base = _base_0,
|
|
__name = "Something",
|
|
__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
|
|
return _class_0
|
|
end)()
|
|
local What
|
|
if this then
|
|
What = 232
|
|
else
|
|
What = 4343
|
|
end
|
|
local d
|
|
a, b, c, d = "hello"
|
|
local another = 3434
|
|
Another = 7890
|
|
if inner then
|
|
local Yeah = "10000"
|
|
end
|
|
if this then
|
|
What = 232
|
|
else
|
|
What = 4343
|
|
end
|
|
if this then
|
|
What = 232
|
|
else
|
|
What = 4343
|
|
end
|
|
x, y, z = 1, 2, 3
|
|
y = function()
|
|
local hallo = 3434
|
|
end
|
|
do
|
|
local _with_0 = tmp
|
|
local j = 2000
|
|
end |