Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Set the code object for QAST::Blocks with a code_object attribute.
  • Loading branch information
pmurias committed Jan 24, 2015
1 parent 30951ea commit 566743a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/vm/js/QAST/Compiler.nqp
Expand Up @@ -1481,8 +1481,15 @@ class QAST::CompilerJS does DWIMYNameMangling does SerializeOnce {

my $sig := self.compile_sig($*BLOCK.params);

# Set code object, if any.
my $set_code_object := '';
my $code_obj := $node.code_object;
if nqp::isconcrete($code_obj) {
$set_code_object := ".setCodeObj({self.value_as_js($code_obj)})";
}

$setup := [
"$cuid.block(function({$sig.expr}) \{\n",
$cuid ~ $set_code_object ~ ".block(function({$sig.expr}) \{\n",
self.setup_setting($node),
self.declare_js_vars($*BLOCK.tmps),
self.declare_js_vars($*BLOCK.js_lexicals),
Expand Down
5 changes: 5 additions & 0 deletions src/vm/js/nqp-runtime/code-ref.js
Expand Up @@ -16,4 +16,9 @@ CodeRef.prototype.takeclosure = function() {
return closure;
};

CodeRef.prototype.setCodeObj = function(codeObj) {
this.codeObj = codeObj;
return this;
};

module.exports = CodeRef;

0 comments on commit 566743a

Please sign in to comment.