Skip to content

Commit

Permalink
[js] Implement nqp::p6var.
Browse files Browse the repository at this point in the history
  • Loading branch information
pmurias committed Oct 1, 2016
1 parent 936b5a5 commit 424d190
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/vm/js/Perl6/Ops.nqp
Expand Up @@ -74,3 +74,5 @@ $ops.add_simple_op('p6definite', $ops.OBJ, [$ops.OBJ], :decont(0));
$ops.add_simple_op('p6captureouters2', $ops.OBJ, [$ops.OBJ, $ops.OBJ], :ctx);
$ops.add_simple_op('p6captureouters', $ops.OBJ, [$ops.OBJ], :ctx);
$ops.add_simple_op('p6capturelex', $ops.OBJ, [$ops.OBJ], :ctx);

$ops.add_simple_op('p6var', $ops.OBJ, [$ops.OBJ], :sideffects); # TODO not really just needs marking as returning a fresh value
9 changes: 9 additions & 0 deletions src/vm/js/perl6-runtime/runtime.js
Expand Up @@ -103,6 +103,15 @@ op.p6capturelex = function(ctx, codeObj) {
return codeObj;
};

op.p6var = function(cont) {
if (cont != null && cont.$$iscont && cont.$$iscont()) {
var wrapper = Scalar._STable.REPR.allocate(Scalar._STable);
wrapper.$$bindattr(Scalar, '$!value', cont);
return wrapper;
} else {
return cont;
}
}

var containerSpecs = require('nqp-runtime/container-specs.js');

Expand Down

0 comments on commit 424d190

Please sign in to comment.