summary refs log tree commit diff
path: root/src/libsyntax/codemap.rs
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2012-12-05 19:22:48 -0800
committerBrian Anderson <banderson@mozilla.com>2012-12-05 19:23:13 -0800
commit4ab1c8805aee4b6a4254fd90695371a06cbcd301 (patch)
treedab4555175a51694f1e5fa31d986e3a851b089a1 /src/libsyntax/codemap.rs
parente23ea24aed95885c8bc59de49c616f60fa5053d1 (diff)
downloadrust-4ab1c8805aee4b6a4254fd90695371a06cbcd301.tar.gz
rust-4ab1c8805aee4b6a4254fd90695371a06cbcd301.zip
Convert Num to explicit self
Diffstat (limited to 'src/libsyntax/codemap.rs')
-rw-r--r--src/libsyntax/codemap.rs74
1 files changed, 35 insertions, 39 deletions
diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs
index 220a0a7e6bb..2473011be0d 100644
--- a/src/libsyntax/codemap.rs
+++ b/src/libsyntax/codemap.rs
@@ -59,27 +59,25 @@ impl BytePos: cmp::Ord {
     pure fn gt(&self, other: &BytePos) -> bool { **self > **other }
 }
 
-impl BytePos: Num {
-    pure fn add(other: &BytePos) -> BytePos {
-        BytePos(*self + **other)
+#[cfg(stage0)]
+impl BytePos: Add<BytePos, BytePos> {
+    pure fn add(rhs: &BytePos) -> BytePos {
+        BytePos(*self + **rhs)
     }
-    pure fn sub(other: &BytePos) -> BytePos {
-        BytePos(*self - **other)
-    }
-    pure fn mul(other: &BytePos) -> BytePos {
-        BytePos(*self * (**other))
-    }
-    pure fn div(other: &BytePos) -> BytePos {
-        BytePos(*self / **other)
-    }
-    pure fn modulo(other: &BytePos) -> BytePos {
-        BytePos(*self % **other)
+}
+
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl BytePos: Add<BytePos, BytePos> {
+    pure fn add(&self, rhs: &BytePos) -> BytePos {
+        BytePos(**self + **rhs)
     }
-    pure fn neg() -> BytePos {
-        BytePos(-*self)
+}
+
+impl BytePos: Sub<BytePos, BytePos> {
+    pure fn sub(&self, rhs: &BytePos) -> BytePos {
+        BytePos(**self - **rhs)
     }
-    pure fn to_int() -> int { *self as int }
-    static pure fn from_int(+n: int) -> BytePos { BytePos(n as uint) }
 }
 
 impl BytePos: to_bytes::IterBytes {
@@ -105,32 +103,30 @@ impl CharPos: cmp::Ord {
     pure fn gt(&self, other: &CharPos) -> bool { **self > **other }
 }
 
-impl CharPos: Num {
-    pure fn add(other: &CharPos) -> CharPos {
-        CharPos(*self + **other)
-    }
-    pure fn sub(other: &CharPos) -> CharPos {
-        CharPos(*self - **other)
-    }
-    pure fn mul(other: &CharPos) -> CharPos {
-        CharPos(*self * (**other))
-    }
-    pure fn div(other: &CharPos) -> CharPos {
-        CharPos(*self / **other)
+impl CharPos: to_bytes::IterBytes {
+    pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
+        (**self).iter_bytes(lsb0, f)
     }
-    pure fn modulo(other: &CharPos) -> CharPos {
-        CharPos(*self % **other)
+}
+
+#[cfg(stage0)]
+impl CharPos: Add<CharPos, CharPos> {
+    pure fn add(rhs: &CharPos) -> CharPos {
+        CharPos(*self + **rhs)
     }
-    pure fn neg() -> CharPos {
-        CharPos(-*self)
+}
+
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl CharPos: Add<CharPos, CharPos> {
+    pure fn add(&self, rhs: &CharPos) -> CharPos {
+        CharPos(**self + **rhs)
     }
-    pure fn to_int() -> int { *self as int }
-    static pure fn from_int(+n: int) -> CharPos { CharPos(n as uint) }
 }
 
-impl CharPos: to_bytes::IterBytes {
-    pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
-        (**self).iter_bytes(lsb0, f)
+impl CharPos: Sub<CharPos, CharPos> {
+    pure fn sub(&self, rhs: &CharPos) -> CharPos {
+        CharPos(**self - **rhs)
     }
 }