Skip to content

Commit d73c0a1

Browse files
committed
unindent super code
1 parent d91fbbe commit d73c0a1

File tree

1 file changed

+49
-44
lines changed

1 file changed

+49
-44
lines changed

moonscript/transform.moon

Lines changed: 49 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -684,49 +684,48 @@ Statement = Transformer {
684684
{"dot", "__parent"}
685685
}
686686

687-
if chain
688-
chain_tail = { unpack chain, 3 }
689-
head = chain_tail[1]
690-
691-
if head == nil
692-
return relative_parent
693-
694-
new_chain = relative_parent
695-
696-
switch head[1]
697-
-- calling super, inject calling name and self into chain
698-
when "call"
699-
calling_name = block\get"current_block"
700-
chain_tail[1] = {"call", {"self", unpack head[2]}}
701-
702-
if ntype(calling_name) == "key_literal"
703-
insert new_chain, {"dot", calling_name[2]}
704-
else
705-
insert new_chain, {"index", calling_name}
706-
707-
-- colon call on super, replace class with self as first arg
708-
when "colon"
709-
call = chain_tail[2]
710-
-- calling chain tail
711-
if call and call[1] == "call"
712-
chain_tail[1] = {
713-
"dot"
714-
head[2]
687+
return relative_parent unless chain
688+
689+
chain_tail = { unpack chain, 3 }
690+
head = chain_tail[1]
691+
692+
if head == nil
693+
return relative_parent
694+
695+
new_chain = relative_parent
696+
697+
switch head[1]
698+
-- calling super, inject calling name and self into chain
699+
when "call"
700+
calling_name = block\get"current_block"
701+
assert calling_name, "missing calling name"
702+
chain_tail[1] = {"call", {"self", unpack head[2]}}
703+
704+
if ntype(calling_name) == "key_literal"
705+
insert new_chain, {"dot", calling_name[2]}
706+
else
707+
insert new_chain, {"index", calling_name}
708+
709+
-- colon call on super, replace class with self as first arg
710+
when "colon"
711+
call = chain_tail[2]
712+
-- calling chain tail
713+
if call and call[1] == "call"
714+
chain_tail[1] = {
715+
"dot"
716+
head[2]
717+
}
718+
719+
chain_tail[2] = {
720+
"call"
721+
{
722+
"self"
723+
unpack call[2]
715724
}
725+
}
716726

717-
chain_tail[2] = {
718-
"call"
719-
{
720-
"self"
721-
unpack call[2]
722-
}
723-
}
724-
725-
insert new_chain, item for item in *chain_tail
726-
727-
new_chain
728-
else
729-
relative_parent
727+
insert new_chain, item for item in *chain_tail
728+
new_chain
730729

731730
{"declare", { cls_name }}
732731
{"declare_glob", "*"}
@@ -939,9 +938,15 @@ Value = Transformer {
939938

940939
node
941940

942-
if: (node) => build.block_exp { node }
943-
unless: (node) =>build.block_exp { node }
944-
with: (node) => build.block_exp { node }
941+
if: (node) =>
942+
build.block_exp { node }
943+
944+
unless: (node) =>
945+
build.block_exp { node }
946+
947+
with: (node) =>
948+
build.block_exp { node }
949+
945950
switch: (node) =>
946951
build.block_exp { node }
947952

0 commit comments

Comments
 (0)