rustc: Break some of metadata's dependencies on session
This commit is contained in:
parent
0f49928c2d
commit
452fc46ffc
|
@ -4,7 +4,6 @@ import std::{ebml, map};
|
|||
import std::map::hashmap;
|
||||
import io::writer_util;
|
||||
import syntax::{ast, ast_util};
|
||||
import driver::session::session;
|
||||
import syntax::attr;
|
||||
import middle::ty;
|
||||
import middle::ast_map;
|
||||
|
@ -15,6 +14,7 @@ import syntax::print::pprust;
|
|||
import cmd=cstore::crate_metadata;
|
||||
import util::ppaux::ty_to_str;
|
||||
import ebml::deserializer;
|
||||
import syntax::diagnostic::span_handler;
|
||||
|
||||
export get_class_fields;
|
||||
export get_symbol;
|
||||
|
@ -455,7 +455,9 @@ fn get_iface_methods(cdata: cmd, id: ast::node_id, tcx: ty::ctxt)
|
|||
let name = item_name(mth);
|
||||
let ty = doc_type(mth, tcx, cdata);
|
||||
let fty = alt ty::get(ty).struct { ty::ty_fn(f) { f }
|
||||
_ { tcx.sess.bug("get_iface_methods: id has non-function type");
|
||||
_ {
|
||||
tcx.diag.handler().bug(
|
||||
"get_iface_methods: id has non-function type");
|
||||
} };
|
||||
result += [{ident: name, tps: bounds, fty: fty,
|
||||
purity: alt check item_family(mth) {
|
||||
|
|
|
@ -19,7 +19,7 @@ import std::serialization::serializer;
|
|||
import std::ebml::serializer;
|
||||
import middle::resolve;
|
||||
import syntax::ast;
|
||||
import driver::session::session;
|
||||
import syntax::diagnostic::span_handler;
|
||||
|
||||
export link_meta;
|
||||
export encode_parms;
|
||||
|
@ -45,6 +45,7 @@ type encode_inlined_item = fn@(ecx: @encode_ctxt,
|
|||
ii: ast::inlined_item);
|
||||
|
||||
type encode_parms = {
|
||||
diag: span_handler,
|
||||
tcx: ty::ctxt,
|
||||
reachable: hashmap<ast::node_id, ()>,
|
||||
exp_map: resolve::exp_map,
|
||||
|
@ -57,6 +58,7 @@ type encode_parms = {
|
|||
};
|
||||
|
||||
enum encode_ctxt = {
|
||||
diag: span_handler,
|
||||
tcx: ty::ctxt,
|
||||
reachable: hashmap<ast::node_id, ()>,
|
||||
exp_map: resolve::exp_map,
|
||||
|
@ -281,7 +283,8 @@ fn def_to_str(did: def_id) -> str { ret #fmt["%d:%d", did.crate, did.node]; }
|
|||
|
||||
fn encode_type_param_bounds(ebml_w: ebml::writer, ecx: @encode_ctxt,
|
||||
params: [ty_param]) {
|
||||
let ty_str_ctxt = @{ds: def_to_str,
|
||||
let ty_str_ctxt = @{diag: ecx.diag,
|
||||
ds: def_to_str,
|
||||
tcx: ecx.tcx,
|
||||
reachable: reachable(ecx, _),
|
||||
abbrevs: tyencode::ac_use_abbrevs(ecx.type_abbrevs)};
|
||||
|
@ -301,7 +304,8 @@ fn encode_variant_id(ebml_w: ebml::writer, vid: def_id) {
|
|||
|
||||
fn write_type(ecx: @encode_ctxt, ebml_w: ebml::writer, typ: ty::t) {
|
||||
let ty_str_ctxt =
|
||||
@{ds: def_to_str,
|
||||
@{diag: ecx.diag,
|
||||
ds: def_to_str,
|
||||
tcx: ecx.tcx,
|
||||
reachable: reachable(ecx, _),
|
||||
abbrevs: tyencode::ac_use_abbrevs(ecx.type_abbrevs)};
|
||||
|
@ -318,8 +322,10 @@ fn encode_symbol(ecx: @encode_ctxt, ebml_w: ebml::writer, id: node_id) {
|
|||
ebml_w.start_tag(tag_items_data_item_symbol);
|
||||
let sym = alt ecx.item_symbols.find(id) {
|
||||
some(x) { x }
|
||||
none { ecx.tcx.sess.bug(#fmt("encode_symbol: \
|
||||
id not found %d", id)); }
|
||||
none {
|
||||
ecx.diag.handler().bug(
|
||||
#fmt("encode_symbol: id not found %d", id));
|
||||
}
|
||||
};
|
||||
ebml_w.writer.write(str::bytes(sym));
|
||||
ebml_w.end_tag();
|
||||
|
@ -426,8 +432,8 @@ fn encode_info_for_mod(ecx: @encode_ctxt, ebml_w: ebml::writer, md: _mod,
|
|||
} // for
|
||||
} // list::cons alt
|
||||
_ {
|
||||
ecx.tcx.sess.bug(#fmt("encode_info_for_mod: empty impl_map \
|
||||
entry for %?", path));
|
||||
ecx.diag.handler().bug(#fmt("encode_info_for_mod: empty impl_map \
|
||||
entry for %?", path));
|
||||
}
|
||||
}
|
||||
encode_path(ebml_w, path, ast_map::path_mod(name));
|
||||
|
@ -1057,6 +1063,7 @@ fn encode_hash(ebml_w: ebml::writer, hash: str) {
|
|||
|
||||
fn encode_metadata(parms: encode_parms, crate: @crate) -> [u8] {
|
||||
let ecx: @encode_ctxt = @encode_ctxt({
|
||||
diag: parms.diag,
|
||||
tcx: parms.tcx,
|
||||
reachable: parms.reachable,
|
||||
exp_map: parms.exp_map,
|
||||
|
@ -1102,7 +1109,8 @@ fn encode_metadata(parms: encode_parms, crate: @crate) -> [u8] {
|
|||
|
||||
// Get the encoded string for a type
|
||||
fn encoded_ty(tcx: ty::ctxt, t: ty::t) -> str {
|
||||
let cx = @{ds: def_to_str,
|
||||
let cx = @{diag: tcx.diag,
|
||||
ds: def_to_str,
|
||||
tcx: tcx,
|
||||
reachable: {|_id| false},
|
||||
abbrevs: tyencode::ac_no_abbrevs};
|
||||
|
|
|
@ -6,8 +6,6 @@ import syntax::ast_util;
|
|||
import syntax::ast_util::respan;
|
||||
import middle::ty;
|
||||
import std::map::hashmap;
|
||||
import driver::session;
|
||||
import session::session;
|
||||
|
||||
export parse_ty_data, parse_def_id, parse_ident;
|
||||
export parse_bounds_data;
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
import io::writer_util;
|
||||
import std::map::hashmap;
|
||||
import syntax::ast::*;
|
||||
import driver::session::session;
|
||||
import syntax::diagnostic::span_handler;
|
||||
import middle::ty;
|
||||
import middle::ty::vid;
|
||||
import syntax::print::pprust::*;
|
||||
|
@ -17,6 +17,7 @@ export enc_bounds;
|
|||
export enc_mode;
|
||||
|
||||
type ctxt = {
|
||||
diag: span_handler,
|
||||
// Def -> str Callback:
|
||||
ds: fn@(def_id) -> str,
|
||||
// The type context.
|
||||
|
@ -145,7 +146,7 @@ fn enc_region(w: io::writer, cx: @ctxt, r: ty::region) {
|
|||
}
|
||||
ty::re_var(_) {
|
||||
// these should not crop up after typeck
|
||||
cx.tcx.sess.bug("Cannot encode region variables");
|
||||
cx.diag.handler().bug("Cannot encode region variables");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -681,7 +681,8 @@ impl helpers for ebml::ebml_deserializer {
|
|||
|
||||
impl helpers for @e::encode_ctxt {
|
||||
fn ty_str_ctxt() -> @tyencode::ctxt {
|
||||
@{ds: e::def_to_str,
|
||||
@{diag: self.tcx.sess.diagnostic(),
|
||||
ds: e::def_to_str,
|
||||
tcx: self.tcx,
|
||||
reachable: encoder::reachable(self, _),
|
||||
abbrevs: tyencode::ac_use_abbrevs(self.type_abbrevs)}
|
||||
|
|
|
@ -4998,6 +4998,7 @@ fn crate_ctxt_to_encode_parms(cx: @crate_ctxt)
|
|||
bind astencode::encode_inlined_item(_, _, _, _, cx.maps);
|
||||
|
||||
{
|
||||
diag: cx.sess.diagnostic(),
|
||||
tcx: cx.tcx,
|
||||
reachable: cx.reachable,
|
||||
exp_map: cx.exp_map,
|
||||
|
|
|
@ -200,7 +200,8 @@ enum ast_ty_to_ty_cache_entry {
|
|||
}
|
||||
|
||||
type ctxt =
|
||||
@{interner: hashmap<intern_key, t_box>,
|
||||
@{diag: syntax::diagnostic::span_handler,
|
||||
interner: hashmap<intern_key, t_box>,
|
||||
mut next_id: uint,
|
||||
sess: session::session,
|
||||
def_map: resolve::def_map,
|
||||
|
@ -462,7 +463,8 @@ fn mk_ctxt(s: session::session, dm: resolve::def_map, amap: ast_map::map,
|
|||
hash_type_structure(k.struct) +
|
||||
option::map_default(k.o_def_id, 0u, ast_util::hash_def_id)
|
||||
}, {|&&a, &&b| a == b});
|
||||
@{interner: interner,
|
||||
@{diag: s.diagnostic(),
|
||||
interner: interner,
|
||||
mut next_id: 0u,
|
||||
sess: s,
|
||||
def_map: dm,
|
||||
|
|
Loading…
Reference in New Issue