Skip to content

Commit 0b958e7

Browse files
jbclementscatamorphism
authored andcommitted
renaming to adhere to conventions
1 parent 6dbfb5d commit 0b958e7

13 files changed

+102
-110
lines changed

src/libsyntax/ast.rs

-2
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ macro_rules! interner_key (
3333
(-3 as uint, 0u)))
3434
)
3535

36-
// FIXME(#3534): Replace with the struct-based newtype when it's been
37-
// implemented.
3836
struct ident { repr: uint }
3937

4038
impl<S: Encoder> ident: Encodable<S> {

src/libsyntax/ext/base.rs

+33-33
Original file line numberDiff line numberDiff line change
@@ -25,65 +25,65 @@ use std::map::HashMap;
2525

2626
// new-style macro! tt code:
2727
//
28-
// syntax_expander_tt, syntax_expander_tt_item, mac_result,
29-
// normal_tt, item_tt
28+
// SyntaxExpanderTT, SyntaxExpanderTTItem, MacResult,
29+
// NormalTT, ItemTT
3030
//
3131
// also note that ast::mac used to have a bunch of extraneous cases and
3232
// is now probably a redundant AST node, can be merged with
3333
// ast::mac_invoc_tt.
3434

35-
struct macro_def {
35+
struct MacroDef {
3636
name: ~str,
37-
ext: syntax_extension,
37+
ext: SyntaxExtension
3838
}
3939

40-
type item_decorator =
40+
type ItemDecorator =
4141
fn@(ext_ctxt, span, ast::meta_item, ~[@ast::item]) -> ~[@ast::item];
4242

43-
struct syntax_expander_tt {
44-
expander: syntax_expander_tt_,
45-
span: Option<span>,
43+
struct SyntaxExpanderTT {
44+
expander: SyntaxExpanderTTFun,
45+
span: Option<span>
4646
}
4747

48-
type syntax_expander_tt_ = fn@(ext_ctxt, span, ~[ast::token_tree])
49-
-> mac_result;
48+
type SyntaxExpanderTTFun = fn@(ext_ctxt, span, ~[ast::token_tree])
49+
-> MacResult;
5050

51-
struct syntax_expander_tt_item {
52-
expander: syntax_expander_tt_item_,
53-
span: Option<span>,
51+
struct SyntaxExpanderTTItem {
52+
expander: SyntaxExpanderTTItemFun,
53+
span: Option<span>
5454
}
5555

56-
type syntax_expander_tt_item_
57-
= fn@(ext_ctxt, span, ast::ident, ~[ast::token_tree]) -> mac_result;
56+
type SyntaxExpanderTTItemFun
57+
= fn@(ext_ctxt, span, ast::ident, ~[ast::token_tree]) -> MacResult;
5858

59-
enum mac_result {
60-
mr_expr(@ast::expr),
61-
mr_item(@ast::item),
62-
mr_any(fn@()-> @ast::expr, fn@()-> Option<@ast::item>, fn@()->@ast::stmt),
63-
mr_def(macro_def)
59+
enum MacResult {
60+
MRExpr(@ast::expr),
61+
MRItem(@ast::item),
62+
MRAny(fn@()-> @ast::expr, fn@()-> Option<@ast::item>, fn@()->@ast::stmt),
63+
MRDef(MacroDef)
6464
}
6565

66-
enum syntax_extension {
66+
enum SyntaxExtension {
6767

6868
// #[auto_encode] and such
69-
item_decorator(item_decorator),
69+
ItemDecorator(ItemDecorator),
7070

7171
// Token-tree expanders
72-
normal_tt(syntax_expander_tt),
72+
NormalTT(SyntaxExpanderTT),
7373

7474
// perhaps macro_rules! will lose its odd special identifier argument,
7575
// and this can go away also
76-
item_tt(syntax_expander_tt_item),
76+
ItemTT(SyntaxExpanderTTItem),
7777
}
7878

7979
// A temporary hard-coded map of methods for expanding syntax extension
8080
// AST nodes into full ASTs
81-
fn syntax_expander_table() -> HashMap<~str, syntax_extension> {
82-
fn builtin_normal_tt(f: syntax_expander_tt_) -> syntax_extension {
83-
normal_tt(syntax_expander_tt {expander: f, span: None})
81+
fn syntax_expander_table() -> HashMap<~str, SyntaxExtension> {
82+
fn builtin_normal_tt(f: SyntaxExpanderTTFun) -> SyntaxExtension {
83+
NormalTT(SyntaxExpanderTT{expander: f, span: None})
8484
}
85-
fn builtin_item_tt(f: syntax_expander_tt_item_) -> syntax_extension {
86-
item_tt(syntax_expander_tt_item {expander: f, span: None})
85+
fn builtin_item_tt(f: SyntaxExpanderTTItemFun) -> SyntaxExtension {
86+
ItemTT(SyntaxExpanderTTItem{expander: f, span: None})
8787
}
8888
let syntax_expanders = HashMap();
8989
syntax_expanders.insert(~"macro_rules",
@@ -93,10 +93,10 @@ fn syntax_expander_table() -> HashMap<~str, syntax_extension> {
9393
builtin_normal_tt(ext::fmt::expand_syntax_ext));
9494
syntax_expanders.insert(
9595
~"auto_encode",
96-
item_decorator(ext::auto_encode::expand_auto_encode));
96+
ItemDecorator(ext::auto_encode::expand_auto_encode));
9797
syntax_expanders.insert(
9898
~"auto_decode",
99-
item_decorator(ext::auto_encode::expand_auto_decode));
99+
ItemDecorator(ext::auto_encode::expand_auto_decode));
100100
syntax_expanders.insert(~"env",
101101
builtin_normal_tt(ext::env::expand_syntax_ext));
102102
syntax_expanders.insert(~"concat_idents",
@@ -106,10 +106,10 @@ fn syntax_expander_table() -> HashMap<~str, syntax_extension> {
106106
builtin_normal_tt(
107107
ext::log_syntax::expand_syntax_ext));
108108
syntax_expanders.insert(~"deriving_eq",
109-
item_decorator(
109+
ItemDecorator(
110110
ext::deriving::expand_deriving_eq));
111111
syntax_expanders.insert(~"deriving_iter_bytes",
112-
item_decorator(
112+
ItemDecorator(
113113
ext::deriving::expand_deriving_iter_bytes));
114114

115115
// Quasi-quoting expanders

src/libsyntax/ext/concat_idents.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use ext::base::*;
1414
use ext::base;
1515

1616
fn expand_syntax_ext(cx: ext_ctxt, sp: span, tts: ~[ast::token_tree])
17-
-> base::mac_result {
17+
-> base::MacResult {
1818
let mut res_str = ~"";
1919
for tts.eachi |i, e| {
2020
if i & 1 == 1 {
@@ -48,5 +48,5 @@ fn expand_syntax_ext(cx: ext_ctxt, sp: span, tts: ~[ast::token_tree])
4848
),
4949
span: sp,
5050
};
51-
mr_expr(e)
51+
MRExpr(e)
5252
}

src/libsyntax/ext/env.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use core::os;
2525
export expand_syntax_ext;
2626

2727
fn expand_syntax_ext(cx: ext_ctxt, sp: span, tts: ~[ast::token_tree])
28-
-> base::mac_result {
28+
-> base::MacResult {
2929

3030
let var = get_single_str_from_tts(cx, sp, tts, "env!");
3131

@@ -36,7 +36,7 @@ fn expand_syntax_ext(cx: ext_ctxt, sp: span, tts: ~[ast::token_tree])
3636
option::None => mk_uniq_str(cx, sp, ~""),
3737
option::Some(ref s) => mk_uniq_str(cx, sp, (*s))
3838
};
39-
mr_expr(e)
39+
MRExpr(e)
4040
}
4141

4242
//

src/libsyntax/ext/expand.rs

+21-24
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use core::option;
2222
use core::vec;
2323
use std::map::HashMap;
2424

25-
fn expand_expr(exts: HashMap<~str, syntax_extension>, cx: ext_ctxt,
25+
fn expand_expr(exts: HashMap<~str, SyntaxExtension>, cx: ext_ctxt,
2626
e: expr_, s: span, fld: ast_fold,
2727
orig: fn@(expr_, span, ast_fold) -> (expr_, span))
2828
-> (expr_, span)
@@ -46,15 +46,13 @@ fn expand_expr(exts: HashMap<~str, syntax_extension>, cx: ext_ctxt,
4646
cx.span_fatal(pth.span,
4747
fmt!("macro undefined: '%s'", *extname))
4848
}
49-
Some(normal_tt(
50-
syntax_expander_tt { expander: exp, span: exp_sp }
51-
)) => {
49+
Some(NormalTT(SyntaxExpanderTT{expander: exp, span: exp_sp})) => {
5250
cx.bt_push(ExpandedFrom({call_site: s,
5351
callie: {name: *extname, span: exp_sp}}));
5452

5553
let expanded = match exp(cx, (*mac).span, (*tts)) {
56-
mr_expr(e) => e,
57-
mr_any(expr_maker,_,_) => expr_maker(),
54+
MRExpr(e) => e,
55+
MRAny(expr_maker,_,_) => expr_maker(),
5856
_ => cx.span_fatal(
5957
pth.span, fmt!("non-expr macro in expr pos: %s",
6058
*extname))
@@ -85,11 +83,11 @@ fn expand_expr(exts: HashMap<~str, syntax_extension>, cx: ext_ctxt,
8583
// attribute prefixing an item, and are interpreted by feeding the item
8684
// through the named attribute _as a syntax extension_ and splicing in the
8785
// resulting item vec into place in favour of the decorator. Note that
88-
// these do _not_ work for macro extensions, just item_decorator ones.
86+
// these do _not_ work for macro extensions, just ItemDecorator ones.
8987
//
9088
// NB: there is some redundancy between this and expand_item, below, and
9189
// they might benefit from some amount of semantic and language-UI merger.
92-
fn expand_mod_items(exts: HashMap<~str, syntax_extension>, cx: ext_ctxt,
90+
fn expand_mod_items(exts: HashMap<~str, SyntaxExtension>, cx: ext_ctxt,
9391
module_: ast::_mod, fld: ast_fold,
9492
orig: fn@(ast::_mod, ast_fold) -> ast::_mod)
9593
-> ast::_mod
@@ -108,8 +106,8 @@ fn expand_mod_items(exts: HashMap<~str, syntax_extension>, cx: ext_ctxt,
108106
ast::meta_list(ref n, _) => (*n)
109107
};
110108
match exts.find(mname) {
111-
None | Some(normal_tt(_)) | Some(item_tt(*)) => items,
112-
Some(item_decorator(dec_fn)) => {
109+
None | Some(NormalTT(_)) | Some(ItemTT(*)) => items,
110+
Some(ItemDecorator(dec_fn)) => {
113111
cx.bt_push(ExpandedFrom({call_site: attr.span,
114112
callie: {name: copy mname,
115113
span: None}}));
@@ -126,7 +124,7 @@ fn expand_mod_items(exts: HashMap<~str, syntax_extension>, cx: ext_ctxt,
126124

127125

128126
// When we enter a module, record it, for the sake of `module!`
129-
fn expand_item(exts: HashMap<~str, syntax_extension>,
127+
fn expand_item(exts: HashMap<~str, SyntaxExtension>,
130128
cx: ext_ctxt, &&it: @ast::item, fld: ast_fold,
131129
orig: fn@(&&v: @ast::item, ast_fold) -> Option<@ast::item>)
132130
-> Option<@ast::item>
@@ -153,7 +151,7 @@ fn expand_item(exts: HashMap<~str, syntax_extension>,
153151

154152
// Support for item-position macro invocations, exactly the same
155153
// logic as for expression-position macro invocations.
156-
fn expand_item_mac(exts: HashMap<~str, syntax_extension>,
154+
fn expand_item_mac(exts: HashMap<~str, SyntaxExtension>,
157155
cx: ext_ctxt, &&it: @ast::item,
158156
fld: ast_fold) -> Option<@ast::item> {
159157

@@ -169,7 +167,7 @@ fn expand_item_mac(exts: HashMap<~str, syntax_extension>,
169167
None => cx.span_fatal(pth.span,
170168
fmt!("macro undefined: '%s!'", *extname)),
171169

172-
Some(normal_tt(ref expand)) => {
170+
Some(NormalTT(ref expand)) => {
173171
if it.ident != parse::token::special_idents::invalid {
174172
cx.span_fatal(pth.span,
175173
fmt!("macro %s! expects no ident argument, \
@@ -181,7 +179,7 @@ fn expand_item_mac(exts: HashMap<~str, syntax_extension>,
181179
span: (*expand).span}}));
182180
((*expand).expander)(cx, it.span, tts)
183181
}
184-
Some(item_tt(ref expand)) => {
182+
Some(ItemTT(ref expand)) => {
185183
if it.ident == parse::token::special_idents::invalid {
186184
cx.span_fatal(pth.span,
187185
fmt!("macro %s! expects an ident argument",
@@ -197,13 +195,13 @@ fn expand_item_mac(exts: HashMap<~str, syntax_extension>,
197195
};
198196

199197
let maybe_it = match expanded {
200-
mr_item(it) => fld.fold_item(it),
201-
mr_expr(_) => cx.span_fatal(pth.span,
198+
MRItem(it) => fld.fold_item(it),
199+
MRExpr(_) => cx.span_fatal(pth.span,
202200
~"expr macro in item position: "
203201
+ *extname),
204-
mr_any(_, item_maker, _) =>
202+
MRAny(_, item_maker, _) =>
205203
option::chain(item_maker(), |i| {fld.fold_item(i)}),
206-
mr_def(ref mdef) => {
204+
MRDef(ref mdef) => {
207205
exts.insert((*mdef).name, (*mdef).ext);
208206
None
209207
}
@@ -212,7 +210,7 @@ fn expand_item_mac(exts: HashMap<~str, syntax_extension>,
212210
return maybe_it;
213211
}
214212
215-
fn expand_stmt(exts: HashMap<~str, syntax_extension>, cx: ext_ctxt,
213+
fn expand_stmt(exts: HashMap<~str, SyntaxExtension>, cx: ext_ctxt,
216214
&& s: stmt_, sp: span, fld: ast_fold,
217215
orig: fn@(&&s: stmt_, span, ast_fold) -> (stmt_, span))
218216
-> (stmt_, span)
@@ -233,16 +231,15 @@ fn expand_stmt(exts: HashMap<~str, syntax_extension>, cx: ext_ctxt,
233231
None =>
234232
cx.span_fatal(pth.span, fmt!("macro undefined: '%s'", *extname)),
235233

236-
Some(normal_tt(
237-
syntax_expander_tt { expander: exp, span: exp_sp }
238-
)) => {
234+
Some(NormalTT(
235+
SyntaxExpanderTT{expander: exp, span: exp_sp})) => {
239236
cx.bt_push(ExpandedFrom(
240237
{call_site: sp, callie: {name: *extname, span: exp_sp}}));
241238
let expanded = match exp(cx, mac.span, tts) {
242-
mr_expr(e) =>
239+
MRExpr(e) =>
243240
@ast::spanned { node: stmt_expr(e, cx.next_id()),
244241
span: e.span},
245-
mr_any(_,_,stmt_mkr) => stmt_mkr(),
242+
MRAny(_,_,stmt_mkr) => stmt_mkr(),
246243
_ => cx.span_fatal(
247244
pth.span,
248245
fmt!("non-stmt macro in stmt pos: %s", *extname))

src/libsyntax/ext/fmt.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ use extfmt::ct::*;
2828
export expand_syntax_ext;
2929

3030
fn expand_syntax_ext(cx: ext_ctxt, sp: span, tts: ~[ast::token_tree])
31-
-> base::mac_result {
31+
-> base::MacResult {
3232
let args = get_exprs_from_tts(cx, copy tts);
3333
if args.len() == 0 {
3434
cx.span_fatal(sp, "fmt! takes at least 1 argument.");
@@ -46,7 +46,7 @@ fn expand_syntax_ext(cx: ext_ctxt, sp: span, tts: ~[ast::token_tree])
4646
parse_fmt_err_(cx, fmtspan, s)
4747
};
4848
let pieces = parse_fmt_string(fmt, parse_fmt_err);
49-
mr_expr(pieces_to_expr(cx, sp, pieces, args))
49+
MRExpr(pieces_to_expr(cx, sp, pieces, args))
5050
}
5151

5252
// FIXME (#2249): A lot of these functions for producing expressions can

src/libsyntax/ext/log_syntax.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ use core::io::WriterUtil;
1818
use core::option;
1919

2020
fn expand_syntax_ext(cx: ext_ctxt, sp: codemap::span, tt: ~[ast::token_tree])
21-
-> base::mac_result {
21+
-> base::MacResult {
2222

2323
cx.print_backtrace();
2424
io::stdout().write_line(
2525
print::pprust::tt_to_str(ast::tt_delim(tt),cx.parse_sess().interner));
2626

2727
//trivial expression
28-
mr_expr(@ast::expr {
28+
MRExpr(@ast::expr {
2929
id: cx.next_id(),
3030
callee_id: cx.next_id(),
3131
node: ast::expr_rec(~[], option::None),

src/libsyntax/ext/pipes/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ mod liveness;
7070

7171

7272
fn expand_proto(cx: ext_ctxt, _sp: span, id: ast::ident,
73-
tt: ~[ast::token_tree]) -> base::mac_result
73+
tt: ~[ast::token_tree]) -> base::MacResult
7474
{
7575
let sess = cx.parse_sess();
7676
let cfg = cx.cfg();
@@ -88,6 +88,6 @@ fn expand_proto(cx: ext_ctxt, _sp: span, id: ast::ident,
8888
liveness::analyze(proto, cx);
8989

9090
// compile
91-
base::mr_item(proto.compile(cx))
91+
base::MRItem(proto.compile(cx))
9292
}
9393

0 commit comments

Comments
 (0)