Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Pass test 18.
Implement QAST::VarWithFallback.
  • Loading branch information
pmurias committed Dec 3, 2014
1 parent c464545 commit 13785ed
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
16 changes: 16 additions & 0 deletions src/vm/js/QAST/Compiler.nqp
Expand Up @@ -1478,6 +1478,22 @@ class QAST::CompilerJS does DWIMYNameMangling does SerializeOnce {
self.compile_var($node);
}

multi method as_js(QAST::VarWithFallback $node, :$want) {
my $var := self.compile_var($node);
if $var.type == $T_OBJ {
my $fallback := self.as_js($node.fallback, :want($T_OBJ));
my $tmp := $*BLOCK.add_tmp();
Chunk.new($T_OBJ, $tmp, [
$var,
"if ({$var.expr} == null) \{\n"
,$fallback
,"$tmp = {$fallback.expr};\n\} else \{\n$tmp = {$var.expr};\n\}\n"
]);
} else {
$var;
}
}

method value_as_js($value) {
my $sc := nqp::getobjsc($value);
my $handle := nqp::scgethandle($sc);
Expand Down
2 changes: 1 addition & 1 deletion src/vm/js/bin/run_tests
@@ -1,5 +1,5 @@
#!/bin/bash
# 19 and 30 where moved out as they were parrot specific, 52,54 is missing, we can't pass 49 till we are bootstraped
#echo 'No tests pass as we are in the early stages of a rewrite/refactor'
prove -e './nqp-js' t/nqp/{01..17}* t/nqp/{20,22,23,25,26,36,37,38,40,41,42,46,48,53,59,63,68,81,83}* t/js/getcomp-js.t
prove -e './nqp-js' t/nqp/{01..18}* t/nqp/{20,22,23,25,26,36,37,38,40,41,42,46,48,53,59,63,68,81,83}* t/js/getcomp-js.t
#prove -e './nqp-js' t/nqp/{01..29}*.t t/nqp/{31..48}* t/nqp/{50,51,53}* t/nqp/{55..81}* t/nqp/83* t/serialization/0{2,3}*.t

0 comments on commit 13785ed

Please sign in to comment.