Skip to content

Commit

Permalink
[js] Unbox objects in a rakudo specific manner
Browse files Browse the repository at this point in the history
  • Loading branch information
pmurias committed Sep 25, 2017
1 parent 13950b7 commit e1fc825
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/vm/js/Perl6/Ops.nqp
Expand Up @@ -44,6 +44,10 @@ register_op_desugar('defor', -> $op {
));
});

$ops.add_hll_unbox('perl6', $ops.INT, 'getInt');
$ops.add_hll_unbox('perl6', $ops.NUM, 'getNum');
$ops.add_hll_unbox('perl6', $ops.STR, 'getStr');

# Signature binding related bits.

$ops.add_simple_op('p6setbinder', $ops.VOID, [$ops.OBJ], :side_effects, sub ($binder) {"nqp.p6binder = $binder"});
Expand Down
12 changes: 12 additions & 0 deletions src/vm/js/perl6-runtime/runtime.js
Expand Up @@ -409,6 +409,18 @@ module.exports.load = function(nqp, CodeRef, Capture, containerSpecs) {
return this.$$getattr(Scalar, '$!value');
});

this.STable.addInternalMethod('$$getInt', function(ctx) {
return this.$$getattr(Scalar, '$!value').$$getInt();
});

this.STable.addInternalMethod('$$getStr', function(ctx) {
return this.$$getattr(Scalar, '$!value').$$getStr();
});

this.STable.addInternalMethod('$$getNum', function(ctx) {
return this.$$getattr(Scalar, '$!value').$$getNum();
});

this.STable.addInternalMethod('$$iscont', function() {
return 1;
});
Expand Down

0 comments on commit e1fc825

Please sign in to comment.