1
Fork 0

rustc: Break a dependency between metadata and resolve

This commit is contained in:
Brian Anderson 2012-05-16 21:50:17 -07:00
parent b329e1c719
commit 6a41eb0192
2 changed files with 28 additions and 18 deletions

View file

@ -48,7 +48,7 @@ type encode_parms = {
diag: span_handler, diag: span_handler,
tcx: ty::ctxt, tcx: ty::ctxt,
reachable: hashmap<ast::node_id, ()>, reachable: hashmap<ast::node_id, ()>,
exp_map: resolve::exp_map, reexports: [(str, def_id)],
impl_map: resolve::impl_map, impl_map: resolve::impl_map,
item_symbols: hashmap<ast::node_id, str>, item_symbols: hashmap<ast::node_id, str>,
discrim_symbols: hashmap<ast::node_id, str>, discrim_symbols: hashmap<ast::node_id, str>,
@ -61,7 +61,7 @@ enum encode_ctxt = {
diag: span_handler, diag: span_handler,
tcx: ty::ctxt, tcx: ty::ctxt,
reachable: hashmap<ast::node_id, ()>, reachable: hashmap<ast::node_id, ()>,
exp_map: resolve::exp_map, reexports: [(str, def_id)],
impl_map: resolve::impl_map, impl_map: resolve::impl_map,
item_symbols: hashmap<ast::node_id, str>, item_symbols: hashmap<ast::node_id, str>,
discrim_symbols: hashmap<ast::node_id, str>, discrim_symbols: hashmap<ast::node_id, str>,
@ -260,19 +260,13 @@ fn encode_item_paths(ebml_w: ebml::writer, ecx: @encode_ctxt, crate: @crate)
fn encode_reexport_paths(ebml_w: ebml::writer, fn encode_reexport_paths(ebml_w: ebml::writer,
ecx: @encode_ctxt, &index: [entry<str>]) { ecx: @encode_ctxt, &index: [entry<str>]) {
let tcx = ecx.tcx; for ecx.reexports.each {|reexport|
for ecx.exp_map.each {|exp_id, defs| let (path, def_id) = reexport;
for defs.each {|def| index += [{val: path, pos: ebml_w.writer.tell()}];
if !def.reexp { cont; } ebml_w.start_tag(tag_paths_data_item);
let path = alt check tcx.items.get(exp_id) { encode_name(ebml_w, path);
ast_map::node_export(_, path) { ast_map::path_to_str(*path) } encode_def_id(ebml_w, def_id);
}; ebml_w.end_tag();
index += [{val: path, pos: ebml_w.writer.tell()}];
ebml_w.start_tag(tag_paths_data_item);
encode_name(ebml_w, path);
encode_def_id(ebml_w, def.id);
ebml_w.end_tag();
}
} }
} }
@ -1071,7 +1065,7 @@ fn encode_metadata(parms: encode_parms, crate: @crate) -> [u8] {
diag: parms.diag, diag: parms.diag,
tcx: parms.tcx, tcx: parms.tcx,
reachable: parms.reachable, reachable: parms.reachable,
exp_map: parms.exp_map, reexports: parms.reexports,
impl_map: parms.impl_map, impl_map: parms.impl_map,
item_symbols: parms.item_symbols, item_symbols: parms.item_symbols,
discrim_symbols: parms.discrim_symbols, discrim_symbols: parms.discrim_symbols,

View file

@ -5197,17 +5197,33 @@ fn crate_ctxt_to_encode_parms(cx: @crate_ctxt)
let encode_inlined_item = let encode_inlined_item =
bind astencode::encode_inlined_item(_, _, _, _, cx.maps); bind astencode::encode_inlined_item(_, _, _, _, cx.maps);
{ ret {
diag: cx.sess.diagnostic(), diag: cx.sess.diagnostic(),
tcx: cx.tcx, tcx: cx.tcx,
reachable: cx.reachable, reachable: cx.reachable,
exp_map: cx.exp_map, reexports: reexports(cx),
impl_map: cx.maps.impl_map, impl_map: cx.maps.impl_map,
item_symbols: cx.item_symbols, item_symbols: cx.item_symbols,
discrim_symbols: cx.discrim_symbols, discrim_symbols: cx.discrim_symbols,
link_meta: cx.link_meta, link_meta: cx.link_meta,
cstore: cx.sess.cstore, cstore: cx.sess.cstore,
encode_inlined_item: encode_inlined_item encode_inlined_item: encode_inlined_item
};
fn reexports(cx: @crate_ctxt) -> [(str, ast::def_id)] {
let mut reexports = [];
for cx.exp_map.each {|exp_id, defs|
for defs.each {|def|
if !def.reexp { cont; }
let path = alt check cx.tcx.items.get(exp_id) {
ast_map::node_export(_, path) {
ast_map::path_to_str(*path)
}
};
reexports += [(path, def.id)];
}
}
ret reexports;
} }
} }