Skip to content

Commit 4054729

Browse files
committed
---
yaml --- r: 79231 b: refs/heads/auto c: b7c0512 h: refs/heads/master i: 79229: d0dfe93 79227: fb958fd 79223: e031419 79215: 481a558 79199: d72a524 79167: 196df88 79103: 7c1b678 v: v3
1 parent 30019f0 commit 4054729

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1313
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1414
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1515
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
16-
refs/heads/auto: 93337f0daab1958bd7f7614cf54d3f69f2ab64ce
16+
refs/heads/auto: b7c0512b27d287cf0657ae4b195d1ca41623c944
1717
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1818
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1919
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336

branches/auto/src/libsyntax/fold.rs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -118,35 +118,37 @@ fn fold_mac_(m: &mac, fld: @ast_fold) -> mac {
118118
node: match m.node {
119119
mac_invoc_tt(ref p,ref tts) =>
120120
mac_invoc_tt(fld.fold_path(p),
121-
fold_tts(*tts,fld))
121+
fold_tts(*tts,|id|{fld.fold_ident(id)}))
122122
},
123123
span: fld.new_span(m.span)
124124
}
125125
}
126126

127-
fn fold_tts(tts : &[token_tree], fld: @ast_fold) -> ~[token_tree] {
127+
// build a new vector of tts by appling the given function to
128+
// all of the identifiers in the token trees.
129+
pub fn fold_tts(tts : &[token_tree], f: @fn(ident)->ident) -> ~[token_tree] {
128130
do tts.map |tt| {
129131
match *tt {
130132
tt_tok(span, ref tok) =>
131-
tt_tok(span,maybe_fold_ident(tok,fld)),
133+
tt_tok(span,maybe_fold_ident(tok,f)),
132134
tt_delim(ref tts) =>
133-
tt_delim(@mut fold_tts(**tts, fld)),
135+
tt_delim(@mut fold_tts(**tts, f)),
134136
tt_seq(span, ref pattern, ref sep, is_optional) =>
135137
tt_seq(span,
136-
@mut fold_tts(**pattern, fld),
137-
sep.map(|tok|maybe_fold_ident(tok,fld)),
138+
@mut fold_tts(**pattern, f),
139+
sep.map(|tok|maybe_fold_ident(tok,f)),
138140
is_optional),
139141
tt_nonterminal(sp,ref ident) =>
140-
tt_nonterminal(sp,fld.fold_ident(*ident))
142+
tt_nonterminal(sp,f(*ident))
141143
}
142144
}
143145
}
144146

145147
// apply ident folder if it's an ident, otherwise leave it alone
146-
fn maybe_fold_ident(t: &token::Token, fld: @ast_fold) -> token::Token {
148+
fn maybe_fold_ident(t : &token::Token, f: @fn(ident)->ident) -> token::Token {
147149
match *t {
148150
token::IDENT(id,followed_by_colons) =>
149-
token::IDENT(fld.fold_ident(id),followed_by_colons),
151+
token::IDENT(f(id),followed_by_colons),
150152
_ => (*t).clone()
151153
}
152154
}

0 commit comments

Comments
 (0)