move interner_key macro
This commit is contained in:
parent
7cacd87efd
commit
313a5ab946
@ -22,14 +22,6 @@ use core::to_str::ToStr;
|
||||
use std::serialize::{Encodable, Decodable, Encoder, Decoder};
|
||||
|
||||
|
||||
/* can't import macros yet, so this is copied from token.rs. See its comment
|
||||
* there. */
|
||||
macro_rules! interner_key (
|
||||
() => (cast::transmute::<(uint, uint),
|
||||
&fn(+v: @@::parse::token::ident_interner)>(
|
||||
(-3 as uint, 0u)))
|
||||
)
|
||||
|
||||
// an identifier contains an index into the interner
|
||||
// table and a SyntaxContext to track renaming and
|
||||
// macro expansion per Flatt et al., "Macros
|
||||
|
@ -374,16 +374,6 @@ pub impl ident_interner {
|
||||
}
|
||||
}
|
||||
|
||||
/* Key for thread-local data for sneaking interner information to the
|
||||
* encoder/decoder. It sounds like a hack because it is one.
|
||||
* Bonus ultra-hack: functions as keys don't work across crates,
|
||||
* so we have to use a unique number. See taskgroup_key! in task.rs
|
||||
* for another case of this. */
|
||||
macro_rules! interner_key (
|
||||
() => (cast::transmute::<(uint, uint), &fn(+v: @@token::ident_interner)>(
|
||||
(-3 as uint, 0u)))
|
||||
)
|
||||
|
||||
pub fn mk_ident_interner() -> @ident_interner {
|
||||
unsafe {
|
||||
match task::local_data::local_data_get(interner_key!()) {
|
||||
|
@ -30,6 +30,13 @@ extern mod std(vers = "0.7-pre");
|
||||
|
||||
use core::*;
|
||||
|
||||
// allow the interner_key macro
|
||||
// to escape this module:
|
||||
#[macro_escape]
|
||||
pub mod util {
|
||||
pub mod interner;
|
||||
}
|
||||
|
||||
pub mod syntax {
|
||||
pub use ext;
|
||||
pub use parse;
|
||||
@ -45,9 +52,6 @@ pub mod ast_util;
|
||||
pub mod ast_map;
|
||||
pub mod visit;
|
||||
pub mod fold;
|
||||
pub mod util {
|
||||
pub mod interner;
|
||||
}
|
||||
|
||||
|
||||
#[path = "parse/mod.rs"]
|
||||
|
@ -12,6 +12,9 @@
|
||||
// allows bidirectional lookup; i.e. given a value, one can easily find the
|
||||
// type, and vice versa.
|
||||
|
||||
// allow the interner_key macro to escape this module:
|
||||
#[macro_escape];
|
||||
|
||||
use core::prelude::*;
|
||||
use core::hashmap::HashMap;
|
||||
|
||||
@ -66,6 +69,17 @@ pub impl<T:Eq + IterBytes + Hash + Const + Copy> Interner<T> {
|
||||
fn len(&self) -> uint { let vect = &*self.vect; vect.len() }
|
||||
}
|
||||
|
||||
/* Key for thread-local data for sneaking interner information to the
|
||||
* encoder/decoder. It sounds like a hack because it is one.
|
||||
* Bonus ultra-hack: functions as keys don't work across crates,
|
||||
* so we have to use a unique number. See taskgroup_key! in task.rs
|
||||
* for another case of this. */
|
||||
macro_rules! interner_key (
|
||||
() => (cast::transmute::<(uint, uint),
|
||||
&fn(+v: @@::parse::token::ident_interner)>(
|
||||
(-3 as uint, 0u)))
|
||||
)
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
@ -109,4 +123,4 @@ mod tests {
|
||||
assert_eq!(i.get(2), @~"Carol");
|
||||
assert_eq!(i.intern(@~"Bob"), 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user