Skip to content

Commit 313a5ab

Browse files
committed
move interner_key macro
1 parent 7cacd87 commit 313a5ab

File tree

4 files changed

+22
-22
lines changed

4 files changed

+22
-22
lines changed

src/libsyntax/ast.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,6 @@ use core::to_str::ToStr;
2222
use std::serialize::{Encodable, Decodable, Encoder, Decoder};
2323

2424

25-
/* can't import macros yet, so this is copied from token.rs. See its comment
26-
* there. */
27-
macro_rules! interner_key (
28-
() => (cast::transmute::<(uint, uint),
29-
&fn(+v: @@::parse::token::ident_interner)>(
30-
(-3 as uint, 0u)))
31-
)
32-
3325
// an identifier contains an index into the interner
3426
// table and a SyntaxContext to track renaming and
3527
// macro expansion per Flatt et al., "Macros

src/libsyntax/parse/token.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -374,16 +374,6 @@ pub impl ident_interner {
374374
}
375375
}
376376
377-
/* Key for thread-local data for sneaking interner information to the
378-
* encoder/decoder. It sounds like a hack because it is one.
379-
* Bonus ultra-hack: functions as keys don't work across crates,
380-
* so we have to use a unique number. See taskgroup_key! in task.rs
381-
* for another case of this. */
382-
macro_rules! interner_key (
383-
() => (cast::transmute::<(uint, uint), &fn(+v: @@token::ident_interner)>(
384-
(-3 as uint, 0u)))
385-
)
386-
387377
pub fn mk_ident_interner() -> @ident_interner {
388378
unsafe {
389379
match task::local_data::local_data_get(interner_key!()) {

src/libsyntax/syntax.rc

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,13 @@ extern mod std(vers = "0.7-pre");
3030

3131
use core::*;
3232

33+
// allow the interner_key macro
34+
// to escape this module:
35+
#[macro_escape]
36+
pub mod util {
37+
pub mod interner;
38+
}
39+
3340
pub mod syntax {
3441
pub use ext;
3542
pub use parse;
@@ -45,9 +52,6 @@ pub mod ast_util;
4552
pub mod ast_map;
4653
pub mod visit;
4754
pub mod fold;
48-
pub mod util {
49-
pub mod interner;
50-
}
5155

5256

5357
#[path = "parse/mod.rs"]

src/libsyntax/util/interner.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
// allows bidirectional lookup; i.e. given a value, one can easily find the
1313
// type, and vice versa.
1414

15+
// allow the interner_key macro to escape this module:
16+
#[macro_escape];
17+
1518
use core::prelude::*;
1619
use core::hashmap::HashMap;
1720

@@ -66,6 +69,17 @@ pub impl<T:Eq + IterBytes + Hash + Const + Copy> Interner<T> {
6669
fn len(&self) -> uint { let vect = &*self.vect; vect.len() }
6770
}
6871

72+
/* Key for thread-local data for sneaking interner information to the
73+
* encoder/decoder. It sounds like a hack because it is one.
74+
* Bonus ultra-hack: functions as keys don't work across crates,
75+
* so we have to use a unique number. See taskgroup_key! in task.rs
76+
* for another case of this. */
77+
macro_rules! interner_key (
78+
() => (cast::transmute::<(uint, uint),
79+
&fn(+v: @@::parse::token::ident_interner)>(
80+
(-3 as uint, 0u)))
81+
)
82+
6983
#[cfg(test)]
7084
mod tests {
7185
use super::*;
@@ -109,4 +123,4 @@ mod tests {
109123
assert_eq!(i.get(2), @~"Carol");
110124
assert_eq!(i.intern(@~"Bob"), 1);
111125
}
112-
}
126+
}

0 commit comments

Comments
 (0)