about summary refs log tree commit diff
path: root/src/libsyntax/util
diff options
context:
space:
mode:
Diffstat (limited to 'src/libsyntax/util')
-rw-r--r--src/libsyntax/util/interner.rs16
-rw-r--r--src/libsyntax/util/parser_testing.rs48
2 files changed, 5 insertions, 59 deletions
diff --git a/src/libsyntax/util/interner.rs b/src/libsyntax/util/interner.rs
index cca2ec89fd4..5d49c8cd75d 100644
--- a/src/libsyntax/util/interner.rs
+++ b/src/libsyntax/util/interner.rs
@@ -12,9 +12,6 @@
 // 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::cmp::Equiv;
 use core::hashmap::HashMap;
 use syntax::parse::token::StringRef;
@@ -78,6 +75,8 @@ pub impl<T:Eq + IterBytes + Hash + Const + Copy> Interner<T> {
     }
 }
 
+// A StrInterner differs from Interner<String> in that it accepts
+// borrowed pointers rather than @ ones, resulting in less allocation.
 pub struct StrInterner {
     priv map: @mut HashMap<@~str, uint>,
     priv vect: @mut ~[@~str],
@@ -133,17 +132,6 @@ pub impl StrInterner {
     }
 }
 
-/* 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::*;
diff --git a/src/libsyntax/util/parser_testing.rs b/src/libsyntax/util/parser_testing.rs
index 12c28f096f6..1c2210c96b6 100644
--- a/src/libsyntax/util/parser_testing.rs
+++ b/src/libsyntax/util/parser_testing.rs
@@ -9,64 +9,22 @@
 // except according to those terms.
 
 use core::option::{Option,None};
-use core::int;
-use core::num::NumCast;
-use codemap::CodeMap;
 use ast;
 use parse::parser::Parser;
-use parse::token::{ident_interner, mk_fresh_ident_interner};
-use diagnostic::{mk_handler, mk_span_handler};
+use parse::{new_parse_sess};
 
 use syntax::parse::{ParseSess,string_to_filemap,filemap_to_tts};
 use syntax::parse::{new_parser_from_source_str};
 
-// add known names to interner for testing
-fn mk_testing_interner() -> @ident_interner {
-    let i = mk_fresh_ident_interner();
-    // baby hack; in order to put the identifiers
-    // 'a' and 'b' at known locations, we're going
-    // to fill up the interner to length 100. If
-    // the # of preloaded items on the interner
-    // ever gets larger than 100, we'll have to
-    // adjust this number (say, to 200) and
-    // change the numbers in the identifier
-    // test cases below.
-
-    assert!(i.len() < 100);
-    for int::range(0,100-((i.len()).to_int())) |_dc| {
-        i.gensym(~"dontcare");
-    }
-    i.intern("a");
-    i.intern("b");
-    i.intern("c");
-    i.intern("d");
-    i.intern("return");
-    assert!(i.get(ast::ident{repr:101,ctxt:0}) == @~"b");
-    i
-}
-
-// make a parse_sess that's closed over a
-// testing interner (where a -> 100, b -> 101)
-fn mk_testing_parse_sess() -> @mut ParseSess {
-    let interner = mk_testing_interner();
-    let cm = @CodeMap::new();
-    @mut ParseSess {
-        cm: cm,
-        next_id: 1,
-        span_diagnostic: mk_span_handler(mk_handler(None), cm),
-        interner: interner,
-    }
-}
-
 // map a string to tts, using a made-up filename: return both the token_trees
 // and the ParseSess
 pub fn string_to_tts_and_sess (source_str : @~str) -> (~[ast::token_tree],@mut ParseSess) {
-    let ps = mk_testing_parse_sess();
+    let ps = new_parse_sess(None);
     (filemap_to_tts(ps,string_to_filemap(ps,source_str,~"bogofile")),ps)
 }
 
 pub fn string_to_parser_and_sess(source_str: @~str) -> (Parser,@mut ParseSess) {
-    let ps = mk_testing_parse_sess();
+    let ps = new_parse_sess(None);
     (new_parser_from_source_str(ps,~[],~"bogofile",source_str),ps)
 }