Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Start to add multi variants to the NQPSetting. Seems that even though…

… we've no inlining or caching, we still manage to win over the coercions from before.
  • Loading branch information...
commit 10019acd6c3713b3b742cc2063e36c160aabfefb 1 parent 8876bee
@jnthn authored
Showing with 42 additions and 15 deletions.
  1. +42 −15 common/NQP/NQPSetting.pm
View
57 common/NQP/NQPSetting.pm
@@ -53,14 +53,26 @@ knowhow NQPList is repr('P6list') {
knowhow NQPArray is repr('P6list') {
}
-## XXX All of these should become multi when we can do that.
+## XXX Need coercive Any fallbacks too.
-sub &infix:<==>($x, $y) {
- nqp::equal_nums($x.Num, $y.Num)
+proto sub &infix:<==>($x, $y) {
+ nqp::multi_dispatch_over_lexical_candidates("&infix:<==>");
+}
+multi sub &infix:<==>(NQPInt $x, NQPInt $y) {
+ nqp::equal_ints($x, $y)
+}
+multi sub &infix:<==>(NQPNum $x, NQPNum $y) {
+ nqp::equal_nums($x, $y)
}
-sub &infix:<!=>($x, $y) {
- !nqp::equal_nums($x.Num, $y.Num)
+proto sub &infix:<!=>($x, $y) {
+ nqp::multi_dispatch_over_lexical_candidates("&infix:<!=>");
+}
+multi sub &infix:<!=>(NQPInt $x, NQPInt $y) {
+ !nqp::equal_ints($x, $y)
+}
+multi sub &infix:<!=>(NQPNum $x, NQPNum $y) {
+ !nqp::equal_nums($x, $y)
}
sub &infix:<eq>($x, $y) {
@@ -79,24 +91,39 @@ sub &prefix:<?>($x) {
$x.Bool
}
-sub &infix:<+>($x, $y) {
- nqp::add_int($x.Int, $y.Int);
+proto sub &infix:<+>($x, $y) {
+ nqp::multi_dispatch_over_lexical_candidates("&infix:<+>");
+}
+multi sub &infix:<+>(NQPInt $x, NQPInt $y) {
+ nqp::add_int($x, $y);
}
-sub &infix:<->($x, $y) {
- nqp::sub_int($x.Int, $y.Int);
+proto sub &infix:<->($x, $y) {
+ nqp::multi_dispatch_over_lexical_candidates("&infix:<->");
+}
+multi sub &infix:<->(NQPInt $x, NQPInt $y) {
+ nqp::sub_int($x, $y);
}
-sub &infix:<*>($x, $y) {
- nqp::mul_int($x.Int, $y.Int);
+proto sub &infix:<*>($x, $y) {
+ nqp::multi_dispatch_over_lexical_candidates("&infix:<*>");
+}
+multi sub &infix:<*>(NQPInt $x, NQPInt $y) {
+ nqp::mul_int($x, $y);
}
-sub &infix:</>($x, $y) {
- nqp::div_int($x.Int, $y.Int);
+proto sub &infix:</>($x, $y) {
+ nqp::multi_dispatch_over_lexical_candidates("&infix:</>");
+}
+multi sub &infix:</>(NQPInt $x, NQPInt $y) {
+ nqp::div_int($x, $y);
}
-sub &infix:<%>($x, $y) {
- nqp::mod_int($x.Int, $y.Int);
+proto sub &infix:<%>($x, $y) {
+ nqp::multi_dispatch_over_lexical_candidates("&infix:<%>");
+}
+multi sub &infix:<%>(NQPInt $x, NQPInt $y) {
+ nqp::mod_int($x, $y);
}
sub &infix:<~>($x, $y) {
Please sign in to comment.
Something went wrong with that request. Please try again.