rustc: Use coherence for operator overloading.

The only use of the old-style impls is now placement new.
This commit is contained in:
Patrick Walton
2012-07-27 19:32:42 -07:00
parent e6d2e49852
commit 93c2f5e0e4
23 changed files with 348 additions and 295 deletions

View File

@@ -31,7 +31,8 @@ import f32::num;
import f64::num;
import num::num;
import ops::{const, copy, send, owned};
import ops::{add, sub, mul, div, modulo, neg, bitops, index};
import ops::{add, sub, mul, div, modulo, neg, bitand, bitor, bitxor, shl};
import ops::{shr, index};
export path, option, some, none, unreachable;
export extensions;

View File

@@ -1,64 +1,96 @@
// Core operators and kinds.
#[cfg(notest)]
#[lang="const"]
trait const {
// Empty.
}
#[cfg(notest)]
#[lang="copy"]
trait copy {
// Empty.
}
#[cfg(notest)]
#[lang="send"]
trait send {
// Empty.
}
#[cfg(notest)]
#[lang="owned"]
trait owned {
// Empty.
}
#[cfg(notest)]
#[lang="add"]
trait add<RHS,Result> {
pure fn add(rhs: RHS) -> Result;
}
#[cfg(notest)]
#[lang="sub"]
trait sub<RHS,Result> {
pure fn sub(rhs: RHS) -> Result;
}
#[cfg(notest)]
#[lang="mul"]
trait mul<RHS,Result> {
pure fn mul(rhs: RHS) -> Result;
}
#[cfg(notest)]
#[lang="div"]
trait div<RHS,Result> {
pure fn div(rhs: RHS) -> Result;
}
#[cfg(notest)]
#[lang="modulo"]
trait modulo<RHS,Result> {
pure fn modulo(rhs: RHS) -> Result;
}
#[cfg(notest)]
#[lang="neg"]
trait neg<RHS,Result> {
pure fn neg(rhs: RHS) -> Result;
trait neg<Result> {
pure fn neg() -> Result;
}
#[lang="bitops"]
trait bitops<RHS,BitCount,Result> {
pure fn and(rhs: RHS) -> Result;
pure fn or(rhs: RHS) -> Result;
pure fn xor(rhs: RHS) -> Result;
pure fn shl(n: BitCount) -> Result;
pure fn shr(n: BitCount) -> Result;
#[cfg(notest)]
#[lang="bitand"]
trait bitand<RHS,Result> {
pure fn bitand(rhs: RHS) -> Result;
}
#[cfg(notest)]
#[lang="bitor"]
trait bitor<RHS,Result> {
pure fn bitor(rhs: RHS) -> Result;
}
#[cfg(notest)]
#[lang="bitxor"]
trait bitxor<RHS,Result> {
pure fn bitxor(rhs: RHS) -> Result;
}
#[cfg(notest)]
#[lang="shl"]
trait shl<RHS,Result> {
pure fn shl(rhs: RHS) -> Result;
}
#[cfg(notest)]
#[lang="shr"]
trait shr<RHS,Result> {
pure fn shr(rhs: RHS) -> Result;
}
#[cfg(notest)]
#[lang="index"]
trait index<Index,Result> {
pure fn index(index: Index) -> Result;