-
-
Save timo/1805bb7bbbc6c2aa5140 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/vm/moar/QAST/QASTOperationsMAST.nqp b/src/vm/moar/QAST/QASTOperationsMAST.nqp | |
index 70f2480..05ed378 100644 | |
--- a/src/vm/moar/QAST/QASTOperationsMAST.nqp | |
+++ b/src/vm/moar/QAST/QASTOperationsMAST.nqp | |
@@ -2134,12 +2134,45 @@ add_getattr_op('getattr_i', 'getattrs_i', $MVM_reg_int64); | |
add_getattr_op('getattr_n', 'getattrs_n', $MVM_reg_num64); | |
add_getattr_op('getattr_s', 'getattrs_s', $MVM_reg_str); | |
+sub add_bindattr_op($name, $moarop, $want=$MVM_reg_obj) { | |
+ QAST::MASTOperations.add_core_op($name, -> $qastcomp, $op { | |
+ my $value_mast := $qastcomp.as_mast( :$want, $op[3] ); | |
+ if nqp::istype($op[2], QAST::SVal) { | |
+ $qastcomp.as_mast( :$want, | |
+ QAST::Stmts.new( :node($op.node), | |
+ QAST::Op.new( :op('bind'), | |
+ QAST::Var.new( | |
+ :name( $op[2].value ), :scope('attribute'), | |
+ $op[0], | |
+ QAST::Op.new( :op('decont'), $op[1]) | |
+ ), | |
+ $value_mast | |
+ ), | |
+ $value_mast ) | |
+ ) | |
+ } else { | |
+ $qastcomp.as_mast( :$want, | |
+ QAST::Stmts.new( :node($op.node), | |
+ QAST::VM.new( :$moarop, | |
+ $op[0], | |
+ QAST::Op.new( :op('decont'), $op[1] ), | |
+ $op[2], | |
+ $value_mast | |
+ ), | |
+ $value_mast | |
+ ) | |
+ ); | |
+ } | |
+ }) | |
+} | |
+ | |
+add_bindattr_op('bindattr', 'bindattrs_o'); | |
+add_bindattr_op('bindattr_i', 'bindattrs_i', $MVM_reg_int64); | |
+add_bindattr_op('bindattr_n', 'bindattrs_n', $MVM_reg_num64); | |
+add_bindattr_op('bindattr_s', 'bindattrs_s', $MVM_reg_str); | |
+ | |
QAST::MASTOperations.add_core_moarop_mapping('attrinited', 'attrinited', :decont(1)); | |
QAST::MASTOperations.add_core_moarop_mapping('hintfor', 'hintfor'); | |
-QAST::MASTOperations.add_core_moarop_mapping('bindattr', 'bindattrs_o', 3, :decont(1)); | |
-QAST::MASTOperations.add_core_moarop_mapping('bindattr_i', 'bindattrs_i', 3, :decont(1)); | |
-QAST::MASTOperations.add_core_moarop_mapping('bindattr_n', 'bindattrs_n', 3, :decont(1)); | |
-QAST::MASTOperations.add_core_moarop_mapping('bindattr_s', 'bindattrs_s', 3, :decont(1)); | |
QAST::MASTOperations.add_core_moarop_mapping('unbox_i', 'unbox_i', :decont(0)); | |
QAST::MASTOperations.add_core_moarop_mapping('unbox_n', 'unbox_n', :decont(0)); | |
QAST::MASTOperations.add_core_moarop_mapping('unbox_s', 'unbox_s', :decont(0)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment