Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Move infix:<%>, infix:<div>, and infix:<mod> to the setting.
However, we don't actually implement infix:<div> or infix:<mod> yet,
so add dummy versions of those to NYI.pm for now so people know
what's going on.
  • Loading branch information
pmichaud committed Aug 28, 2009
1 parent f351f60 commit 7666e92
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 18 deletions.
1 change: 0 additions & 1 deletion build/gen_junction_pir.pl
Expand Up @@ -6,7 +6,6 @@
use warnings;

my @binary = qw(
infix:% infix:div infix:mod
infix:~
infix:== infix:< infix:> infix:<= infix:>=
infix:eq infix:lt infix:gt infix:le infix:ge
Expand Down
1 change: 0 additions & 1 deletion build/gen_whatever_pir.pl
Expand Up @@ -6,7 +6,6 @@
use warnings;

my @ops = qw(
infix:% infix:div infix:mod
infix:== infix:< infix:> infix:<= infix:>= infix:<=>
infix:.. infix:^.. infix:..^ infix:^..^
prefix:+ prefix:? prefix:! prefix:^
Expand Down
16 changes: 0 additions & 16 deletions src/builtins/op.pir
Expand Up @@ -136,22 +136,6 @@ src/builtins/op.pir - Perl 6 builtin operators
## TODO: prefix:= prefix:* prefix:** prefix:~^ prefix:+^


.sub 'infix:%' :multi(_,_)
.param num a
.param num b
$N0 = mod a, b
.return ($N0)
.end


.sub 'infix:%' :multi(Integer,Integer)
.param num a
.param num b
$N0 = mod a, b
.tailcall '!upgrade_to_num_if_needed'($N0)
.end


.sub 'infix:xx' :multi(_,_)
.param pmc a
.param int n
Expand Down
8 changes: 8 additions & 0 deletions src/setting/NYI.pm
Expand Up @@ -25,4 +25,12 @@ multi infix:«<<==» (*@a) {
die 'Feed operators are not yet implemented in Rakudo, sorry';
}

multi infix:<div>($a, $b) {
die 'infix:<div> not yet implemented in Rakudo, sorry';
}

multi infix:<mod>($a, $b) {
die 'infix:<mod> not yet implemented in Rakudo, sorry';
}

# vim: ft=perl6
22 changes: 22 additions & 0 deletions src/setting/Operators.pm
Expand Up @@ -182,6 +182,28 @@ multi sub infix:</>(Int $a, Int $b) {
}
}

multi sub infix:<%>($a, $b) {
Q:PIR {
$P0 = find_lex '$a'
$N0 = $P0
$P1 = find_lex '$b'
$N1 = $P1
$N2 = mod $N0, $N1
%r = box $N2
}
}
multi sub infix:<%>(Int $a, Int $b) {
Q:PIR {
$P0 = find_lex '$a'
$N0 = $P0
$P1 = find_lex '$b'
$N1 = $P1
$N2 = mod $N0, $N1
%r = '!upgrade_to_num_if_needed'($N2)
}
}
multi sub infix:<**>($a, $b) {
Q:PIR {
$P0 = find_lex '$a'
Expand Down
27 changes: 27 additions & 0 deletions src/setting/Whatever.pm
Expand Up @@ -53,6 +53,33 @@ multi sub infix:</>($a, Whatever $b)
multi sub infix:</>($a, Whatever $b)
{ WhateverCodeX('infix:/', $a, $b) }

multi sub infix:<%>(Whatever $a, $b) is default
{ WhateverCodeX('infix:%', $a, $b) }
multi sub infix:<%>(WhateverCode $a, $b) is default
{ WhateverCodeX('infix:%', $a, $b) }
multi sub infix:<%>($a, Whatever $b)
{ WhateverCodeX('infix:%', $a, $b) }
multi sub infix:<%>($a, Whatever $b)
{ WhateverCodeX('infix:%', $a, $b) }

multi sub infix:<div>(Whatever $a, $b) is default
{ WhateverCodeX('infix:div', $a, $b) }
multi sub infix:<div>(WhateverCode $a, $b) is default
{ WhateverCodeX('infix:div', $a, $b) }
multi sub infix:<div>($a, Whatever $b)
{ WhateverCodeX('infix:div', $a, $b) }
multi sub infix:<div>($a, Whatever $b)
{ WhateverCodeX('infix:div', $a, $b) }

multi sub infix:<mod>(Whatever $a, $b) is default
{ WhateverCodeX('infix:mod', $a, $b) }
multi sub infix:<mod>(WhateverCode $a, $b) is default
{ WhateverCodeX('infix:mod', $a, $b) }
multi sub infix:<mod>($a, Whatever $b)
{ WhateverCodeX('infix:mod', $a, $b) }
multi sub infix:<mod>($a, Whatever $b)
{ WhateverCodeX('infix:mod', $a, $b) }

multi sub infix:<**>(Whatever $a, $b) is default
{ WhateverCodeX('infix:**', $a, $b) }
multi sub infix:<**>(WhateverCode $a, $b) is default
Expand Down

0 comments on commit 7666e92

Please sign in to comment.