Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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
jnthn committed Aug 22, 2010
1 parent 8876bee commit 10019ac
Showing 1 changed file with 42 additions and 15 deletions.
57 changes: 42 additions & 15 deletions common/NQP/NQPSetting.pm
Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down

0 comments on commit 10019ac

Please sign in to comment.