libsyntax: Remove the interner_get function and all uses

This commit is contained in:
Patrick Walton 2014-01-31 16:10:06 -08:00 committed by Huon Wilson
parent a695b62118
commit e5dc347ccf
5 changed files with 13 additions and 34 deletions

View File

@ -14,8 +14,8 @@ use codemap::{Span, Spanned, DUMMY_SP};
use abi::AbiSet;
use ast_util;
use opt_vec::OptVec;
use parse::token::{InternedString, interner_get, special_idents};
use parse::token::{str_to_ident};
use parse::token::{InternedString, special_idents, str_to_ident};
use parse::token;
use std::cell::RefCell;
use std::hashmap::HashMap;
@ -126,7 +126,8 @@ pub type Mrk = u32;
impl<S:Encoder> Encodable<S> for Ident {
fn encode(&self, s: &mut S) {
s.emit_str(interner_get(self.name));
let string = token::get_ident(self.name);
s.emit_str(string.get());
}
}

View File

@ -25,7 +25,10 @@ use std::num;
pub fn path_name_i(idents: &[Ident]) -> ~str {
// FIXME: Bad copies (#2543 -- same for everything else that says "bad")
idents.map(|i| token::interner_get(i.name)).connect("::")
idents.map(|i| {
let string = token::get_ident(i.name);
string.get().to_str()
}).connect("::")
}
// totally scary function: ignores all but the last element, should have

View File

@ -4178,7 +4178,8 @@ impl Parser {
outer_attrs, "path") {
Some(d) => dir_path.join(d),
None => {
let mod_name = token::interner_get(id.name).to_owned();
let mod_string = token::get_ident(id.name);
let mod_name = mod_string.get().to_owned();
let default_path_str = mod_name + ".rs";
let secondary_path_str = mod_name + "/mod.rs";
let default_path = dir_path.join(default_path_str.as_slice());

View File

@ -651,11 +651,6 @@ pub fn gensym(str : &str) -> Name {
interner.gensym(str)
}
// map an interned representation back to a string
pub fn interner_get(name : Name) -> @str {
get_ident_interner().get(name)
}
// maps a string to an identifier with an empty syntax context
pub fn str_to_ident(str : &str) -> ast::Ident {
ast::Ident::new(intern(str))
@ -679,28 +674,6 @@ pub fn fresh_name(src : &ast::Ident) -> Name {
gensym(format!("{}_{}",ident_to_str(src),num))*/
}
// it looks like there oughta be a str_ptr_eq fn, but no one bothered to implement it?
// determine whether two @str values are pointer-equal
pub fn str_ptr_eq(a : @str, b : @str) -> bool {
unsafe {
let p : uint = cast::transmute(a);
let q : uint = cast::transmute(b);
let result = p == q;
// got to transmute them back, to make sure the ref count is correct:
let _junk1 : @str = cast::transmute(p);
let _junk2 : @str = cast::transmute(q);
result
}
}
// return true when two identifiers refer (through the intern table) to the same ptr_eq
// string. This is used to compare identifiers in places where hygienic comparison is
// not wanted (i.e. not lexical vars).
pub fn ident_spelling_eq(a : &ast::Ident, b : &ast::Ident) -> bool {
str_ptr_eq(interner_get(a.name),interner_get(b.name))
}
// create a fresh mark.
pub fn fresh_mark() -> Mrk {
gensym("mark")

View File

@ -19,7 +19,7 @@ use codemap::{CodeMap, BytePos};
use codemap;
use diagnostic;
use parse::classify::expr_is_simple_block;
use parse::token::{IdentInterner, interner_get};
use parse::token::IdentInterner;
use parse::{comments, token};
use parse;
use print::pp::{break_offset, word, space, zerobreak, hardbreak};
@ -1544,7 +1544,8 @@ pub fn print_ident(s: &mut State, ident: ast::Ident) {
}
pub fn print_name(s: &mut State, name: ast::Name) {
word(&mut s.s, interner_get(name));
let string = token::get_ident(name);
word(&mut s.s, string.get());
}
pub fn print_for_decl(s: &mut State, loc: &ast::Local, coll: &ast::Expr) {