summary refs log tree commit diff
path: root/src/libsyntax/parse
diff options
context:
space:
mode:
authorPatrick Walton <pcwalton@mimiga.net>2012-11-14 18:59:30 -0800
committerPatrick Walton <pcwalton@mimiga.net>2012-11-19 15:33:11 -0800
commit318e534895f20e7991abbc644eec311816010ef1 (patch)
tree764ce1ae3e9efbecd4fdc057663beb522b10bda9 /src/libsyntax/parse
parent4101587a88d719659d2e30feaad8437c55af9150 (diff)
downloadrust-318e534895f20e7991abbc644eec311816010ef1.tar.gz
rust-318e534895f20e7991abbc644eec311816010ef1.zip
rustc: Implement explicit self for Eq and Ord. r=graydon
Diffstat (limited to 'src/libsyntax/parse')
-rw-r--r--src/libsyntax/parse/comments.rs12
-rw-r--r--src/libsyntax/parse/obsolete.rs12
-rw-r--r--src/libsyntax/parse/parser.rs10
-rw-r--r--src/libsyntax/parse/token.rs285
4 files changed, 319 insertions, 0 deletions
diff --git a/src/libsyntax/parse/comments.rs b/src/libsyntax/parse/comments.rs
index 2a8bbe3b6d8..3cb6b08d976 100644
--- a/src/libsyntax/parse/comments.rs
+++ b/src/libsyntax/parse/comments.rs
@@ -20,12 +20,24 @@ enum cmnt_style {
 }
 
 impl cmnt_style : cmp::Eq {
+    #[cfg(stage0)]
     pure fn eq(other: &cmnt_style) -> bool {
         (self as uint) == ((*other) as uint)
     }
+    #[cfg(stage1)]
+    #[cfg(stage2)]
+    pure fn eq(&self, other: &cmnt_style) -> bool {
+        ((*self) as uint) == ((*other) as uint)
+    }
+    #[cfg(stage0)]
     pure fn ne(other: &cmnt_style) -> bool {
         (self as uint) != ((*other) as uint)
     }
+    #[cfg(stage1)]
+    #[cfg(stage2)]
+    pure fn ne(&self, other: &cmnt_style) -> bool {
+        ((*self) as uint) != ((*other) as uint)
+    }
 }
 
 type cmnt = {style: cmnt_style, lines: ~[~str], pos: BytePos};
diff --git a/src/libsyntax/parse/obsolete.rs b/src/libsyntax/parse/obsolete.rs
index e5f6cf8ee25..40df4d5f7d4 100644
--- a/src/libsyntax/parse/obsolete.rs
+++ b/src/libsyntax/parse/obsolete.rs
@@ -29,12 +29,24 @@ pub enum ObsoleteSyntax {
 }
 
 impl ObsoleteSyntax : cmp::Eq {
+    #[cfg(stage0)]
     pure fn eq(other: &ObsoleteSyntax) -> bool {
         self as uint == (*other) as uint
     }
+    #[cfg(stage1)]
+    #[cfg(stage2)]
+    pure fn eq(&self, other: &ObsoleteSyntax) -> bool {
+        (*self) as uint == (*other) as uint
+    }
+    #[cfg(stage0)]
     pure fn ne(other: &ObsoleteSyntax) -> bool {
         !self.eq(other)
     }
+    #[cfg(stage1)]
+    #[cfg(stage2)]
+    pure fn ne(&self, other: &ObsoleteSyntax) -> bool {
+        !(*self).eq(other)
+    }
 }
 
 impl ObsoleteSyntax: to_bytes::IterBytes {
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index 3e8f0840883..0df61a7f044 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -3743,10 +3743,20 @@ impl Parser {
 }
 
 impl restriction : cmp::Eq {
+    #[cfg(stage0)]
     pure fn eq(other: &restriction) -> bool {
         (self as uint) == ((*other) as uint)
     }
+    #[cfg(stage1)]
+    #[cfg(stage2)]
+    pure fn eq(&self, other: &restriction) -> bool {
+        ((*self) as uint) == ((*other) as uint)
+    }
+    #[cfg(stage0)]
     pure fn ne(other: &restriction) -> bool { !self.eq(other) }
+    #[cfg(stage1)]
+    #[cfg(stage2)]
+    pure fn ne(&self, other: &restriction) -> bool { !(*self).eq(other) }
 }
 
 //
diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs
index baf963942e2..2e59d2fa45f 100644
--- a/src/libsyntax/parse/token.rs
+++ b/src/libsyntax/parse/token.rs
@@ -463,13 +463,24 @@ fn reserved_keyword_table() -> HashMap<~str, ()> {
 }
 
 impl binop : cmp::Eq {
+    #[cfg(stage0)]
     pure fn eq(other: &binop) -> bool {
         (self as uint) == ((*other) as uint)
     }
+    #[cfg(stage1)]
+    #[cfg(stage2)]
+    pure fn eq(&self, other: &binop) -> bool {
+        ((*self) as uint) == ((*other) as uint)
+    }
+    #[cfg(stage0)]
     pure fn ne(other: &binop) -> bool { !self.eq(other) }
+    #[cfg(stage1)]
+    #[cfg(stage2)]
+    pure fn ne(&self, other: &binop) -> bool { !(*self).eq(other) }
 }
 
 impl Token : cmp::Eq {
+    #[cfg(stage0)]
     pure fn eq(other: &Token) -> bool {
         match self {
             EQ => {
@@ -738,7 +749,281 @@ impl Token : cmp::Eq {
             }
         }
     }
+    #[cfg(stage1)]
+    #[cfg(stage2)]
+    pure fn eq(&self, other: &Token) -> bool {
+        match (*self) {
+            EQ => {
+                match (*other) {
+                    EQ => true,
+                    _ => false
+                }
+            }
+            LT => {
+                match (*other) {
+                    LT => true,
+                    _ => false
+                }
+            }
+            LE => {
+                match (*other) {
+                    LE => true,
+                    _ => false
+                }
+            }
+            EQEQ => {
+                match (*other) {
+                    EQEQ => true,
+                    _ => false
+                }
+            }
+            NE => {
+                match (*other) {
+                    NE => true,
+                    _ => false
+                }
+            }
+            GE => {
+                match (*other) {
+                    GE => true,
+                    _ => false
+                }
+            }
+            GT => {
+                match (*other) {
+                    GT => true,
+                    _ => false
+                }
+            }
+            ANDAND => {
+                match (*other) {
+                    ANDAND => true,
+                    _ => false
+                }
+            }
+            OROR => {
+                match (*other) {
+                    OROR => true,
+                    _ => false
+                }
+            }
+            NOT => {
+                match (*other) {
+                    NOT => true,
+                    _ => false
+                }
+            }
+            TILDE => {
+                match (*other) {
+                    TILDE => true,
+                    _ => false
+                }
+            }
+            BINOP(e0a) => {
+                match (*other) {
+                    BINOP(e0b) => e0a == e0b,
+                    _ => false
+                }
+            }
+            BINOPEQ(e0a) => {
+                match (*other) {
+                    BINOPEQ(e0b) => e0a == e0b,
+                    _ => false
+                }
+            }
+            AT => {
+                match (*other) {
+                    AT => true,
+                    _ => false
+                }
+            }
+            DOT => {
+                match (*other) {
+                    DOT => true,
+                    _ => false
+                }
+            }
+            DOTDOT => {
+                match (*other) {
+                    DOTDOT => true,
+                    _ => false
+                }
+            }
+            ELLIPSIS => {
+                match (*other) {
+                    ELLIPSIS => true,
+                    _ => false
+                }
+            }
+            COMMA => {
+                match (*other) {
+                    COMMA => true,
+                    _ => false
+                }
+            }
+            SEMI => {
+                match (*other) {
+                    SEMI => true,
+                    _ => false
+                }
+            }
+            COLON => {
+                match (*other) {
+                    COLON => true,
+                    _ => false
+                }
+            }
+            MOD_SEP => {
+                match (*other) {
+                    MOD_SEP => true,
+                    _ => false
+                }
+            }
+            RARROW => {
+                match (*other) {
+                    RARROW => true,
+                    _ => false
+                }
+            }
+            LARROW => {
+                match (*other) {
+                    LARROW => true,
+                    _ => false
+                }
+            }
+            DARROW => {
+                match (*other) {
+                    DARROW => true,
+                    _ => false
+                }
+            }
+            FAT_ARROW => {
+                match (*other) {
+                    FAT_ARROW => true,
+                    _ => false
+                }
+            }
+            LPAREN => {
+                match (*other) {
+                    LPAREN => true,
+                    _ => false
+                }
+            }
+            RPAREN => {
+                match (*other) {
+                    RPAREN => true,
+                    _ => false
+                }
+            }
+            LBRACKET => {
+                match (*other) {
+                    LBRACKET => true,
+                    _ => false
+                }
+            }
+            RBRACKET => {
+                match (*other) {
+                    RBRACKET => true,
+                    _ => false
+                }
+            }
+            LBRACE => {
+                match (*other) {
+                    LBRACE => true,
+                    _ => false
+                }
+            }
+            RBRACE => {
+                match (*other) {
+                    RBRACE => true,
+                    _ => false
+                }
+            }
+            POUND => {
+                match (*other) {
+                    POUND => true,
+                    _ => false
+                }
+            }
+            DOLLAR => {
+                match (*other) {
+                    DOLLAR => true,
+                    _ => false
+                }
+            }
+            LIT_INT(e0a, e1a) => {
+                match (*other) {
+                    LIT_INT(e0b, e1b) => e0a == e0b && e1a == e1b,
+                    _ => false
+                }
+            }
+            LIT_UINT(e0a, e1a) => {
+                match (*other) {
+                    LIT_UINT(e0b, e1b) => e0a == e0b && e1a == e1b,
+                    _ => false
+                }
+            }
+            LIT_INT_UNSUFFIXED(e0a) => {
+                match (*other) {
+                    LIT_INT_UNSUFFIXED(e0b) => e0a == e0b,
+                    _ => false
+                }
+            }
+            LIT_FLOAT(e0a, e1a) => {
+                match (*other) {
+                    LIT_FLOAT(e0b, e1b) => e0a == e0b && e1a == e1b,
+                    _ => false
+                }
+            }
+            LIT_FLOAT_UNSUFFIXED(e0a) => {
+                match (*other) {
+                    LIT_FLOAT_UNSUFFIXED(e0b) => e0a == e0b,
+                    _ => false
+                }
+            }
+            LIT_STR(e0a) => {
+                match (*other) {
+                    LIT_STR(e0b) => e0a == e0b,
+                    _ => false
+                }
+            }
+            IDENT(e0a, e1a) => {
+                match (*other) {
+                    IDENT(e0b, e1b) => e0a == e0b && e1a == e1b,
+                    _ => false
+                }
+            }
+            UNDERSCORE => {
+                match (*other) {
+                    UNDERSCORE => true,
+                    _ => false
+                }
+            }
+            INTERPOLATED(_) => {
+                match (*other) {
+                    INTERPOLATED(_) => true,
+                    _ => false
+                }
+            }
+            DOC_COMMENT(e0a) => {
+                match (*other) {
+                    DOC_COMMENT(e0b) => e0a == e0b,
+                    _ => false
+                }
+            }
+            EOF => {
+                match (*other) {
+                    EOF => true,
+                    _ => false
+                }
+            }
+        }
+    }
+    #[cfg(stage0)]
     pure fn ne(other: &Token) -> bool { !self.eq(other) }
+    #[cfg(stage1)]
+    #[cfg(stage2)]
+    pure fn ne(&self, other: &Token) -> bool { !(*self).eq(other) }
 }
 
 // Local Variables: