summary refs log tree commit diff
path: root/src/libsyntax/ext/base.rs
diff options
context:
space:
mode:
authorHuon Wilson <dbau.pp+github@gmail.com>2013-05-17 21:27:17 +1000
committerHuon Wilson <dbau.pp+github@gmail.com>2013-05-22 00:04:10 +1000
commit4045da9f4f7290b02bee52caa42504e4ce5406f7 (patch)
treeb29a484fe04e1c301fb33b9673f01087219bb71a /src/libsyntax/ext/base.rs
parenteea265ea165cb0e6fa989a3712efd701456b265d (diff)
downloadrust-4045da9f4f7290b02bee52caa42504e4ce5406f7.tar.gz
rust-4045da9f4f7290b02bee52caa42504e4ce5406f7.zip
syntax/ext: modernise ext_ctxt to be CamelCase and use new.
Diffstat (limited to 'src/libsyntax/ext/base.rs')
-rw-r--r--src/libsyntax/ext/base.rs41
1 files changed, 20 insertions, 21 deletions
diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs
index b387694c6c1..9b71fb9647c 100644
--- a/src/libsyntax/ext/base.rs
+++ b/src/libsyntax/ext/base.rs
@@ -33,7 +33,7 @@ pub struct MacroDef {
     ext: SyntaxExtension
 }
 
-pub type ItemDecorator = @fn(@ext_ctxt,
+pub type ItemDecorator = @fn(@ExtCtxt,
                              span,
                              @ast::meta_item,
                              ~[@ast::item])
@@ -44,7 +44,7 @@ pub struct SyntaxExpanderTT {
     span: Option<span>
 }
 
-pub type SyntaxExpanderTTFun = @fn(@ext_ctxt,
+pub type SyntaxExpanderTTFun = @fn(@ExtCtxt,
                                    span,
                                    &[ast::token_tree])
                                 -> MacResult;
@@ -54,7 +54,7 @@ pub struct SyntaxExpanderTTItem {
     span: Option<span>
 }
 
-pub type SyntaxExpanderTTItemFun = @fn(@ext_ctxt,
+pub type SyntaxExpanderTTItemFun = @fn(@ExtCtxt,
                                        span,
                                        ast::ident,
                                        ~[ast::token_tree])
@@ -202,7 +202,7 @@ pub fn syntax_expander_table() -> SyntaxEnv {
 // One of these is made during expansion and incrementally updated as we go;
 // when a macro expansion occurs, the resulting nodes have the backtrace()
 // -> expn_info of their expansion context stored into their span.
-pub struct ext_ctxt {
+pub struct ExtCtxt {
     parse_sess: @mut parse::ParseSess,
     cfg: ast::crate_cfg,
     backtrace: @mut Option<@ExpnInfo>,
@@ -216,7 +216,17 @@ pub struct ext_ctxt {
     trace_mac: @mut bool
 }
 
-pub impl ext_ctxt {
+pub impl ExtCtxt {
+    fn new(parse_sess: @mut parse::ParseSess, cfg: ast::crate_cfg) -> @ExtCtxt {
+        @ExtCtxt {
+            parse_sess: parse_sess,
+            cfg: cfg,
+            backtrace: @mut None,
+            mod_path: @mut ~[],
+            trace_mac: @mut false
+        }
+    }
+
     fn codemap(&self) -> @CodeMap { self.parse_sess.cm }
     fn parse_sess(&self) -> @mut parse::ParseSess { self.parse_sess }
     fn cfg(&self) -> ast::crate_cfg { copy self.cfg }
@@ -294,18 +304,7 @@ pub impl ext_ctxt {
     }
 }
 
-pub fn mk_ctxt(parse_sess: @mut parse::ParseSess, cfg: ast::crate_cfg)
-    -> @ext_ctxt {
-    @ext_ctxt {
-        parse_sess: parse_sess,
-        cfg: cfg,
-        backtrace: @mut None,
-        mod_path: @mut ~[],
-        trace_mac: @mut false
-    }
-}
-
-pub fn expr_to_str(cx: @ext_ctxt, expr: @ast::expr, err_msg: ~str) -> ~str {
+pub fn expr_to_str(cx: @ExtCtxt, expr: @ast::expr, err_msg: ~str) -> ~str {
     match expr.node {
       ast::expr_lit(l) => match l.node {
         ast::lit_str(s) => copy *s,
@@ -315,7 +314,7 @@ pub fn expr_to_str(cx: @ext_ctxt, expr: @ast::expr, err_msg: ~str) -> ~str {
     }
 }
 
-pub fn expr_to_ident(cx: @ext_ctxt,
+pub fn expr_to_ident(cx: @ExtCtxt,
                      expr: @ast::expr,
                      err_msg: &str) -> ast::ident {
     match expr.node {
@@ -329,14 +328,14 @@ pub fn expr_to_ident(cx: @ext_ctxt,
     }
 }
 
-pub fn check_zero_tts(cx: @ext_ctxt, sp: span, tts: &[ast::token_tree],
+pub fn check_zero_tts(cx: @ExtCtxt, sp: span, tts: &[ast::token_tree],
                       name: &str) {
     if tts.len() != 0 {
         cx.span_fatal(sp, fmt!("%s takes no arguments", name));
     }
 }
 
-pub fn get_single_str_from_tts(cx: @ext_ctxt,
+pub fn get_single_str_from_tts(cx: @ExtCtxt,
                                sp: span,
                                tts: &[ast::token_tree],
                                name: &str) -> ~str {
@@ -351,7 +350,7 @@ pub fn get_single_str_from_tts(cx: @ext_ctxt,
     }
 }
 
-pub fn get_exprs_from_tts(cx: @ext_ctxt, tts: &[ast::token_tree])
+pub fn get_exprs_from_tts(cx: @ExtCtxt, tts: &[ast::token_tree])
                        -> ~[@ast::expr] {
     let p = parse::new_parser_from_tts(cx.parse_sess(),
                                        cx.cfg(),