Navigation Menu

Skip to content

Commit

Permalink
Moved <, >, <=, and >= into the Setting
Browse files Browse the repository at this point in the history
In order for such a move to work, all declarations outside of the Setting
had to be removed. This includes the nice autogeneration of subs in
gen_whatever_pir, which unfortunately translates to eight quite similar
methods in the Setting. Improvements welcome.
  • Loading branch information
Carl Masak committed Sep 29, 2009
1 parent 9792a2e commit c8181aa
Show file tree
Hide file tree
Showing 5 changed files with 112 additions and 34 deletions.
2 changes: 1 addition & 1 deletion build/gen_junction_pir.pl
Expand Up @@ -7,7 +7,7 @@

my @binary = qw(
infix:~
infix:== infix:< infix:> infix:<= infix:>=
infix:==
infix:eq infix:lt infix:gt infix:le infix:ge
infix:<=> infix:cmp infix:=:=
);
Expand Down
2 changes: 1 addition & 1 deletion build/gen_whatever_pir.pl
Expand Up @@ -6,7 +6,7 @@
use warnings;

my @ops = qw(
infix:== infix:< infix:> infix:<= infix:>= infix:<=>
infix:== infix:<=>
infix:.. infix:^.. infix:..^ infix:^..^
prefix:+ prefix:? prefix:! prefix:^
);
Expand Down
32 changes: 0 additions & 32 deletions src/builtins/cmp.pir
Expand Up @@ -20,38 +20,6 @@ src/builtins/cmp.pir - Perl6 comparison builtins
.end


.sub 'infix:<' :multi(_,_)
.param num a
.param num b
$I0 = islt a, b
.tailcall 'prefix:?'($I0)
.end


.sub 'infix:<=' :multi(_,_)
.param num a
.param num b
$I0 = isle a, b
.tailcall 'prefix:?'($I0)
.end


.sub 'infix:>' :multi(_,_)
.param num a
.param num b
$I0 = isgt a, b
.tailcall 'prefix:?'($I0)
.end


.sub 'infix:>=' :multi(_,_)
.param num a
.param num b
$I0 = isge a, b
.tailcall 'prefix:?'($I0)
.end


.sub 'infix:<=>' :multi(_,_)
.param pmc a
.param pmc b
Expand Down
2 changes: 2 additions & 0 deletions src/setting/Any-num.pm
Expand Up @@ -171,3 +171,5 @@ our Num sub rand (*@args) {
die "too many arguments passed - 0 params expected" if @args;
1.rand
}


108 changes: 108 additions & 0 deletions src/setting/Operators.pm
Expand Up @@ -245,4 +245,112 @@ multi sub infix:<!==>($a, $b) { !($a == $b) }
multi sub infix:<ne>($a, $b) { !($a eq $b) }
multi sub infix:<!eq>($a, $b) { !($a eq $b) }

multi sub infix:<< < >>($a, $b) {
? Q:PIR {
$P0 = find_lex '$a'
$N0 = $P0
$P1 = find_lex '$b'
$N1 = $P1
$I0 = islt $N0, $N1
%r = box $I0
}
}
multi sub infix:<< > >>($a, $b) {
? Q:PIR {
$P0 = find_lex '$a'
$N0 = $P0
$P1 = find_lex '$b'
$N1 = $P1
$I0 = isgt $N0, $N1
%r = box $I0
}
}
multi sub infix:<< <= >>($a, $b) {
? Q:PIR {
$P0 = find_lex '$a'
$N0 = $P0
$P1 = find_lex '$b'
$N1 = $P1
$I0 = isle $N0, $N1
%r = box $I0
}
}
multi sub infix:<< >= >>($a, $b) {
? Q:PIR {
$P0 = find_lex '$a'
$N0 = $P0
$P1 = find_lex '$b'
$N1 = $P1
$I0 = isge $N0, $N1
%r = box $I0
}
}
multi sub infix:<< < >>(Whatever $a, $b) {
Q:PIR {
$P0 = find_lex '$a'
$P1 = find_lex '$b'
.tailcall 'WhateverCodeX'('infix:<', $P0, $P1)
}
}
multi sub infix:<< < >>($a, Whatever $b) {
Q:PIR {
$P0 = find_lex '$a'
$P1 = find_lex '$b'
.tailcall 'WhateverCodeX'('infix:<', $P0, $P1)
}
}

multi sub infix:<< > >>(Whatever $a, $b) {
Q:PIR {
$P0 = find_lex '$a'
$P1 = find_lex '$b'
.tailcall 'WhateverCodeX'('infix:>', $P0, $P1)
}
}
multi sub infix:<< > >>($a, Whatever $b) {
Q:PIR {
$P0 = find_lex '$a'
$P1 = find_lex '$b'
.tailcall 'WhateverCodeX'('infix:>', $P0, $P1)
}
}

multi sub infix:<< <= >>(Whatever $a, $b) {
Q:PIR {
$P0 = find_lex '$a'
$P1 = find_lex '$b'
.tailcall 'WhateverCodeX'('infix:<=', $P0, $P1)
}
}
multi sub infix:<< <= >>($a, Whatever $b) {
Q:PIR {
$P0 = find_lex '$a'
$P1 = find_lex '$b'
.tailcall 'WhateverCodeX'('infix:<=', $P0, $P1)
}
}

multi sub infix:<< >= >>(Whatever $a, $b) {
Q:PIR {
$P0 = find_lex '$a'
$P1 = find_lex '$b'
.tailcall 'WhateverCodeX'('infix:>=', $P0, $P1)
}
}
multi sub infix:<< >= >>($a, Whatever $b) {
Q:PIR {
$P0 = find_lex '$a'
$P1 = find_lex '$b'
.tailcall 'WhateverCodeX'('infix:>=', $P0, $P1)
}
}

# vim: ft=perl6

0 comments on commit c8181aa

Please sign in to comment.