Skip to content

Commit 48fd5f9

Browse files
committed
[js] Support .resultchild on QAST::Stmt and QAST::Stmts. Implement having multiple children for QAST::Stmt.
1 parent d32f936 commit 48fd5f9

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/vm/js/Compiler.nqp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -741,10 +741,14 @@ class QAST::CompilerJS does DWIMYNameMangling does SerializeOnce {
741741
}
742742
}
743743

744-
method compile_all_the_statements(QAST::Stmts $node, $want, :$result_child = +$node.list -1, :$cps) {
744+
method compile_all_the_statements(QAST::Stmts $node, $want, :$result_child, :$cps) {
745745
my @chunks;
746746
my @stmts := $node.list;
747747

748+
unless nqp::defined($result_child) {
749+
$result_child := +$node.list - 1;
750+
}
751+
748752
my $i := 0;
749753
for @stmts -> $stmt {
750754
my $chunk := self.as_js(@stmts[$i], :want($i == $result_child ?? $want !! $T_VOID), :$cps);
@@ -1186,7 +1190,7 @@ class QAST::CompilerJS does DWIMYNameMangling does SerializeOnce {
11861190
# Helps with register allocation on other backends
11871191
# We don't do allocate registers so just ignore that
11881192
multi method as_js(QAST::Stmt $node, :$want, :$cps) {
1189-
self.as_js($node[0], :$want, :$cps);
1193+
self.compile_all_the_statements($node, $want, :$cps, :result_child($node.resultchild));
11901194
}
11911195

11921196
multi method as_js(QAST::Stmts $node, :$want, :$cps) {
@@ -1210,7 +1214,7 @@ class QAST::CompilerJS does DWIMYNameMangling does SerializeOnce {
12101214
Chunk.void("nqp.ctxsave(\{{nqp::join(',', @lexicals)}\});\n");
12111215
}
12121216
else {
1213-
self.compile_all_the_statements($node, $want, :$cps);
1217+
self.compile_all_the_statements($node, $want, :$cps, :result_child($node.resultchild));
12141218
}
12151219
}
12161220

0 commit comments

Comments
 (0)