summary refs log tree commit diff
path: root/src/libsyntax/ext
diff options
context:
space:
mode:
authorPatrick Walton <pcwalton@mimiga.net>2013-05-10 15:15:06 -0700
committerPatrick Walton <pcwalton@mimiga.net>2013-05-12 16:35:18 -0700
commit5d3559e6455757c5508bba5b5add69477ebac53e (patch)
tree71e166364df7f828c4c98c5853597d2c62c37fac /src/libsyntax/ext
parent06ef889cdc77db862d526bf6a607ecdf3ee80beb (diff)
downloadrust-5d3559e6455757c5508bba5b5add69477ebac53e.tar.gz
rust-5d3559e6455757c5508bba5b5add69477ebac53e.zip
librustc: Make `self` and `static` into keywords
Diffstat (limited to 'src/libsyntax/ext')
-rw-r--r--src/libsyntax/ext/auto_encode.rs24
-rw-r--r--src/libsyntax/ext/build.rs4
-rw-r--r--src/libsyntax/ext/deriving/encodable.rs12
-rw-r--r--src/libsyntax/ext/deriving/mod.rs3
-rw-r--r--src/libsyntax/ext/deriving/ty.rs4
-rw-r--r--src/libsyntax/ext/pipes/parse_proto.rs4
6 files changed, 24 insertions, 27 deletions
diff --git a/src/libsyntax/ext/auto_encode.rs b/src/libsyntax/ext/auto_encode.rs
index 1d3af61be70..e1416230720 100644
--- a/src/libsyntax/ext/auto_encode.rs
+++ b/src/libsyntax/ext/auto_encode.rs
@@ -245,6 +245,7 @@ trait ExtCtxtMethods {
     fn expr_path(&self, span: span, strs: ~[ast::ident]) -> @ast::expr;
     fn expr_path_global(&self, span: span, strs: ~[ast::ident]) -> @ast::expr;
     fn expr_var(&self, span: span, var: &str) -> @ast::expr;
+    fn expr_self(&self, span: span) -> @ast::expr;
     fn expr_field(&self, span: span, expr: @ast::expr, ident: ast::ident)
                   -> @ast::expr;
     fn expr_call(&self, span: span, expr: @ast::expr, args: ~[@ast::expr])
@@ -450,6 +451,10 @@ impl ExtCtxtMethods for @ext_ctxt {
         self.expr_path(span, ~[self.ident_of(var)])
     }
 
+    fn expr_self(&self, span: span) -> @ast::expr {
+        self.expr(span, ast::expr_self)
+    }
+
     fn expr_field(
         &self,
         span: span,
@@ -790,12 +795,8 @@ fn mk_struct_ser_impl(
         let expr_lambda = cx.lambda_expr_1(
             cx.expr_method_call(
                 span,
-                cx.expr_field(
-                    span,
-                    cx.expr_var(span, "self"),
-                    field.ident
-                ),
-                cx.ident_of("encode"),
+                cx.expr_field(span, cx.expr_self(span), field.ident),
+                cx.ident_of(~"encode"),
                 ~[cx.expr_var(span, "__s")]
             ),
             cx.ident_of("__s")
@@ -1062,13 +1063,10 @@ fn mk_enum_ser_body(
     // ast for `match *self { $(arms) }`
     let match_expr = cx.expr(
         span,
-        ast::expr_match(
-            cx.expr(
-                span,
-                ast::expr_unary(ast::deref, cx.expr_var(span, "self"))
-            ),
-            arms
-        )
+        ast::expr_match(cx.expr(span,
+                                ast::expr_unary(ast::deref,
+                                                cx.expr_self(span))),
+                        arms)
     );
 
     // ast for `__s.emit_enum($(name), || $(match_expr))`
diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs
index 3bfb93b34b3..3f90fd6267b 100644
--- a/src/libsyntax/ext/build.rs
+++ b/src/libsyntax/ext/build.rs
@@ -518,6 +518,10 @@ pub fn mk_unreachable_arm(cx: @ext_ctxt, span: span) -> ast::arm {
     mk_arm(cx, span, ~[mk_pat_wild(cx, span)], mk_unreachable(cx, span))
 }
 
+pub fn make_self(cx: @ext_ctxt, span: span) -> @ast::expr {
+    build::mk_expr(cx, span, ast::expr_self)
+}
+
 //
 // Duplication functions
 //
diff --git a/src/libsyntax/ext/deriving/encodable.rs b/src/libsyntax/ext/deriving/encodable.rs
index 2786c9c6eb5..a5edd92022f 100644
--- a/src/libsyntax/ext/deriving/encodable.rs
+++ b/src/libsyntax/ext/deriving/encodable.rs
@@ -204,8 +204,6 @@ fn expand_deriving_encodable_struct_method(
     type_ident: ident,
     struct_def: &struct_def
 ) -> @method {
-    let self_ident = cx.ident_of("self");
-
     // Create the body of the method.
     let mut idx = 0;
     let mut statements = ~[];
@@ -213,12 +211,10 @@ fn expand_deriving_encodable_struct_method(
         match struct_field.node.kind {
             named_field(ident, _) => {
                 // Create the accessor for this field.
-                let self_field = build::mk_access(
-                    cx,
-                    span,
-                    ~[self_ident],
-                    ident
-                );
+                let self_field = build::mk_access_(cx,
+                                                   span,
+                                                   build::make_self(cx, span),
+                                                   ident);
 
                 // Call the substructure method.
                 let encode_expr = call_substructure_encode_method(
diff --git a/src/libsyntax/ext/deriving/mod.rs b/src/libsyntax/ext/deriving/mod.rs
index 78eacafe3d7..3b94a95dfe0 100644
--- a/src/libsyntax/ext/deriving/mod.rs
+++ b/src/libsyntax/ext/deriving/mod.rs
@@ -371,8 +371,7 @@ pub fn expand_enum_or_struct_match(cx: @ext_ctxt,
                                span: span,
                                arms: ~[ ast::arm ])
                             -> @expr {
-    let self_ident = cx.ident_of("self");
-    let self_expr = build::mk_path(cx, span, ~[ self_ident ]);
+    let self_expr = build::make_self(cx, span);
     let self_expr = build::mk_unary(cx, span, ast::deref, self_expr);
     let self_match_expr = ast::expr_match(self_expr, arms);
     build::mk_expr(cx, span, self_match_expr)
diff --git a/src/libsyntax/ext/deriving/ty.rs b/src/libsyntax/ext/deriving/ty.rs
index 08947efa7b7..0bb88dae26b 100644
--- a/src/libsyntax/ext/deriving/ty.rs
+++ b/src/libsyntax/ext/deriving/ty.rs
@@ -191,7 +191,7 @@ fn mk_generics(lifetimes: ~[ast::Lifetime],  ty_params: ~[ast::TyParam]) -> Gene
     }
 }
 
-/// Lifetimes and bounds on type paramers
+/// Lifetimes and bounds on type parameters
 pub struct LifetimeBounds {
     lifetimes: ~[~str],
     bounds: ~[(~str, ~[Path])]
@@ -218,7 +218,7 @@ pub impl LifetimeBounds {
 
 pub fn get_explicit_self(cx: @ext_ctxt, span: span, self_ptr: Option<PtrTy>)
     -> (@expr, ast::self_ty) {
-    let self_path = build::mk_path(cx, span, ~[cx.ident_of("self")]);
+    let self_path = build::make_self(cx, span);
     match self_ptr {
         None => {
             (self_path, respan(span, ast::sty_value))
diff --git a/src/libsyntax/ext/pipes/parse_proto.rs b/src/libsyntax/ext/pipes/parse_proto.rs
index f9346f49b61..5c99ddc9040 100644
--- a/src/libsyntax/ext/pipes/parse_proto.rs
+++ b/src/libsyntax/ext/pipes/parse_proto.rs
@@ -32,7 +32,7 @@ impl proto_parser for parser::Parser {
                 sep: None,
                 trailing_sep_allowed: false,
             },
-            |self| self.parse_state(proto)
+            |this| this.parse_state(proto)
         );
 
         return proto;
@@ -70,7 +70,7 @@ impl proto_parser for parser::Parser {
                 sep: Some(token::COMMA),
                 trailing_sep_allowed: true,
             },
-            |self| self.parse_message(state)
+            |this| this.parse_message(state)
         );
     }