parent
25f7c844df
commit
bd300636ee
@ -12,6 +12,7 @@ export get_tag_variants;
|
||||
export get_impls_for_mod;
|
||||
export get_impl_methods;
|
||||
export get_type;
|
||||
export get_item_name;
|
||||
|
||||
fn get_symbol(cstore: cstore::cstore, def: ast::def_id) -> str {
|
||||
let cdata = cstore::get_crate_data(cstore, def.crate).data;
|
||||
@ -93,6 +94,11 @@ fn get_type(tcx: ty::ctxt, def: ast::def_id) -> ty::ty_param_kinds_and_ty {
|
||||
decoder::get_type(cdata, def, tcx, resolver)
|
||||
}
|
||||
|
||||
fn get_item_name(cstore: cstore::cstore, cnum: int, id: int) -> ast::ident {
|
||||
let cdata = cstore::get_crate_data(cstore, cnum).data;
|
||||
ret decoder::lookup_item_name(cdata, id);
|
||||
}
|
||||
|
||||
// Translates a def_id from an external crate to a def_id for the current
|
||||
// compilation environment. We use this when trying to load types from
|
||||
// external crates - if those types further refer to types in other crates
|
||||
|
@ -183,7 +183,6 @@ fn lookup_item_name(data: @[u8], id: ast::node_id) -> ast::ident {
|
||||
item_name(lookup_item(id, data))
|
||||
}
|
||||
|
||||
// FIXME doesn't yet handle renamed re-exported externals
|
||||
fn lookup_def(cnum: ast::crate_num, data: @[u8], did_: ast::def_id) ->
|
||||
ast::def {
|
||||
let item = lookup_item(did_.node, data);
|
||||
|
@ -250,10 +250,11 @@ fn encode_tag_variant_info(ecx: @encode_ctxt, ebml_w: ebml::writer,
|
||||
}
|
||||
|
||||
fn encode_info_for_mod(ebml_w: ebml::writer, md: _mod,
|
||||
id: node_id) {
|
||||
id: node_id, name: ident) {
|
||||
ebml::start_tag(ebml_w, tag_items_data_item);
|
||||
encode_def_id(ebml_w, local_def(id));
|
||||
encode_family(ebml_w, 'm' as u8);
|
||||
encode_name(ebml_w, name);
|
||||
for i in md.items {
|
||||
alt i.node {
|
||||
item_impl(_, _, _) {
|
||||
@ -300,12 +301,13 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::writer, item: @item,
|
||||
ebml::end_tag(ebml_w);
|
||||
}
|
||||
item_mod(m) {
|
||||
encode_info_for_mod(ebml_w, m, item.id);
|
||||
encode_info_for_mod(ebml_w, m, item.id, item.ident);
|
||||
}
|
||||
item_native_mod(_) {
|
||||
ebml::start_tag(ebml_w, tag_items_data_item);
|
||||
encode_def_id(ebml_w, local_def(item.id));
|
||||
encode_family(ebml_w, 'n' as u8);
|
||||
encode_name(ebml_w, item.ident);
|
||||
ebml::end_tag(ebml_w);
|
||||
}
|
||||
item_ty(_, tps) {
|
||||
@ -434,7 +436,7 @@ fn encode_info_for_items(ecx: @encode_ctxt, ebml_w: ebml::writer,
|
||||
let index: [entry<int>] = [];
|
||||
ebml::start_tag(ebml_w, tag_items_data);
|
||||
index += [{val: crate_node_id, pos: ebml_w.writer.tell()}];
|
||||
encode_info_for_mod(ebml_w, crate_mod, crate_node_id);
|
||||
encode_info_for_mod(ebml_w, crate_mod, crate_node_id, "");
|
||||
ecx.ccx.ast_map.items {|key, val|
|
||||
alt val {
|
||||
middle::ast_map::node_item(i) {
|
||||
|
@ -1353,7 +1353,25 @@ fn ns_for_def(d: def) -> namespace {
|
||||
fn lookup_external(e: env, cnum: int, ids: [ident], ns: namespace) ->
|
||||
option::t<def> {
|
||||
for d: def in csearch::lookup_defs(e.sess.get_cstore(), cnum, ids) {
|
||||
e.ext_map.insert(def_id_of_def(d), ids);
|
||||
let did = def_id_of_def(d);
|
||||
alt d {
|
||||
def_mod(_) | def_native_mod(_) {
|
||||
// The [native] module name might have renamed when importing,
|
||||
// find the original name for further lookup of names inside the
|
||||
// [native] module
|
||||
if did.crate != ast::local_crate {
|
||||
let cname = cstore::get_crate_data(e.cstore, did.crate).name;
|
||||
let name =
|
||||
csearch::get_item_name(e.cstore, did.crate, did.node);
|
||||
e.ext_map.insert(did, vec::init(ids) + [name]);
|
||||
} else {
|
||||
e.ext_map.insert(did, ids);
|
||||
}
|
||||
}
|
||||
_ {
|
||||
e.ext_map.insert(did, ids);
|
||||
}
|
||||
}
|
||||
if ns == ns_for_def(d) { ret some(d); }
|
||||
}
|
||||
ret none::<def>;
|
||||
|
Loading…
Reference in New Issue
Block a user