Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
unbust >1600 parrot spectest failures introduces by 9515bb7
This patch does not really fix the issue on parrot, it just fudges
the by the patch changed lines so these will only be made ative for
jvm and moar.
Sidenote: proto prefix:<+^>($?, $?) and proto prefix:<~^>($?, $?)
were changed to take precisely one argument, since these are prefixes.
  • Loading branch information
FROGGS committed Aug 4, 2014
1 parent b17a24b commit cf544ab
Show file tree
Hide file tree
Showing 4 changed files with 192 additions and 2 deletions.
15 changes: 15 additions & 0 deletions src/core/Any.pm
Expand Up @@ -346,17 +346,32 @@ my class Any { # declared in BOOTSTRAP
Metamodel::ClassHOW.exclude_parent(Any);

# builtin ops
#?if parrot
proto infix:<===>($?, $?) is pure { * }
#?endif
#?if !parrot
proto infix:<===>(Mu $?, Mu $?) is pure { * }
#?endif
multi infix:<===>($?) { Bool::True }
multi infix:<===>($a, $b) {
nqp::p6bool(nqp::iseq_s(nqp::unbox_s($a.WHICH), nqp::unbox_s($b.WHICH)))
}

#?if parrot
proto infix:<before>($, $?) is pure { * }
#?endif
#?if !parrot
proto infix:<before>(Mu $, Mu $?) is pure { * }
#?endif
multi infix:<before>($?) { Bool::True }
multi infix:<before>(\a, \b) { (a cmp b) < 0 }

#?if parrot
proto infix:<after>($, $?) is pure { * }
#?endif
#?if !parrot
proto infix:<after>(Mu $, Mu $?) is pure { * }
#?endif
multi infix:<after>($x?) { Bool::True }
multi infix:<after>(\a, \b) { (a cmp b) > 0 }

Expand Down
112 changes: 111 additions & 1 deletion src/core/Numeric.pm
Expand Up @@ -181,109 +181,219 @@ multi sub round($a) { $a.Numeric.round }
multi sub round(Numeric $a) { $a.round }
multi sub round(Numeric $a, $scale) { $a.round($scale) }

#?if parrot
proto infix:<+>($?, $?) is pure { * }
#?endif
#?if !parrot
proto infix:<+>(Mu $?, Mu $?) is pure { * }
#?endif
multi infix:<+>($x = 0) { $x.Numeric }
multi infix:<+>(\a, \b) { a.Numeric + b.Numeric }

#?if parrot
proto infix:<->($?, $?) is pure { * }
#?endif
#?if !parrot
proto infix:<->(Mu $?, Mu $?) is pure { * }
#?endif
multi infix:<->($x = 0) { $x.Numeric }
multi infix:<->(\a, \b) { a.Numeric - b.Numeric }

#?if parrot
proto infix:<*>($?, $?) is pure { * }
#?endif
#?if !parrot
proto infix:<*>(Mu $?, Mu $?) is pure { * }
#?endif
multi infix:<*>($x = 1) { $x.Numeric }
multi infix:<*>(\a, \b) { a.Numeric * b.Numeric }

#?if parrot
proto infix:</>($?, $?) { * }
#?endif
#?if !parrot
proto infix:</>(Mu $?, Mu $?) { * }
#?endif
multi infix:</>() { fail "No zero-arg meaning for infix:</>" }
multi infix:</>($x) { $x.Numeric }
multi infix:</>(\a, \b) { a.Numeric / b.Numeric }

#?if parrot
proto infix:<div>($?, $?) is pure { * }
#?endif
#?if !parrot
proto infix:<div>(Mu $?, Mu $?) is pure { * }
#?endif
# rest of infix:<div> is in Int.pm

#?if parrot
proto infix:<%>($?, $?) is pure { * }
#?endif
#?if !parrot
proto infix:<%>(Mu $?, Mu $?) is pure { * }
#?endif
multi infix:<%>() { fail "No zero-arg meaning for infix:<%>" }
multi infix:<%>($x) { $x }
multi infix:<%>(\a, \b) { a.Real % b.Real }

#?if parrot
proto infix:<%%>($?, $?) is pure { * }
#?endif
#?if !parrot
proto infix:<%%>(Mu $?, Mu $?) is pure { * }
#?endif
multi infix:<%%>() { fail "No zero-arg meaning for infix:<%%>" }
multi infix:<%%>($) { Bool::True }
multi infix:<%%>(\a, \b) {
fail X::Numeric::DivideByZero.new(using => 'infix:<%%>') unless b;
a.Real % b.Real == 0;
}

#?if parrot
proto infix:<lcm>($?, $?) is pure { * }
#?endif
#?if !parrot
proto infix:<lcm>(Mu $?, Mu $?) is pure { * }
#?endif
multi infix:<lcm>(Int $x = 1) { $x }
multi infix:<lcm>(\a, \b) { a.Int lcm b.Int }

#?if parrot
proto infix:<gcd>($?, $?) is pure { * }
#?endif
#?if !parrot
proto infix:<gcd>(Mu $?, Mu $?) is pure { * }
#?endif
multi infix:<gcd>() { fail 'No zero-arg meaning for infix:<gcd>' }
multi infix:<gcd>(Int $x) { $x }
multi infix:<gcd>(\a, \b) { a.Int gcd b.Int }

#?if parrot
proto infix:<**>($?, $?) is pure { * }
#?endif
#?if !parrot
proto infix:<**>(Mu $?, Mu $?) is pure { * }
#?endif
multi infix:<**>($x = 1) { $x.Numeric }
multi infix:<**>(\a, \b) { a.Numeric ** b.Numeric }

## relational operators

#?if parrot
proto infix:«<=>»($?, $?) is pure { * }
#?endif
#?if !parrot
proto infix:«<=>»(Mu $, Mu $?) is pure { * }
#?endif
multi infix:«<=>»(\a, \b) { a.Real <=> b.Real }

#?if parrot
proto infix:<==>($?, $?) is pure { * }
#?endif
#?if !parrot
proto infix:<==>(Mu $?, Mu $?) is pure { * }
#?endif
multi infix:<==>($?) { Bool::True }
multi infix:<==>(\a, \b) { a.Numeric == b.Numeric }

proto infix:<!=>(Mu $?, Mu $?) is pure { * }
multi infix:<!=>($?) { Bool::True }
multi infix:<!=>(Mu \a, Mu \b) { not a == b }

#?if parrot
proto infix:«<»($?, $?) is pure { * }
#?endif
#?if !parrot
proto infix:«<»(Mu $?, Mu $?) is pure { * }
#?endif
multi infix:«<»($?) { Bool::True }
multi infix<»(\a, \b) { a.Real < b.Real }

#?if parrot
proto infix:«<=»($?, $?) is pure { * }
#?endif
#?if !parrot
proto infix:«<=»(Mu $?, Mu $?) is pure { * }
#?endif
multi infix:«<=»($?) { Bool::True }
multi infix<=»(\a, \b) { a.Real <= b.Real }

#?if parrot
proto infix:«>»($?, $?) is pure { * }
#?endif
#?if !parrot
proto infix:«>»(Mu $?, Mu $?) is pure { * }
#?endif
multi infix:«>»($?) { Bool::True }
multi infix>»(\a, \b) { a.Real > b.Real }

#?if parrot
proto infix:«>=»($?, $?) is pure { * }
#?endif
#?if !parrot
proto infix:«>=»(Mu $?, Mu $?) is pure { * }
#?endif
multi infix:«>=»($?) { Bool::True }
multi infix>=»(\a, \b) { a.Real >= b.Real }

## bitwise operators

#?if parrot
proto infix:<+&>($?, $?) is pure { * }
#?endif
#?if !parrot
proto infix:<+&>(Mu $?, Mu $?) is pure { * }
#?endif
multi infix:<+&>() { +^0 }
multi infix:<+&>($x) { $x }
multi infix:<+&>($x, $y) { $x.Numeric.Int +& $y.Numeric.Int }

#?if parrot
proto infix:<+|>($?, $?) is pure { * }
#?endif
#?if !parrot
proto infix:<+|>(Mu $?, Mu $?) is pure { * }
#?endif
multi infix:<+|>() { 0 }
multi infix:<+|>($x) { $x }
multi infix:<+|>($x, $y) { $x.Numeric.Int +| $y.Numeric.Int }

#?if parrot
proto infix:<+^>($?, $?) is pure { * }
#?endif
#?if !parrot
proto infix:<+^>(Mu $?, Mu $?) is pure { * }
#?endif
multi infix:<+^>() { 0 }
multi infix:<+^>($x) { $x }
multi infix:<+^>($x, $y) { $x.Numeric.Int +^ $y.Numeric.Int }

#?if parrot
proto infix:«+<»($?, $?) is pure { * }
#?endif
#?if !parrot
proto infix:«+<»(Mu $?, Mu $?) is pure { * }
#?endif
multi infix:«+<»() { fail "No zero-arg meaning for infix:«+<»"; }
multi infix+<»($x) { $x }
multi infix+<»($x,$y) { $x.Numeric.Int +< $y.Numeric.Int }

#?if parrot
proto infix:«+>»($?, $?) is pure { * }
#?endif
#?if !parrot
proto infix:«+>»(Mu $?, Mu $?) is pure { * }
#?endif
multi infix:«+>»() { fail "No zero-arg meaning for infix:«+>»"; }
multi infix+>»($x) { $x }
multi infix+>»($x,$y) { $x.Numeric.Int +> $y.Numeric.Int }

proto prefix:<+^>(Mu $?, Mu $?) is pure { * }
#?if parrot
proto prefix:<+^>($) is pure { * }
#?endif
#?if !parrot
proto prefix:<+^>(Mu $) is pure { * }
#?endif
multi prefix:<+^>($x) { +^ $x.Numeric.Int }

# vim: ft=perl6 expandtab sw=4
5 changes: 5 additions & 0 deletions src/core/Order.pm
Expand Up @@ -8,7 +8,12 @@ sub ORDER(int $i) {
$i == 0 ?? Same !! $i < 0 ?? Less !! More
}

#?if parrot
proto infix:<cmp>($, $) { * }
#?endif
#?if !parrot
proto infix:<cmp>(Mu $, Mu $) { * }
#?endif
multi infix:<cmp>(\a, \b) {
return Order::Less if a === -Inf || b === Inf;
return Order::More if a === Inf || b === -Inf;
Expand Down
62 changes: 61 additions & 1 deletion src/core/Stringy.pm
Expand Up @@ -7,56 +7,116 @@ multi sub infix:<eqv>(Stringy:D $a, Stringy:D $b) {
proto prefix:<~>($) is pure { * }
multi prefix:<~>(\a) { a.Stringy }

#?if parrot
proto infix:<~>($?, $?) is pure { * }
#?endif
#?if !parrot
proto infix:<~>(Mu $?, Mu $?) is pure { * }
#?endif
multi infix:<~>($x = '') { $x.Stringy }
multi infix:<~>(\a, \b) { a.Stringy ~ b.Stringy }

#?if parrot
proto infix:<x>($?, $?) { * }
#?endif
#?if !parrot
proto infix:<x>(Mu $?, Mu $?) { * }
#?endif
multi infix:<x>() { fail "No zero-arg meaning for infix:<x>" }
multi infix:<x>($x) { $x.Stringy }
multi infix:<x>($s, $n) { $s.Stringy x ($n.Int // 0) }

#?if parrot
proto infix:<leg>($?, $?) is pure { * }
#?endif
#?if !parrot
proto infix:<leg>(Mu $?, Mu $?) is pure { * }
#?endif
multi infix:<leg>(\a, \b) { a.Stringy cmp b.Stringy }

#?if parrot
proto infix:<eq>($?, $?) is pure { * }
#?endif
#?if !parrot
proto infix:<eq>(Mu $?, Mu $?) is pure { * }
#?endif
multi infix:<eq>($x?) { Bool::True }
multi infix:<eq>(\a, \b) { a.Stringy eq b.Stringy }

proto infix:<ne>(Mu $?, Mu $?) is pure { * }
multi infix:<ne>($x?) { Bool::True }
multi infix:<ne>(Mu \a, Mu \b) { a !eq b }

#?if parrot
proto infix:<lt>($?, $?) is pure { * }
#?endif
#?if !parrot
proto infix:<lt>(Mu $?, Mu $?) is pure { * }
#?endif
multi infix:<lt>($x?) { Bool::True }
multi infix:<lt>(\a, \b) { a.Stringy lt b.Stringy }

#?if parrot
proto infix:<le>($?, $?) is pure { * }
#?endif
#?if !parrot
proto infix:<le>(Mu $?, Mu $?) is pure { * }
#?endif
multi infix:<le>($x?) { Bool::True }
multi infix:<le>(\a, \b) { a.Stringy le b.Stringy }

#?if parrot
proto infix:<gt>($?, $?) is pure { * }
#?endif
#?if !parrot
proto infix:<gt>(Mu $?, Mu $?) is pure { * }
#?endif
multi infix:<gt>($x?) { Bool::True }
multi infix:<gt>(\a, \b) { a.Stringy gt b.Stringy }

#?if parrot
proto infix:<ge>($?, $?) is pure { * }
#?endif
#?if !parrot
proto infix:<ge>(Mu $?, Mu $?) is pure { * }
#?endif
multi infix:<ge>($x?) { Bool::True }
multi infix:<ge>(\a, \b) { a.Stringy ge b.Stringy }

#?if parrot
proto infix:<~|>($?, $?) is pure { * }
#?endif
#?if !parrot
proto infix:<~|>(Mu $?, Mu $?) is pure { * }
#?endif
multi infix:<~|>($x = '') { $x.Stringy }
multi infix:<~|>(\a, \b) { a.Stringy ~| b.Stringy }

#?if parrot
proto infix:<~^>($?, $?) is pure { * }
#?endif
#?if !parrot
proto infix:<~^>(Mu $?, Mu $?) is pure { * }
#?endif
multi infix:<~^>($x = '') { $x.Stringy }
multi infix:<~^>(\a, \b) { a.Stringy ~^ b.Stringy }

#?if parrot
proto infix:<~&>($?, $?) is pure { * }
#?endif
#?if !parrot
proto infix:<~&>(Mu $?, Mu $?) is pure { * }
#?endif
multi infix:<~&>() { fail "No zero-arg meaning for infix:<~&>" }
multi infix:<~&>($x) { $x.Stringy }
multi infix:<~&>(\a, \b) { a.Stringy ~& b.Stringy }

proto prefix:<~^>(Mu $?, Mu $?) is pure { * }
#?if parrot
proto prefix:<~^>($) is pure { * }
#?endif
#?if !parrot
proto prefix:<~^>(Mu $) is pure { * }
#?endif
multi prefix:<~^>(\a) { ~^ a.Stringy }

# vim: ft=perl6 expandtab sw=4

0 comments on commit cf544ab

Please sign in to comment.