rebuild specs and code

This commit is contained in:
leaf corcoran 2015-11-19 22:47:06 -08:00
parent 66d80ed217
commit ae2558ab67
3 changed files with 120 additions and 53 deletions

View File

@ -171,6 +171,7 @@ with_continue_listener = function(body)
} }
end end
do do
local _class_0
local _base_0 = { local _base_0 = {
transform_once = function(self, scope, node, ...) transform_once = function(self, scope, node, ...)
if self.seen_nodes[node] then if self.seen_nodes[node] then
@ -217,7 +218,7 @@ do
end end
} }
_base_0.__index = _base_0 _base_0.__index = _base_0
local _class_0 = setmetatable({ _class_0 = setmetatable({
__init = function(self, transformers) __init = function(self, transformers)
self.transformers = transformers self.transformers = transformers
self.seen_nodes = setmetatable({ }, { self.seen_nodes = setmetatable({ }, {
@ -1000,7 +1001,35 @@ Statement = Transformer({
"nil" "nil"
}, },
["then"] = { ["then"] = {
parent_cls_name:index("name") build.assign_one(LocalName("parent"), build.chain({
base = "rawget",
{
"call",
{
{
"ref",
"cls"
},
{
"string",
'"',
"__parent"
}
}
}
})),
build["if"]({
cond = LocalName("parent"),
["then"] = {
build.chain({
base = LocalName("parent"),
{
"index",
"name"
}
})
}
})
} }
}) })
insert(class_lookup, { insert(class_lookup, {
@ -1098,18 +1127,23 @@ Statement = Transformer({
self:put_name(name) self:put_name(name)
end end
return self:set("super", function(block, chain) return self:set("super", function(block, chain)
local relative_parent = {
"chain",
cls_name,
{
"dot",
"__parent"
}
}
if chain then if chain then
local chain_tail = { local chain_tail = {
unpack(chain, 3) unpack(chain, 3)
} }
local new_chain = {
"chain",
parent_cls_name
}
local head = chain_tail[1] local head = chain_tail[1]
if head == nil then if head == nil then
return parent_cls_name return relative_parent
end end
local new_chain = relative_parent
local _exp_1 = head[1] local _exp_1 = head[1]
if "call" == _exp_1 then if "call" == _exp_1 then
local calling_name = block:get("current_block") local calling_name = block:get("current_block")
@ -1153,10 +1187,16 @@ Statement = Transformer({
end end
return new_chain return new_chain
else else
return parent_cls_name return relative_parent
end end
end) end)
end), end),
{
"declare",
{
cls_name
}
},
{ {
"declare_glob", "declare_glob",
"*" "*"
@ -1240,6 +1280,7 @@ Statement = Transformer({
end end
}) })
do do
local _class_0
local _base_0 = { local _base_0 = {
body_idx = { body_idx = {
["for"] = 4, ["for"] = 4,
@ -1300,7 +1341,7 @@ do
end end
} }
_base_0.__index = _base_0 _base_0.__index = _base_0
local _class_0 = setmetatable({ _class_0 = setmetatable({
__init = function(self, accum_name) __init = function(self, accum_name)
self.accum_name = NameProxy("accum") self.accum_name = NameProxy("accum")
self.value_name = NameProxy("value") self.value_name = NameProxy("value")

View File

@ -1,5 +1,6 @@
local Hello local Hello
do do
local _class_0
local _base_0 = { local _base_0 = {
hello = function(self) hello = function(self)
return print(self.test, self.world) return print(self.test, self.world)
@ -9,7 +10,7 @@ do
end end
} }
_base_0.__index = _base_0 _base_0.__index = _base_0
local _class_0 = setmetatable({ _class_0 = setmetatable({
__init = function(self, test, world) __init = function(self, test, world)
self.test, self.world = test, world self.test, self.world = test, world
return print("creating object..") return print("creating object..")
@ -32,13 +33,14 @@ x:hello()
print(x) print(x)
local Simple local Simple
do do
local _class_0
local _base_0 = { local _base_0 = {
cool = function(self) cool = function(self)
return print("cool") return print("cool")
end end
} }
_base_0.__index = _base_0 _base_0.__index = _base_0
local _class_0 = setmetatable({ _class_0 = setmetatable({
__init = function() end, __init = function() end,
__base = _base_0, __base = _base_0,
__name = "Simple" __name = "Simple"
@ -55,11 +57,12 @@ do
end end
local Yikes local Yikes
do do
local _class_0
local _parent_0 = Simple local _parent_0 = Simple
local _base_0 = { } local _base_0 = { }
_base_0.__index = _base_0 _base_0.__index = _base_0
setmetatable(_base_0, _parent_0.__base) setmetatable(_base_0, _parent_0.__base)
local _class_0 = setmetatable({ _class_0 = setmetatable({
__init = function(self) __init = function(self)
return print("created hello") return print("created hello")
end, end,
@ -94,13 +97,14 @@ x = Yikes()
x:cool() x:cool()
local Hi local Hi
do do
local _class_0
local _base_0 = { local _base_0 = {
cool = function(self, num) cool = function(self, num)
return print("num", num) return print("num", num)
end end
} }
_base_0.__index = _base_0 _base_0.__index = _base_0
local _class_0 = setmetatable({ _class_0 = setmetatable({
__init = function(self, arg) __init = function(self, arg)
return print("init arg", arg) return print("init arg", arg)
end, end,
@ -118,17 +122,18 @@ do
Hi = _class_0 Hi = _class_0
end end
do do
local _class_0
local _parent_0 = Hi local _parent_0 = Hi
local _base_0 = { local _base_0 = {
cool = function(self) cool = function(self)
return self.__class.__parent.cool(self, 120302) return _class_0.__parent.cool(self, 120302)
end end
} }
_base_0.__index = _base_0 _base_0.__index = _base_0
setmetatable(_base_0, _parent_0.__base) setmetatable(_base_0, _parent_0.__base)
local _class_0 = setmetatable({ _class_0 = setmetatable({
__init = function(self) __init = function(self)
return self.__class.__parent.__init(self, "man") return _class_0.__parent.__init(self, "man")
end, end,
__base = _base_0, __base = _base_0,
__name = "Simple", __name = "Simple",
@ -162,11 +167,12 @@ x:cool()
print(x.__class == Simple) print(x.__class == Simple)
local Okay local Okay
do do
local _class_0
local _base_0 = { local _base_0 = {
something = 20323 something = 20323
} }
_base_0.__index = _base_0 _base_0.__index = _base_0
local _class_0 = setmetatable({ _class_0 = setmetatable({
__init = function() end, __init = function() end,
__base = _base_0, __base = _base_0,
__name = "Okay" __name = "Okay"
@ -183,19 +189,20 @@ do
end end
local Biggie local Biggie
do do
local _class_0
local _parent_0 = Okay local _parent_0 = Okay
local _base_0 = { local _base_0 = {
something = function(self) something = function(self)
self.__class.__parent.something(self, 1, 2, 3, 4) _class_0.__parent.something(self, 1, 2, 3, 4)
self.__class.__parent.something(another_self, 1, 2, 3, 4) _class_0.__parent.something(another_self, 1, 2, 3, 4)
return assert(self.__class.__parent == Okay) return assert(_class_0.__parent == Okay)
end end
} }
_base_0.__index = _base_0 _base_0.__index = _base_0
setmetatable(_base_0, _parent_0.__base) setmetatable(_base_0, _parent_0.__base)
local _class_0 = setmetatable({ _class_0 = setmetatable({
__init = function(self, ...) __init = function(self, ...)
return self.__class.__parent.__init(self, ...) return _class_0.__parent.__init(self, ...)
end, end,
__base = _base_0, __base = _base_0,
__name = "Biggie", __name = "Biggie",
@ -226,13 +233,14 @@ do
end end
local Yeah local Yeah
do do
local _class_0
local _base_0 = { local _base_0 = {
okay = function(self) okay = function(self)
return self.__class.__parent.something(self, 1, 2, 3, 4) return _class_0.__parent.something(self, 1, 2, 3, 4)
end end
} }
_base_0.__index = _base_0 _base_0.__index = _base_0
local _class_0 = setmetatable({ _class_0 = setmetatable({
__init = function() end, __init = function() end,
__base = _base_0, __base = _base_0,
__name = "Yeah" __name = "Yeah"
@ -249,13 +257,14 @@ do
end end
local What local What
do do
local _class_0
local _base_0 = { local _base_0 = {
something = function(self) something = function(self)
return print("val:", self.val) return print("val:", self.val)
end end
} }
_base_0.__index = _base_0 _base_0.__index = _base_0
local _class_0 = setmetatable({ _class_0 = setmetatable({
__init = function() end, __init = function() end,
__base = _base_0, __base = _base_0,
__name = "What" __name = "What"
@ -271,11 +280,12 @@ do
What = _class_0 What = _class_0
end end
do do
local _class_0
local _parent_0 = What local _parent_0 = What
local _base_0 = { local _base_0 = {
val = 2323, val = 2323,
something = function(self) something = function(self)
local _base_1 = self.__class.__parent local _base_1 = _class_0.__parent
local _fn_0 = _base_1.something local _fn_0 = _base_1.something
return function(...) return function(...)
return _fn_0(self, ...) return _fn_0(self, ...)
@ -284,9 +294,9 @@ do
} }
_base_0.__index = _base_0 _base_0.__index = _base_0
setmetatable(_base_0, _parent_0.__base) setmetatable(_base_0, _parent_0.__base)
local _class_0 = setmetatable({ _class_0 = setmetatable({
__init = function(self, ...) __init = function(self, ...)
return self.__class.__parent.__init(self, ...) return _class_0.__parent.__init(self, ...)
end, end,
__base = _base_0, __base = _base_0,
__name = "Hello", __name = "Hello",
@ -323,16 +333,17 @@ do
end end
local CoolSuper local CoolSuper
do do
local _class_0
local _base_0 = { local _base_0 = {
hi = function(self) hi = function(self)
self.__class.__parent.hi(self, 1, 2, 3, 4)(1, 2, 3, 4) _class_0.__parent.hi(self, 1, 2, 3, 4)(1, 2, 3, 4)
self.__class.__parent.something(1, 2, 3, 4) _class_0.__parent.something(1, 2, 3, 4)
local _ = self.__class.__parent.something(1, 2, 3, 4).world local _ = _class_0.__parent.something(1, 2, 3, 4).world
self.__class.__parent.yeah(self, "world").okay(hi, hi, hi) _class_0.__parent.yeah(self, "world").okay(hi, hi, hi)
_ = something.super _ = something.super
_ = self.__class.__parent.super.super.super _ = _class_0.__parent.super.super.super
do do
local _base_1 = self.__class.__parent local _base_1 = _class_0.__parent
local _fn_0 = _base_1.hello local _fn_0 = _base_1.hello
_ = function(...) _ = function(...)
return _fn_0(self, ...) return _fn_0(self, ...)
@ -342,7 +353,7 @@ do
end end
} }
_base_0.__index = _base_0 _base_0.__index = _base_0
local _class_0 = setmetatable({ _class_0 = setmetatable({
__init = function() end, __init = function() end,
__base = _base_0, __base = _base_0,
__name = "CoolSuper" __name = "CoolSuper"
@ -368,12 +379,13 @@ xx = function(hello, world, cool)
end end
local ClassMan local ClassMan
do do
local _class_0
local _base_0 = { local _base_0 = {
blue = function(self) end, blue = function(self) end,
green = function(self) end green = function(self) end
} }
_base_0.__index = _base_0 _base_0.__index = _base_0
local _class_0 = setmetatable({ _class_0 = setmetatable({
__init = function() end, __init = function() end,
__base = _base_0, __base = _base_0,
__name = "ClassMan" __name = "ClassMan"
@ -403,10 +415,11 @@ self.hello(2, 3, 4)
local _ = hello[self].world local _ = hello[self].world
local Whacko local Whacko
do do
local _class_0
local hello local hello
local _base_0 = { } local _base_0 = { }
_base_0.__index = _base_0 _base_0.__index = _base_0
local _class_0 = setmetatable({ _class_0 = setmetatable({
__init = function() end, __init = function() end,
__base = _base_0, __base = _base_0,
__name = "Whacko" __name = "Whacko"
@ -436,9 +449,10 @@ local yyy
yyy = function() yyy = function()
local Cool local Cool
do do
local _class_0
local _base_0 = { } local _base_0 = { }
_base_0.__index = _base_0 _base_0.__index = _base_0
local _class_0 = setmetatable({ _class_0 = setmetatable({
__init = function() end, __init = function() end,
__base = _base_0, __base = _base_0,
__name = "Cool" __name = "Cool"
@ -458,9 +472,10 @@ yyy = function()
end end
end end
do do
local _class_0
local _base_0 = { } local _base_0 = { }
_base_0.__index = _base_0 _base_0.__index = _base_0
local _class_0 = setmetatable({ _class_0 = setmetatable({
__init = function() end, __init = function() end,
__base = _base_0, __base = _base_0,
__name = "D" __name = "D"
@ -478,9 +493,10 @@ do
a.b.c.D = _class_0 a.b.c.D = _class_0
end end
do do
local _class_0
local _base_0 = { } local _base_0 = { }
_base_0.__index = _base_0 _base_0.__index = _base_0
local _class_0 = setmetatable({ _class_0 = setmetatable({
__init = function() end, __init = function() end,
__base = _base_0, __base = _base_0,
__name = "hello" __name = "hello"
@ -498,13 +514,14 @@ do
a.b["hello"] = _class_0 a.b["hello"] = _class_0
end end
do do
local _class_0
local _parent_0 = Hello.World local _parent_0 = Hello.World
local _base_0 = { } local _base_0 = { }
_base_0.__index = _base_0 _base_0.__index = _base_0
setmetatable(_base_0, _parent_0.__base) setmetatable(_base_0, _parent_0.__base)
local _class_0 = setmetatable({ _class_0 = setmetatable({
__init = function(self, ...) __init = function(self, ...)
return self.__class.__parent.__init(self, ...) return _class_0.__parent.__init(self, ...)
end, end,
__base = _base_0, __base = _base_0,
__name = "Something", __name = "Something",
@ -539,9 +556,10 @@ do
end end
local a local a
do do
local _class_0
local _base_0 = { } local _base_0 = { }
_base_0.__index = _base_0 _base_0.__index = _base_0
local _class_0 = setmetatable({ _class_0 = setmetatable({
__init = function() end, __init = function() end,
__base = _base_0, __base = _base_0,
__name = "a" __name = "a"
@ -559,9 +577,10 @@ end
local b local b
local Something local Something
do do
local _class_0
local _base_0 = { } local _base_0 = { }
_base_0.__index = _base_0 _base_0.__index = _base_0
local _class_0 = setmetatable({ _class_0 = setmetatable({
__init = function() end, __init = function() end,
__base = _base_0, __base = _base_0,
__name = "Something" __name = "Something"
@ -579,13 +598,14 @@ do
end end
local c local c
do do
local _class_0
local _parent_0 = Hello local _parent_0 = Hello
local _base_0 = { } local _base_0 = { }
_base_0.__index = _base_0 _base_0.__index = _base_0
setmetatable(_base_0, _parent_0.__base) setmetatable(_base_0, _parent_0.__base)
local _class_0 = setmetatable({ _class_0 = setmetatable({
__init = function(self, ...) __init = function(self, ...)
return self.__class.__parent.__init(self, ...) return _class_0.__parent.__init(self, ...)
end, end,
__base = _base_0, __base = _base_0,
__name = "Something", __name = "Something",
@ -617,13 +637,14 @@ do
end end
local d local d
do do
local _class_0
local _parent_0 = World local _parent_0 = World
local _base_0 = { } local _base_0 = { }
_base_0.__index = _base_0 _base_0.__index = _base_0
setmetatable(_base_0, _parent_0.__base) setmetatable(_base_0, _parent_0.__base)
local _class_0 = setmetatable({ _class_0 = setmetatable({
__init = function(self, ...) __init = function(self, ...)
return self.__class.__parent.__init(self, ...) return _class_0.__parent.__init(self, ...)
end, end,
__base = _base_0, __base = _base_0,
__name = "d", __name = "d",
@ -655,9 +676,10 @@ end
print(((function() print(((function()
local WhatsUp local WhatsUp
do do
local _class_0
local _base_0 = { } local _base_0 = { }
_base_0.__index = _base_0 _base_0.__index = _base_0
local _class_0 = setmetatable({ _class_0 = setmetatable({
__init = function() end, __init = function() end,
__base = _base_0, __base = _base_0,
__name = "WhatsUp" __name = "WhatsUp"
@ -675,9 +697,10 @@ print(((function()
end end
end)()).__name) end)()).__name)
do do
local _class_0
local _base_0 = { } local _base_0 = { }
_base_0.__index = _base_0 _base_0.__index = _base_0
local _class_0 = setmetatable({ _class_0 = setmetatable({
__init = function() end, __init = function() end,
__base = _base_0, __base = _base_0,
__name = "Something" __name = "Something"
@ -695,10 +718,11 @@ do
Something = _class_0 Something = _class_0
end end
do do
local _class_0
local val, insert local val, insert
local _base_0 = { } local _base_0 = { }
_base_0.__index = _base_0 _base_0.__index = _base_0
local _class_0 = setmetatable({ _class_0 = setmetatable({
__init = function(self) __init = function(self)
return print(insert, val) return print(insert, val)
end, end,
@ -719,9 +743,10 @@ do
Something = _class_0 Something = _class_0
end end
do do
local _class_0
local _base_0 = { } local _base_0 = { }
_base_0.__index = _base_0 _base_0.__index = _base_0
local _class_0 = setmetatable({ _class_0 = setmetatable({
__init = hi, __init = hi,
__base = _base_0, __base = _base_0,
__name = "X" __name = "X"

View File

@ -4,11 +4,12 @@ do
end end
do do
do do
local _class_0
local _base_0 = { local _base_0 = {
umm = "cool" umm = "cool"
} }
_base_0.__index = _base_0 _base_0.__index = _base_0
local _class_0 = setmetatable({ _class_0 = setmetatable({
__init = function() end, __init = function() end,
__base = _base_0, __base = _base_0,
__name = "Something" __name = "Something"