Skip to content

Commit

Permalink
Move prefix:<-> into the setting.
Browse files Browse the repository at this point in the history
  • Loading branch information
pmichaud committed Aug 28, 2009
1 parent 4276205 commit 81d6216
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 26 deletions.
2 changes: 1 addition & 1 deletion build/gen_whatever_pir.pl
Expand Up @@ -9,7 +9,7 @@
infix:% infix:div infix:mod
infix:== infix:!= infix:< infix:> infix:<= infix:>= infix:<=>
infix:.. infix:^.. infix:..^ infix:^..^
prefix:+ prefix:- prefix:~ prefix:? prefix:! prefix:^
prefix:+ prefix:~ prefix:? prefix:! prefix:^
);

for (@ops) {
Expand Down
14 changes: 0 additions & 14 deletions src/builtins/op.pir
Expand Up @@ -122,20 +122,6 @@ src/builtins/op.pir - Perl 6 builtin operators
.end


.sub 'prefix:-' :multi(_)
.param num a
$N0 = neg a
.return ($N0)
.end


.sub 'prefix:-' :multi('Integer')
.param num a
$N0 = neg a
.tailcall '!upgrade_to_num_if_needed'($N0)
.end


.sub 'prefix:~' :multi(_)
.param string a
$P0 = new ['Str']
Expand Down
11 changes: 0 additions & 11 deletions src/classes/Complex.pir
Expand Up @@ -173,17 +173,6 @@ Casts a value to a complex number.
.return (a)
.end

=item prefix:-

=cut

.sub 'prefix:-' :multi('Complex')
.param pmc a
a = neg a
.return (a)
.end


=item re

=cut
Expand Down
8 changes: 8 additions & 0 deletions src/setting/Complex.pm
Expand Up @@ -87,4 +87,12 @@ multi sub infix:</>($a, Complex $b) {
}
multi sub prefix:<->(Complex $a) {
Q:PIR {
$P0 = find_lex '$a'
%r = neg $P0
}
}
# vim: ft=perl6
18 changes: 18 additions & 0 deletions src/setting/Operators.pm
Expand Up @@ -204,4 +204,22 @@ multi sub infix:<**>(Int $a, Int $b) {
}
}
multi sub prefix:<->($a) {
Q:PIR {
$P0 = find_lex '$a'
$N0 = $P0
$N0 = neg $N0
%r = box $N0
}
}
multi sub prefix:<->(Int $a) {
Q:PIR {
$P0 = find_lex '$a'
$N0 = $P0
$N0 = neg $N0
%r = '!upgrade_to_num_if_needed'($N0)
}
}
# vim: ft=perl6
5 changes: 5 additions & 0 deletions src/setting/Whatever.pm
Expand Up @@ -62,4 +62,9 @@ multi sub infix:<**>($a, Whatever $b)
multi sub infix:<**>($a, Whatever $b)
{ WhateverCodeX('infix:**', $a, $b) }

multi sub prefix:<->(Whatever $a)
{ WhateverCodeX('prefix:-', $a) }
multi sub prefix:<->(WhateverCode $a)
{ WhateverCodeX('prefix:-', $a) }

# vim: ft=perl6

0 comments on commit 81d6216

Please sign in to comment.