removed some interner fields

This commit is contained in:
John Clements 2013-05-14 17:27:27 -07:00
parent 1537056982
commit ae02bf70e0
18 changed files with 66 additions and 75 deletions

View file

@ -39,6 +39,7 @@ use syntax::attr;
use syntax::codemap;
use syntax::diagnostic;
use syntax::parse;
use syntax::parse::token;
use syntax::print::{pp, pprust};
use syntax;
@ -230,7 +231,7 @@ pub fn compile_rest(sess: Session,
sess.filesearch,
session::sess_os_to_meta_os(sess.targ_cfg.os),
sess.opts.is_static,
sess.parse_sess.interner));
token::get_ident_interner()));
let lang_items = time(time_passes, ~"language item collection", ||
middle::lang_items::collect_language_items(crate, sess));
@ -455,7 +456,7 @@ pub fn pretty_print_input(sess: Session, cfg: ast::crate_cfg, input: &input,
let is_expanded = upto != cu_parse;
let src = sess.codemap.get_filemap(source_name(input)).src;
do io::with_str_reader(*src) |rdr| {
pprust::print_crate(sess.codemap, sess.parse_sess.interner,
pprust::print_crate(sess.codemap, token::get_ident_interner(),
sess.span_diagnostic, crate.unwrap(),
source_name(input),
rdr, io::stdout(), ann, is_expanded);
@ -754,7 +755,7 @@ pub fn build_session_(sopts: @session::options,
let target_cfg = build_target_config(sopts, demitter);
let p_s = parse::new_parse_sess_special_handler(span_diagnostic_handler,
cm);
let cstore = @mut cstore::mk_cstore(p_s.interner);
let cstore = @mut cstore::mk_cstore(token::get_ident_interner());
let filesearch = filesearch::mk_filesearch(
&sopts.maybe_sysroot,
sopts.target_triple,
@ -963,7 +964,7 @@ pub fn early_error(emitter: diagnostic::Emitter, msg: ~str) -> ! {
pub fn list_metadata(sess: Session, path: &Path, out: @io::Writer) {
metadata::loader::list_file_metadata(
sess.parse_sess.interner,
token::get_ident_interner(),
session::sess_os_to_meta_os(sess.targ_cfg.os), path, out);
}

View file

@ -26,6 +26,7 @@ use syntax::diagnostic;
use syntax::parse::ParseSess;
use syntax::{ast, codemap};
use syntax::abi;
use syntax::parse::token;
use syntax;
use core::hashmap::HashMap;
@ -294,13 +295,13 @@ impl Session_ {
}
pub fn str_of(@self, id: ast::ident) -> @~str {
self.parse_sess.interner.get(id)
token::get_ident_interner().get(id)
}
pub fn ident_of(@self, st: &str) -> ast::ident {
self.parse_sess.interner.intern(st)
token::get_ident_interner().intern(st)
}
pub fn intr(@self) -> @syntax::parse::token::ident_interner {
self.parse_sess.interner
token::get_ident_interner()
}
}

View file

@ -22,6 +22,7 @@ use syntax::codemap::{dummy_sp, span, ExpandedFrom, CallInfo, NameAndSpan};
use syntax::codemap;
use syntax::ext::base::ExtCtxt;
use syntax::fold;
use syntax::parse::token;
use syntax::print::pprust;
use syntax::{ast, ast_util};
@ -143,7 +144,7 @@ fn fold_item(cx: @mut TestCtxt, i: @ast::item, fld: @fold::ast_fold)
-> Option<@ast::item> {
cx.path.push(i.ident);
debug!("current path: %s",
ast_util::path_name_i(copy cx.path, cx.sess.parse_sess.interner));
ast_util::path_name_i(copy cx.path, token::get_ident_interner()));
if is_test_fn(cx, i) || is_bench_fn(i) {
match i.node {
@ -412,12 +413,12 @@ fn mk_test_desc_and_fn_rec(cx: &TestCtxt, test: &Test) -> @ast::expr {
let ext_cx = cx.ext_cx;
debug!("encoding %s", ast_util::path_name_i(path,
cx.sess.parse_sess.interner));
token::get_ident_interner()));
let name_lit: ast::lit =
nospan(ast::lit_str(@ast_util::path_name_i(
path,
cx.sess.parse_sess.interner)));
token::get_ident_interner())));
let name_expr = @ast::expr {
id: cx.sess.next_node_id(),

View file

@ -43,6 +43,7 @@ use syntax::opt_vec::OptVec;
use syntax::opt_vec;
use syntax::parse::token::special_idents;
use syntax::{ast_util, visit};
use syntax::parse::token;
use syntax;
use writer = extra::ebml::writer;
@ -142,7 +143,7 @@ fn add_to_index(ecx: @EncodeContext,
index.push(
entry {
val: ast_util::path_name_i(full_path,
ecx.tcx.sess.parse_sess.interner),
token::get_ident_interner()),
pos: ebml_w.writer.tell()
});
}
@ -485,8 +486,7 @@ fn encode_info_for_mod(ecx: @EncodeContext,
(%?/%?)",
*ecx.tcx.sess.str_of(ident),
did,
ast_map::node_id_to_str(ecx.tcx.items, did, ecx.tcx
.sess.parse_sess.interner));
ast_map::node_id_to_str(ecx.tcx.items, did, token::get_ident_interner()));
ebml_w.start_tag(tag_mod_impl);
ebml_w.wr_str(def_to_str(local_def(did)));

View file

@ -41,6 +41,7 @@ use syntax::codemap::span;
use syntax::codemap;
use syntax::fold::*;
use syntax::fold;
use syntax::parse::token;
use syntax;
use writer = extra::ebml::writer;
@ -86,7 +87,7 @@ pub fn encode_inlined_item(ecx: @e::EncodeContext,
ii: ast::inlined_item,
maps: Maps) {
debug!("> Encoding inlined item: %s::%s (%u)",
ast_map::path_to_str(path, ecx.tcx.sess.parse_sess.interner),
ast_map::path_to_str(path, token::get_ident_interner()),
*ecx.tcx.sess.str_of(ii.ident()),
ebml_w.writer.tell());
@ -99,7 +100,7 @@ pub fn encode_inlined_item(ecx: @e::EncodeContext,
ebml_w.end_tag();
debug!("< Encoded inlined fn: %s::%s (%u)",
ast_map::path_to_str(path, ecx.tcx.sess.parse_sess.interner),
ast_map::path_to_str(path, token::get_ident_interner()),
*ecx.tcx.sess.str_of(ii.ident()),
ebml_w.writer.tell());
}
@ -119,7 +120,7 @@ pub fn decode_inlined_item(cdata: @cstore::crate_metadata,
None => None,
Some(ast_doc) => {
debug!("> Decoding inlined fn: %s::?",
ast_map::path_to_str(path, tcx.sess.parse_sess.interner));
ast_map::path_to_str(path, token::get_ident_interner()));
let mut ast_dsr = reader::Decoder(ast_doc);
let from_id_range = Decodable::decode(&mut ast_dsr);
let to_id_range = reserve_id_range(dcx.tcx.sess, from_id_range);
@ -132,7 +133,7 @@ pub fn decode_inlined_item(cdata: @cstore::crate_metadata,
let ii = renumber_ast(xcx, raw_ii);
debug!("Fn named: %s", *tcx.sess.str_of(ii.ident()));
debug!("< Decoded inlined fn: %s::%s",
ast_map::path_to_str(path, tcx.sess.parse_sess.interner),
ast_map::path_to_str(path, token::get_ident_interner()),
*tcx.sess.str_of(ii.ident()));
ast_map::map_decoded_item(tcx.sess.diagnostic(),
dcx.tcx.items, path, &ii);
@ -1167,7 +1168,7 @@ impl fake_ext_ctxt for fake_session {
}
}
fn ident_of(&self, st: &str) -> ast::ident {
self.interner.intern(st)
token::get_ident_interner().intern(st)
}
}
@ -1236,9 +1237,9 @@ fn test_simplification() {
match (item_out, item_exp) {
(ast::ii_item(item_out), ast::ii_item(item_exp)) => {
assert!(pprust::item_to_str(item_out,
ext_cx.parse_sess().interner)
token::get_ident_interner())
== pprust::item_to_str(item_exp,
ext_cx.parse_sess().interner));
token::get_ident_interner()));
}
_ => fail!()
}

View file

@ -35,6 +35,7 @@ use syntax::ast_util::{Private, Public, is_local};
use syntax::ast_util::{variant_visibility_to_privacy, visibility_to_privacy};
use syntax::attr;
use syntax::codemap::span;
use syntax::parse::token;
use syntax::visit;
pub fn check_crate(tcx: ty::ctxt,
@ -120,7 +121,7 @@ pub fn check_crate(tcx: ty::ctxt,
ast_map::node_id_to_str(
tcx.items,
method_id,
tcx.sess.parse_sess.interner)));
token::get_ident_interner())));
}
None => {
tcx.sess.span_bug(span, "method not found in \
@ -184,7 +185,7 @@ pub fn check_crate(tcx: ty::ctxt,
ast_map::node_id_to_str(
tcx.items,
method_id,
tcx.sess.parse_sess.interner)));
token::get_ident_interner())));
}
None => {
tcx.sess.span_bug(span, "method not found in \
@ -216,9 +217,7 @@ pub fn check_crate(tcx: ty::ctxt,
ast_map::node_id_to_str(
tcx.items,
item_id,
tcx.sess
.parse_sess
.interner)));
token::get_ident_interner())));
}
None => {
tcx.sess.span_bug(span, "item not found in AST map?!");
@ -236,8 +235,8 @@ pub fn check_crate(tcx: ty::ctxt,
if field.ident != ident { loop; }
if field.vis == private {
tcx.sess.span_err(span, fmt!("field `%s` is private",
*tcx.sess.parse_sess.interner
.get(ident)));
*token::get_ident_interner()
.get(ident)));
}
break;
}
@ -257,9 +256,7 @@ pub fn check_crate(tcx: ty::ctxt,
!privileged_items.contains(&(container_id.node))) {
tcx.sess.span_err(span,
fmt!("method `%s` is private",
*tcx.sess
.parse_sess
.interner
*token::get_ident_interner()
.get(*name)));
}
} else {
@ -268,7 +265,7 @@ pub fn check_crate(tcx: ty::ctxt,
if visibility != public {
tcx.sess.span_err(span,
fmt!("method `%s` is private",
*tcx.sess.parse_sess.interner
*token::get_ident_interner()
.get(*name)));
}
}
@ -289,9 +286,7 @@ pub fn check_crate(tcx: ty::ctxt,
!privileged_items.contains(&def_id.node) {
tcx.sess.span_err(span,
fmt!("function `%s` is private",
*tcx.sess
.parse_sess
.interner
*token::get_ident_interner()
.get(copy *path
.idents
.last())));
@ -300,9 +295,7 @@ pub fn check_crate(tcx: ty::ctxt,
def_id) != public {
tcx.sess.span_err(span,
fmt!("function `%s` is private",
*tcx.sess
.parse_sess
.interner
*token::get_ident_interner()
.get(copy *path
.idents
.last())));
@ -350,10 +343,7 @@ pub fn check_crate(tcx: ty::ctxt,
`%s` \
is \
private",
*tcx
.sess
.parse_sess
.interner
*token::get_ident_interner()
.get
(method
.ident)));

View file

@ -30,6 +30,7 @@ use core::hashmap::{HashMap, HashSet};
use syntax::ast_map;
use syntax::codemap::span;
use syntax::print::pprust;
use syntax::parse::token;
use syntax::parse::token::special_idents;
use syntax::{ast, visit};
@ -595,7 +596,7 @@ impl DetermineRpCtxt {
debug!("add_rp() variance for %s: %? == %? ^ %?",
ast_map::node_id_to_str(self.ast_map, id,
self.sess.parse_sess.interner),
token::get_ident_interner()),
joined_variance, old_variance, variance);
if Some(joined_variance) != old_variance {
@ -614,9 +615,9 @@ impl DetermineRpCtxt {
debug!("add dependency from %d -> %d (%s -> %s) with variance %?",
from, self.item_id,
ast_map::node_id_to_str(self.ast_map, from,
self.sess.parse_sess.interner),
token::get_ident_interner()),
ast_map::node_id_to_str(self.ast_map, self.item_id,
self.sess.parse_sess.interner),
token::get_ident_interner()),
copy self.ambient_variance);
let vec = match self.dep_map.find(&from) {
Some(&vec) => vec,
@ -951,7 +952,7 @@ pub fn determine_rp_in_crate(sess: Session,
debug!("item %? (%s) is parameterized with variance %?",
key,
ast_map::node_id_to_str(ast_map, key,
sess.parse_sess.interner),
token::get_ident_interner()),
value);
}
"----"

View file

@ -28,6 +28,7 @@ use syntax::ast_util::{path_to_ident, walk_pat, trait_method_to_ty_method};
use syntax::ast_util::{Privacy, Public, Private};
use syntax::ast_util::{variant_visibility_to_privacy, visibility_to_privacy};
use syntax::attr::{attr_metas, contains_name};
use syntax::parse::token;
use syntax::parse::token::ident_interner;
use syntax::parse::token::special_idents;
use syntax::print::pprust::path_to_str;
@ -805,8 +806,7 @@ pub fn Resolver(session: Session,
self_ident: special_idents::self_,
type_self_ident: special_idents::type_self,
primitive_type_table: @PrimitiveTypeTable(session.
parse_sess.interner),
primitive_type_table: @PrimitiveTypeTable(token::get_ident_interner()),
namespaces: ~[ TypeNS, ValueNS ],
@ -2942,7 +2942,7 @@ impl Resolver {
module_: @mut Module,
module_path: &[ident])
-> ResolveResult<ModulePrefixResult> {
let interner = self.session.parse_sess.interner;
let interner = token::get_ident_interner();
// Start at the current module if we see `self` or `super`, or at the
// top of the crate otherwise.

View file

@ -78,7 +78,8 @@ use syntax::ast_map::{path, path_elt_to_str, path_name};
use syntax::ast_util::{local_def, path_to_ident};
use syntax::attr;
use syntax::codemap::span;
use syntax::parse::token::special_idents;
use syntax::parse::token;
use syntax::parse::token::{special_idents};
use syntax::print::pprust::stmt_to_str;
use syntax::visit;
use syntax::{ast, ast_util, codemap, ast_map};
@ -2257,10 +2258,10 @@ pub fn register_fn_fuller(ccx: @CrateContext,
-> ValueRef {
debug!("register_fn_fuller creating fn for item %d with path %s",
node_id,
ast_map::path_to_str(path, ccx.sess.parse_sess.interner));
ast_map::path_to_str(path, token::get_ident_interner()));
let ps = if attr::attrs_contains_name(attrs, "no_mangle") {
path_elt_to_str(*path.last(), ccx.sess.parse_sess.interner)
path_elt_to_str(*path.last(), token::get_ident_interner())
} else {
mangle_exported_name(ccx, /*bad*/copy path, node_type)
};
@ -2504,7 +2505,7 @@ pub fn get_item_val(ccx: @CrateContext, id: ast::node_id) -> ValueRef {
}
ast::foreign_item_const(*) => {
let typ = ty::node_id_to_type(tcx, ni.id);
let ident = ccx.sess.parse_sess.interner.get(ni.ident);
let ident = token::get_ident_interner().get(ni.ident);
let g = do str::as_c_str(*ident) |buf| {
unsafe {
llvm::LLVMAddGlobal(ccx.llmod,
@ -3069,7 +3070,7 @@ pub fn trans_crate(sess: session::Session,
lib::llvm::associate_type(tn, @"tydesc", tydesc_type);
let crate_map = decl_crate_map(sess, link_meta, llmod);
let dbg_cx = if sess.opts.debuginfo {
Some(debuginfo::mk_ctxt(copy llmod_id, sess.parse_sess.interner))
Some(debuginfo::mk_ctxt(copy llmod_id, token::get_ident_interner()))
} else {
None
};
@ -3104,7 +3105,7 @@ pub fn trans_crate(sess: session::Session,
lltypes: @mut HashMap::new(),
llsizingtypes: @mut HashMap::new(),
adt_reprs: @mut HashMap::new(),
names: new_namegen(sess.parse_sess.interner),
names: new_namegen(token::get_ident_interner()),
next_addrspace: new_addrspace_gen(),
symbol_hasher: symbol_hasher,
type_hashcodes: @mut HashMap::new(),

View file

@ -41,6 +41,7 @@ use syntax::{ast, ast_util};
use syntax::{attr, ast_map};
use syntax::opt_vec;
use syntax::parse::token::special_idents;
use syntax::parse::token;
use syntax::abi::{X86, X86_64, Arm, Mips};
use syntax::abi::{RustIntrinsic, Rust, Stdcall, Fastcall,
Cdecl, Aapcs, C};
@ -343,8 +344,7 @@ pub fn trans_foreign_mod(ccx: @CrateContext,
}
}
ast::foreign_item_const(*) => {
let ident = ccx.sess.parse_sess.interner.get(
foreign_item.ident);
let ident = token::get_ident_interner().get(foreign_item.ident);
ccx.item_symbols.insert(foreign_item.id, copy *ident);
}
}

View file

@ -42,6 +42,7 @@ use syntax::ast;
use syntax::ast::*;
use syntax::ast_map;
use syntax::ast_util;
use syntax::parse::token;
use syntax::visit;
pub type type_uses = uint; // Bitmask
@ -170,7 +171,7 @@ pub fn type_uses_for(ccx: @CrateContext, fn_id: def_id, n_tps: uint)
ast_map::node_id_to_str(
ccx.tcx.items,
fn_id_loc.node,
ccx.tcx.sess.parse_sess.interner)));
token::get_ident_interner())));
}
}
let Context { uses, _ } = cx;

View file

@ -43,6 +43,7 @@ use syntax::ast_util;
use syntax::attr;
use syntax::codemap::span;
use syntax::codemap;
use syntax::parse::token;
use syntax::parse::token::special_idents;
use syntax::{ast, ast_map};
use syntax::opt_vec::OptVec;
@ -2819,7 +2820,7 @@ pub fn node_id_to_trait_ref(cx: ctxt, id: ast::node_id) -> @ty::TraitRef {
None => cx.sess.bug(
fmt!("node_id_to_trait_ref: no trait ref for node `%s`",
ast_map::node_id_to_str(cx.items, id,
cx.sess.parse_sess.interner)))
token::get_ident_interner())))
}
}
@ -2830,7 +2831,7 @@ pub fn node_id_to_type(cx: ctxt, id: ast::node_id) -> t {
None => cx.sess.bug(
fmt!("node_id_to_type: no type for node `%s`",
ast_map::node_id_to_str(cx.items, id,
cx.sess.parse_sess.interner)))
token::get_ident_interner())))
}
}
@ -3821,7 +3822,7 @@ pub fn substd_enum_variants(cx: ctxt,
}
pub fn item_path_str(cx: ctxt, id: ast::def_id) -> ~str {
ast_map::path_to_str(item_path(cx, id), cx.sess.parse_sess.interner)
ast_map::path_to_str(item_path(cx, id), token::get_ident_interner())
}
pub enum DtorKind {
@ -4107,7 +4108,7 @@ pub fn lookup_struct_fields(cx: ctxt, did: ast::def_id) -> ~[field_ty] {
cx.sess.bug(
fmt!("struct ID not bound to an item: %s",
ast_map::node_id_to_str(cx.items, did.node,
cx.sess.parse_sess.interner)));
token::get_ident_interner())));
}
}
}

View file

@ -127,6 +127,7 @@ use syntax::codemap::span;
use syntax::codemap;
use syntax::opt_vec::OptVec;
use syntax::opt_vec;
use syntax::parse::token;
use syntax::parse::token::special_idents;
use syntax::print::pprust;
use syntax::visit;
@ -815,7 +816,7 @@ impl FnCtxt {
fmt!("no type for node %d: %s in fcx %s",
id, ast_map::node_id_to_str(
self.tcx().items, id,
self.tcx().sess.parse_sess.interner),
token::get_ident_interner()),
self.tag()));
}
}
@ -829,7 +830,7 @@ impl FnCtxt {
fmt!("no type substs for node %d: %s in fcx %s",
id, ast_map::node_id_to_str(
self.tcx().items, id,
self.tcx().sess.parse_sess.interner),
token::get_ident_interner()),
self.tag()));
}
}

View file

@ -28,6 +28,7 @@ use middle::typeck;
use syntax::abi::AbiSet;
use syntax::ast_map;
use syntax::codemap::span;
use syntax::parse::token;
use syntax::print::pprust;
use syntax::{ast, ast_util};
@ -200,7 +201,7 @@ pub fn re_scope_id_to_str(cx: ctxt, node_id: ast::node_id) -> ~str {
_ => { cx.sess.bug(
fmt!("re_scope refers to %s",
ast_map::node_id_to_str(cx.items, node_id,
cx.sess.parse_sess.interner))) }
token::get_ident_interner()))) }
}
}

View file

@ -174,7 +174,7 @@ fn run(repl: Repl, input: ~str) -> Repl {
_ => fail!()
};
debug!("recording input into repl history");
record(repl, blk, sess.parse_sess.interner)
record(repl, blk, token::get_ident_interner())
}
// Compiles a crate given by the filename as a library if the compiled

View file

@ -849,7 +849,7 @@ mod test {
};
let table = @mut new_sctable();
let a_name = 100; // enforced by testing_interner
let a2_name = sess.interner.gensym("a2").name;
let a2_name = get_ident_interner().gensym("a2").name;
let renamer = new_ident_renamer(ast::ident{name:a_name,ctxt:empty_ctxt},
a2_name,table);
let renamed_ast = fun_to_ident_folder(renamer).fold_item(item_ast).get();

View file

@ -31,7 +31,6 @@ pub trait reader {
fn next_token(@mut self) -> TokenAndSpan;
fn fatal(@mut self, ~str) -> !;
fn span_diag(@mut self) -> @span_handler;
fn interner(@mut self) -> @token::ident_interner;
fn peek(@mut self) -> TokenAndSpan;
fn dup(@mut self) -> @reader;
}
@ -122,7 +121,6 @@ impl reader for StringReader {
self.span_diagnostic.span_fatal(copy self.peek_span, m)
}
fn span_diag(@mut self) -> @span_handler { self.span_diagnostic }
fn interner(@mut self) -> @token::ident_interner { get_ident_interner() }
fn peek(@mut self) -> TokenAndSpan {
TokenAndSpan {
tok: copy self.peek_tok,
@ -139,7 +137,6 @@ impl reader for TtReader {
self.sp_diag.span_fatal(copy self.cur_span, m);
}
fn span_diag(@mut self) -> @span_handler { self.sp_diag }
fn interner(@mut self) -> @token::ident_interner { get_ident_interner() }
fn peek(@mut self) -> TokenAndSpan {
TokenAndSpan {
tok: copy self.cur_tok,

View file

@ -43,14 +43,10 @@ pub mod classify;
pub mod obsolete;
// info about a parsing session.
// This structure and the reader both have
// an interner associated with them. If they're
// not the same, bad things can happen.
pub struct ParseSess {
cm: @codemap::CodeMap, // better be the same as the one in the reader!
next_id: node_id,
span_diagnostic: @span_handler, // better be the same as the one in the reader!
interner: @ident_interner,
}
pub fn new_parse_sess(demitter: Option<Emitter>) -> @mut ParseSess {
@ -59,7 +55,6 @@ pub fn new_parse_sess(demitter: Option<Emitter>) -> @mut ParseSess {
cm: cm,
next_id: 1,
span_diagnostic: mk_span_handler(mk_handler(demitter), cm),
interner: get_ident_interner(),
}
}
@ -70,7 +65,6 @@ pub fn new_parse_sess_special_handler(sh: @span_handler,
cm: cm,
next_id: 1,
span_diagnostic: sh,
interner: get_ident_interner(),
}
}