Skip to content

Commit 71100ab

Browse files
committed
---
yaml --- r: 27960 b: refs/heads/try c: 7317bf8 h: refs/heads/master v: v3
1 parent ff7f64a commit 71100ab

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: cd6f24f9d14ac90d167386a56e7a6ac1f0318195
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: cd6f24f9d14ac90d167386a56e7a6ac1f0318195
5-
refs/heads/try: 9a7890d73af5ebe4bf862fa727427e290da1391b
5+
refs/heads/try: 7317bf8792ebb3f27768109b7d574ee0806cc5e5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: d0c6ce338884ee21843f4b40bf6bf18d222ce5df

branches/try/src/libsyntax/parse/token.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,9 +279,18 @@ pure fn is_bar(t: token) -> bool {
279279

280280
type ident_interner = util::interner::interner<@~str>;
281281

282+
mod special_idents {
283+
const underscore : uint = 0u;
284+
const anon : uint = 1u;
285+
const destr : uint = 2u; // 'drop', but that's reserved
286+
}
287+
282288
fn mk_ident_interner() -> ident_interner {
283-
let rv = @interner::mk::<@~str>(|x| str::hash(*x),
284-
|x,y| str::eq(*x, *y));
289+
/* the indices here must correspond to the numbers in special_idents */
290+
let init_vec = ~[@~"_", @~"anon", @~"drop"];
291+
292+
let rv = @interner::mk_prefill::<@~str>(|x| str::hash(*x),
293+
|x,y| str::eq(*x, *y), init_vec);
285294
rv
286295
}
287296

branches/try/src/libsyntax/util/interner.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,15 @@ fn mk<T: const copy>(+hasher: hashfn<T>, +eqer: eqfn<T>) -> interner<T> {
1818
return hi as interner::<T>;
1919
}
2020

21+
fn mk_prefill<T: const copy>(hasher: hashfn<T>, eqer: eqfn<T>,
22+
init: ~[T]) -> interner<T> {
23+
24+
let rv = mk(hasher, eqer);
25+
for init.each() |v| { rv.intern(v); }
26+
return rv;
27+
}
28+
29+
2130
/* when traits can extend traits, we should extend index<uint,T> to get [] */
2231
trait interner<T: const copy> {
2332
fn intern(T) -> uint;

0 commit comments

Comments
 (0)