rustc: Remove resolve_path
This commit is contained in:
parent
75d3e3c755
commit
8f01343f01
src/rustc/metadata
@ -50,30 +50,6 @@ fn lookup_method_purity(cstore: cstore::cstore, did: ast::def_id)
|
||||
}
|
||||
}
|
||||
|
||||
/* Returns a vector of possible def IDs for a given path,
|
||||
in a given crate */
|
||||
fn resolve_path(cstore: cstore::cstore, cnum: ast::crate_num,
|
||||
path: ~[ast::ident]) ->
|
||||
~[(ast::crate_num, @~[u8], ast::def_id)] {
|
||||
let cm = cstore::get_crate_data(cstore, cnum);
|
||||
debug!{"resolve_path %s in crates[%d]:%s",
|
||||
ast_util::path_name_i(path), cnum, cm.name};
|
||||
let mut result = ~[];
|
||||
for decoder::resolve_path(path, cm.data).each |def| {
|
||||
if def.crate == ast::local_crate {
|
||||
vec::push(result, (cnum, cm.data, def));
|
||||
} else {
|
||||
if cm.cnum_map.contains_key(def.crate) {
|
||||
// This reexport is itself a reexport from another crate
|
||||
let next_cnum = cm.cnum_map.get(def.crate);
|
||||
let next_cm_data = cstore::get_crate_data(cstore, next_cnum);
|
||||
vec::push(result, (next_cnum, next_cm_data.data, def));
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/// Iterates over all the paths in the given crate.
|
||||
fn each_path(cstore: cstore::cstore, cnum: ast::crate_num,
|
||||
f: fn(decoder::path_entry) -> bool) {
|
||||
|
@ -213,38 +213,6 @@ fn enum_variant_ids(item: ebml::doc, cdata: cmd) -> ~[ast::def_id] {
|
||||
return ids;
|
||||
}
|
||||
|
||||
// Given a path and serialized crate metadata, returns the IDs of the
|
||||
// definitions the path may refer to.
|
||||
fn resolve_path(path: ~[ast::ident], data: @~[u8]) -> ~[ast::def_id] {
|
||||
fn eq_item(data: &[u8], s: ~str) -> bool {
|
||||
// XXX: Use string equality.
|
||||
let data_len = data.len();
|
||||
let s_len = s.len();
|
||||
if data_len != s_len {
|
||||
return false;
|
||||
}
|
||||
let mut i = 0;
|
||||
while i < data_len {
|
||||
if data[i] != s[i] {
|
||||
return false;
|
||||
}
|
||||
i += 1;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
let s = ast_util::path_name_i(path);
|
||||
let md = ebml::doc(data);
|
||||
let paths = ebml::get_doc(md, tag_paths);
|
||||
let eqer = |a| eq_item(a, s);
|
||||
let mut result: ~[ast::def_id] = ~[];
|
||||
debug!{"resolve_path: looking up %s", s};
|
||||
for lookup_hash(paths, eqer, hash_path(s)).each |doc| {
|
||||
let did_doc = ebml::get_doc(doc, tag_def_id);
|
||||
vec::push(result, ebml::with_doc_data(did_doc, |d| parse_def_id(d)));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
fn item_path(item_doc: ebml::doc) -> ast_map::path {
|
||||
let path_doc = ebml::get_doc(item_doc, tag_path);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user