middle: resolve: fix inconsistencies around ExportMap and remove the 2 suffix.

This commit is contained in:
Eduard Burtescu 2014-12-18 20:27:17 +02:00
parent 533822207f
commit fb1d6f24fc
7 changed files with 43 additions and 43 deletions

View File

@ -66,7 +66,7 @@ pub type EncodeInlinedItem<'a> = |ecx: &EncodeContext,
pub struct EncodeParams<'a, 'tcx: 'a> {
pub diag: &'a SpanHandler,
pub tcx: &'a ty::ctxt<'tcx>,
pub reexports2: &'a middle::resolve::ExportMap2,
pub reexports: &'a middle::resolve::ExportMap,
pub item_symbols: &'a RefCell<NodeMap<String>>,
pub link_meta: &'a LinkMeta,
pub cstore: &'a cstore::CStore,
@ -77,7 +77,7 @@ pub struct EncodeParams<'a, 'tcx: 'a> {
pub struct EncodeContext<'a, 'tcx: 'a> {
pub diag: &'a SpanHandler,
pub tcx: &'a ty::ctxt<'tcx>,
pub reexports2: &'a middle::resolve::ExportMap2,
pub reexports: &'a middle::resolve::ExportMap,
pub item_symbols: &'a RefCell<NodeMap<String>>,
pub link_meta: &'a LinkMeta,
pub cstore: &'a cstore::CStore,
@ -379,7 +379,7 @@ fn encode_path<PI: Iterator<PathElem>>(rbml_w: &mut Encoder, path: PI) {
}
fn encode_reexported_static_method(rbml_w: &mut Encoder,
exp: &middle::resolve::Export2,
exp: &middle::resolve::Export,
method_def_id: DefId,
method_name: ast::Name) {
debug!("(encode reexported static method) {}::{}",
@ -398,7 +398,7 @@ fn encode_reexported_static_method(rbml_w: &mut Encoder,
fn encode_reexported_static_base_methods(ecx: &EncodeContext,
rbml_w: &mut Encoder,
exp: &middle::resolve::Export2)
exp: &middle::resolve::Export)
-> bool {
let impl_items = ecx.tcx.impl_items.borrow();
match ecx.tcx.inherent_impls.borrow().get(&exp.def_id) {
@ -428,7 +428,7 @@ fn encode_reexported_static_base_methods(ecx: &EncodeContext,
fn encode_reexported_static_trait_methods(ecx: &EncodeContext,
rbml_w: &mut Encoder,
exp: &middle::resolve::Export2)
exp: &middle::resolve::Export)
-> bool {
match ecx.tcx.trait_items_cache.borrow().get(&exp.def_id) {
Some(trait_items) => {
@ -449,7 +449,7 @@ fn encode_reexported_static_trait_methods(ecx: &EncodeContext,
fn encode_reexported_static_methods(ecx: &EncodeContext,
rbml_w: &mut Encoder,
mod_path: PathElems,
exp: &middle::resolve::Export2) {
exp: &middle::resolve::Export) {
if let Some(ast_map::NodeItem(item)) = ecx.tcx.map.find(exp.def_id.node) {
let original_name = token::get_ident(item.ident);
@ -519,7 +519,7 @@ fn encode_reexports(ecx: &EncodeContext,
id: NodeId,
path: PathElems) {
debug!("(encoding info for module) encoding reexports for {}", id);
match ecx.reexports2.get(&id) {
match ecx.reexports.get(&id) {
Some(ref exports) => {
debug!("(encoding info for module) found reexports for {}", id);
for exp in exports.iter() {
@ -2071,7 +2071,7 @@ fn encode_metadata_inner(wr: &mut SeekableMemWriter,
item_symbols,
diag,
tcx,
reexports2,
reexports,
cstore,
encode_inlined_item,
link_meta,
@ -2081,7 +2081,7 @@ fn encode_metadata_inner(wr: &mut SeekableMemWriter,
let ecx = EncodeContext {
diag: diag,
tcx: tcx,
reexports2: reexports2,
reexports: reexports,
item_symbols: item_symbols,
link_meta: link_meta,
cstore: cstore,

View File

@ -29,7 +29,7 @@ use syntax::codemap::Span;
use syntax::parse::token;
use syntax::visit::{mod, Visitor};
type Context<'a, 'tcx> = (&'a MethodMap<'tcx>, &'a resolve::ExportMap2);
type Context<'a, 'tcx> = (&'a MethodMap<'tcx>, &'a resolve::ExportMap);
/// A set of AST nodes exported by the crate.
pub type ExportedItems = NodeSet;
@ -136,7 +136,7 @@ impl<'v> Visitor<'v> for ParentVisitor {
struct EmbargoVisitor<'a, 'tcx: 'a> {
tcx: &'a ty::ctxt<'tcx>,
exp_map2: &'a resolve::ExportMap2,
export_map: &'a resolve::ExportMap,
// This flag is an indicator of whether the previous item in the
// hierarchical chain was exported or not. This is the indicator of whether
@ -342,8 +342,8 @@ impl<'a, 'tcx, 'v> Visitor<'v> for EmbargoVisitor<'a, 'tcx> {
// This code is here instead of in visit_item so that the
// crate module gets processed as well.
if self.prev_exported {
assert!(self.exp_map2.contains_key(&id), "wut {}", id);
for export in self.exp_map2[id].iter() {
assert!(self.export_map.contains_key(&id), "wut {}", id);
for export in self.export_map[id].iter() {
if is_local(export.def_id) {
self.reexports.insert(export.def_id.node);
}
@ -1520,7 +1520,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for VisiblePrivateTypesVisitor<'a, 'tcx> {
}
pub fn check_crate(tcx: &ty::ctxt,
exp_map2: &resolve::ExportMap2,
export_map: &resolve::ExportMap,
external_exports: resolve::ExternalExports,
last_private_map: resolve::LastPrivateMap)
-> (ExportedItems, PublicItems) {
@ -1561,7 +1561,7 @@ pub fn check_crate(tcx: &ty::ctxt,
exported_items: NodeSet::new(),
public_items: NodeSet::new(),
reexports: NodeSet::new(),
exp_map2: exp_map2,
export_map: export_map,
prev_exported: true,
prev_public: true,
};

View File

@ -97,13 +97,13 @@ struct BindingInfo {
type BindingMap = HashMap<Name, BindingInfo>;
// Trait method resolution
pub type TraitMap = NodeMap<Vec<DefId> >;
pub type TraitMap = NodeMap<Vec<DefId>>;
// This is the replacement export map. It maps a module to all of the exports
// within.
pub type ExportMap2 = NodeMap<Vec<Export2>>;
pub type ExportMap = NodeMap<Vec<Export>>;
pub struct Export2 {
pub struct Export {
pub name: String, // The name of the target.
pub def_id: DefId, // The definition of the target.
}
@ -946,7 +946,7 @@ struct Resolver<'a> {
freevars: RefCell<FreevarMap>,
freevars_seen: RefCell<NodeMap<NodeSet>>,
capture_mode_map: CaptureModeMap,
export_map2: ExportMap2,
export_map: ExportMap,
trait_map: TraitMap,
external_exports: ExternalExports,
last_private: LastPrivateMap,
@ -1061,7 +1061,7 @@ impl<'a> Resolver<'a> {
freevars: RefCell::new(NodeMap::new()),
freevars_seen: RefCell::new(NodeMap::new()),
capture_mode_map: NodeMap::new(),
export_map2: NodeMap::new(),
export_map: NodeMap::new(),
trait_map: NodeMap::new(),
used_imports: HashSet::new(),
used_crates: HashSet::new(),
@ -3859,12 +3859,12 @@ impl<'a> Resolver<'a> {
}
fn record_exports_for_module(&mut self, module_: &Module) {
let mut exports2 = Vec::new();
let mut exports = Vec::new();
self.add_exports_for_module(&mut exports2, module_);
self.add_exports_for_module(&mut exports, module_);
match module_.def_id.get() {
Some(def_id) => {
self.export_map2.insert(def_id.node, exports2);
self.export_map.insert(def_id.node, exports);
debug!("(computing exports) writing exports for {} (some)",
def_id.node);
}
@ -3873,7 +3873,7 @@ impl<'a> Resolver<'a> {
}
fn add_exports_of_namebindings(&mut self,
exports2: &mut Vec<Export2> ,
exports: &mut Vec<Export>,
name: Name,
namebindings: &NameBindings,
ns: Namespace) {
@ -3882,7 +3882,7 @@ impl<'a> Resolver<'a> {
let name = token::get_name(name);
debug!("(computing exports) YES: export '{}' => {}",
name, d.def_id());
exports2.push(Export2 {
exports.push(Export {
name: name.get().to_string(),
def_id: d.def_id()
});
@ -3894,7 +3894,7 @@ impl<'a> Resolver<'a> {
}
fn add_exports_for_module(&mut self,
exports2: &mut Vec<Export2> ,
exports: &mut Vec<Export>,
module_: &Module) {
for (name, importresolution) in module_.import_resolutions.borrow().iter() {
if !importresolution.is_public {
@ -3906,7 +3906,7 @@ impl<'a> Resolver<'a> {
Some(target) => {
debug!("(computing exports) maybe export '{}'",
token::get_name(*name));
self.add_exports_of_namebindings(exports2,
self.add_exports_of_namebindings(exports,
*name,
&*target.bindings,
ns)
@ -6322,7 +6322,7 @@ pub struct CrateMap {
pub def_map: DefMap,
pub freevars: RefCell<FreevarMap>,
pub capture_mode_map: RefCell<CaptureModeMap>,
pub exp_map2: ExportMap2,
pub export_map: ExportMap,
pub trait_map: TraitMap,
pub external_exports: ExternalExports,
pub last_private_map: LastPrivateMap,
@ -6339,7 +6339,7 @@ pub fn resolve_crate(session: &Session,
def_map: resolver.def_map,
freevars: resolver.freevars,
capture_mode_map: RefCell::new(resolver.capture_mode_map),
exp_map2: resolver.export_map2,
export_map: resolver.export_map,
trait_map: resolver.trait_map,
external_exports: resolver.external_exports,
last_private_map: resolver.last_private,

View File

@ -99,7 +99,7 @@ pub const INITIAL_DISCRIMINANT_VALUE: Disr = 0;
/// The complete set of all analyses described in this module. This is
/// produced by the driver and fed to trans and later passes.
pub struct CrateAnalysis<'tcx> {
pub exp_map2: middle::resolve::ExportMap2,
pub export_map: middle::resolve::ExportMap,
pub exported_items: middle::privacy::ExportedItems,
pub public_items: middle::privacy::PublicItems,
pub ty_cx: ty::ctxt<'tcx>,

View File

@ -345,7 +345,7 @@ pub fn phase_3_run_analysis_passes<'tcx>(sess: Session,
def_map,
freevars,
capture_mode_map,
exp_map2,
export_map,
trait_map,
external_exports,
last_private_map
@ -406,7 +406,7 @@ pub fn phase_3_run_analysis_passes<'tcx>(sess: Session,
let maps = (external_exports, last_private_map);
let (exported_items, public_items) =
time(time_passes, "privacy checking", maps, |(a, b)|
middle::privacy::check_crate(&ty_cx, &exp_map2, a, b));
middle::privacy::check_crate(&ty_cx, &export_map, a, b));
time(time_passes, "intrinsic checking", (), |_|
middle::intrinsicck::check_crate(&ty_cx));
@ -447,7 +447,7 @@ pub fn phase_3_run_analysis_passes<'tcx>(sess: Session,
lint::check_crate(&ty_cx, &exported_items));
ty::CrateAnalysis {
exp_map2: exp_map2,
export_map: export_map,
ty_cx: ty_cx,
exported_items: exported_items,
public_items: public_items,

View File

@ -2938,7 +2938,7 @@ pub fn crate_ctxt_to_encode_parms<'a, 'tcx>(cx: &'a SharedCrateContext<'tcx>,
encoder::EncodeParams {
diag: cx.sess().diagnostic(),
tcx: cx.tcx(),
reexports2: cx.exp_map2(),
reexports: cx.export_map(),
item_symbols: cx.item_symbols(),
link_meta: cx.link_meta(),
cstore: &cx.sess().cstore,
@ -3071,7 +3071,7 @@ fn internalize_symbols(cx: &SharedCrateContext, reachable: &HashSet<String>) {
pub fn trans_crate<'tcx>(analysis: ty::CrateAnalysis<'tcx>)
-> (ty::ctxt<'tcx>, CrateTranslation) {
let ty::CrateAnalysis { ty_cx: tcx, exp_map2, reachable, name, .. } = analysis;
let ty::CrateAnalysis { ty_cx: tcx, export_map, reachable, name, .. } = analysis;
let krate = tcx.map.krate();
// Before we touch LLVM, make sure that multithreading is enabled.
@ -3098,7 +3098,7 @@ pub fn trans_crate<'tcx>(analysis: ty::CrateAnalysis<'tcx>)
let shared_ccx = SharedCrateContext::new(link_meta.crate_name.as_slice(),
codegen_units,
tcx,
exp_map2,
export_map,
Sha256::new(),
link_meta.clone(),
reachable);

View File

@ -61,7 +61,7 @@ pub struct SharedCrateContext<'tcx> {
metadata_llmod: ModuleRef,
metadata_llcx: ContextRef,
exp_map2: resolve::ExportMap2,
export_map: resolve::ExportMap,
reachable: NodeSet,
item_symbols: RefCell<NodeMap<String>>,
link_meta: LinkMeta,
@ -238,7 +238,7 @@ impl<'tcx> SharedCrateContext<'tcx> {
pub fn new(crate_name: &str,
local_count: uint,
tcx: ty::ctxt<'tcx>,
emap2: resolve::ExportMap2,
export_map: resolve::ExportMap,
symbol_hasher: Sha256,
link_meta: LinkMeta,
reachable: NodeSet)
@ -251,7 +251,7 @@ impl<'tcx> SharedCrateContext<'tcx> {
local_ccxs: Vec::with_capacity(local_count),
metadata_llmod: metadata_llmod,
metadata_llcx: metadata_llcx,
exp_map2: emap2,
export_map: export_map,
reachable: reachable,
item_symbols: RefCell::new(NodeMap::new()),
link_meta: link_meta,
@ -329,8 +329,8 @@ impl<'tcx> SharedCrateContext<'tcx> {
self.metadata_llcx
}
pub fn exp_map2<'a>(&'a self) -> &'a resolve::ExportMap2 {
&self.exp_map2
pub fn export_map<'a>(&'a self) -> &'a resolve::ExportMap {
&self.export_map
}
pub fn reachable<'a>(&'a self) -> &'a NodeSet {
@ -553,8 +553,8 @@ impl<'b, 'tcx> CrateContext<'b, 'tcx> {
&self.local.item_vals
}
pub fn exp_map2<'a>(&'a self) -> &'a resolve::ExportMap2 {
&self.shared.exp_map2
pub fn export_map<'a>(&'a self) -> &'a resolve::ExportMap {
&self.shared.export_map
}
pub fn reachable<'a>(&'a self) -> &'a NodeSet {