Skip to content

Commit ae2558a

Browse files
committed
rebuild specs and code
1 parent 66d80ed commit ae2558a

File tree

3 files changed

+120
-53
lines changed

3 files changed

+120
-53
lines changed

moonscript/transform.lua

Lines changed: 50 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ with_continue_listener = function(body)
171171
}
172172
end
173173
do
174+
local _class_0
174175
local _base_0 = {
175176
transform_once = function(self, scope, node, ...)
176177
if self.seen_nodes[node] then
@@ -217,7 +218,7 @@ do
217218
end
218219
}
219220
_base_0.__index = _base_0
220-
local _class_0 = setmetatable({
221+
_class_0 = setmetatable({
221222
__init = function(self, transformers)
222223
self.transformers = transformers
223224
self.seen_nodes = setmetatable({ }, {
@@ -1000,7 +1001,35 @@ Statement = Transformer({
10001001
"nil"
10011002
},
10021003
["then"] = {
1003-
parent_cls_name:index("name")
1004+
build.assign_one(LocalName("parent"), build.chain({
1005+
base = "rawget",
1006+
{
1007+
"call",
1008+
{
1009+
{
1010+
"ref",
1011+
"cls"
1012+
},
1013+
{
1014+
"string",
1015+
'"',
1016+
"__parent"
1017+
}
1018+
}
1019+
}
1020+
})),
1021+
build["if"]({
1022+
cond = LocalName("parent"),
1023+
["then"] = {
1024+
build.chain({
1025+
base = LocalName("parent"),
1026+
{
1027+
"index",
1028+
"name"
1029+
}
1030+
})
1031+
}
1032+
})
10041033
}
10051034
})
10061035
insert(class_lookup, {
@@ -1098,18 +1127,23 @@ Statement = Transformer({
10981127
self:put_name(name)
10991128
end
11001129
return self:set("super", function(block, chain)
1130+
local relative_parent = {
1131+
"chain",
1132+
cls_name,
1133+
{
1134+
"dot",
1135+
"__parent"
1136+
}
1137+
}
11011138
if chain then
11021139
local chain_tail = {
11031140
unpack(chain, 3)
11041141
}
1105-
local new_chain = {
1106-
"chain",
1107-
parent_cls_name
1108-
}
11091142
local head = chain_tail[1]
11101143
if head == nil then
1111-
return parent_cls_name
1144+
return relative_parent
11121145
end
1146+
local new_chain = relative_parent
11131147
local _exp_1 = head[1]
11141148
if "call" == _exp_1 then
11151149
local calling_name = block:get("current_block")
@@ -1153,10 +1187,16 @@ Statement = Transformer({
11531187
end
11541188
return new_chain
11551189
else
1156-
return parent_cls_name
1190+
return relative_parent
11571191
end
11581192
end)
11591193
end),
1194+
{
1195+
"declare",
1196+
{
1197+
cls_name
1198+
}
1199+
},
11601200
{
11611201
"declare_glob",
11621202
"*"
@@ -1240,6 +1280,7 @@ Statement = Transformer({
12401280
end
12411281
})
12421282
do
1283+
local _class_0
12431284
local _base_0 = {
12441285
body_idx = {
12451286
["for"] = 4,
@@ -1300,7 +1341,7 @@ do
13001341
end
13011342
}
13021343
_base_0.__index = _base_0
1303-
local _class_0 = setmetatable({
1344+
_class_0 = setmetatable({
13041345
__init = function(self, accum_name)
13051346
self.accum_name = NameProxy("accum")
13061347
self.value_name = NameProxy("value")

0 commit comments

Comments
 (0)