Skip to content

Commit

Permalink
[js] Make bootstrapped nqp-js run code correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
pmurias committed Jul 24, 2017
1 parent 53618db commit a3c3003
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/vm/js/Compiler.nqp
Expand Up @@ -1499,10 +1499,14 @@ class QAST::CompilerJS does DWIMYNameMangling does SerializeOnce {
my str $set_hll := $*HLL ?? "nqp.setCodeRefHLL(cuids, {quote_string($*HLL)});\n" !! '';

my $set_code_objects := self.set_code_objects;
my @setup := ["module.exports = nqp.run(async function() \{\n", $pre , $comp_mode ?? self.create_sc($node) !! '', $set_code_objects, self.declare_js_vars($*BLOCK.tmps), self.declare_js_vars($*BLOCK.js_lexicals), self.capture_inners($*BLOCK), self.clone_inners($*BLOCK), $set_hll, $post, $body, "\});\n"];
my @setup := [$pre , $comp_mode ?? self.create_sc($node) !! '', $set_code_objects, self.declare_js_vars($*BLOCK.tmps), self.declare_js_vars($*BLOCK.js_lexicals), self.capture_inners($*BLOCK), self.clone_inners($*BLOCK), $set_hll, $post, $body];
if !$instant {
@setup.push('return ');
@setup.push("new nqp.EvalResult({$body.expr}, nqp.createArray(cuids))");
}

@setup.unshift((!$instant ?? '' !! "module.exports = ") ~ "nqp.run(async function() \{\n");
@setup.push("\});\n");
Chunk.new($T_VOID, "", @setup);
}

Expand Down

0 comments on commit a3c3003

Please sign in to comment.