Don't thread the local crate number through the session
It's a constant, anyway.
This commit is contained in:
parent
6fd6fdea93
commit
4349eaed84
@ -344,11 +344,8 @@ fn build_session_options(str binary, getopts::match match, str binary_dir) ->
|
||||
fn build_session(@session::options sopts) -> session::session {
|
||||
auto target_cfg = build_target_config();
|
||||
auto crate_cache = syntax::_std::new_int_hash[session::crate_metadata]();
|
||||
auto target_crate_num = 0;
|
||||
auto sess =
|
||||
session::session(target_crate_num, target_cfg, sopts, crate_cache, [],
|
||||
ret session::session(target_cfg, sopts, crate_cache, [],
|
||||
[], [], codemap::new_codemap(), 0u);
|
||||
ret sess;
|
||||
}
|
||||
|
||||
fn parse_pretty(session::session sess, &str name) -> pp_mode {
|
||||
|
@ -41,8 +41,7 @@ type options =
|
||||
|
||||
type crate_metadata = rec(str name, vec[u8] data);
|
||||
|
||||
obj session(ast::crate_num cnum,
|
||||
@config targ_cfg,
|
||||
obj session(@config targ_cfg,
|
||||
@options opts,
|
||||
map::hashmap[int, crate_metadata] crates,
|
||||
mutable vec[str] used_crate_files,
|
||||
@ -52,7 +51,6 @@ obj session(ast::crate_num cnum,
|
||||
mutable uint err_count) {
|
||||
fn get_targ_cfg() -> @config { ret targ_cfg; }
|
||||
fn get_opts() -> @options { ret opts; }
|
||||
fn get_targ_crate_num() -> ast::crate_num { ret cnum; }
|
||||
fn span_fatal(span sp, str msg) -> ! {
|
||||
// FIXME: Use constants, but rustboot doesn't know how to export them.
|
||||
codemap::emit_error(some(sp), msg, cm);
|
||||
|
@ -4816,7 +4816,7 @@ fn trans_external_path(&@block_ctxt cx, &ast::def_id did,
|
||||
fn lval_generic_fn(&@block_ctxt cx, &ty::ty_param_count_and_ty tpt,
|
||||
&ast::def_id fn_id, ast::node_id id) -> lval_result {
|
||||
auto lv;
|
||||
if (cx.fcx.lcx.ccx.sess.get_targ_crate_num() == fn_id._0) {
|
||||
if (fn_id._0 == ast::local_crate) {
|
||||
// Internal reference.
|
||||
assert (cx.fcx.lcx.ccx.fn_pairs.contains_key(fn_id._1));
|
||||
lv = lval_val(cx, cx.fcx.lcx.ccx.fn_pairs.get(fn_id._1));
|
||||
@ -4851,7 +4851,7 @@ fn lookup_discriminant(&@local_ctxt lcx, &ast::def_id tid, &ast::def_id vid)
|
||||
case (none) {
|
||||
// It's an external discriminant that we haven't seen yet.
|
||||
|
||||
assert (lcx.ccx.sess.get_targ_crate_num() != vid._0);
|
||||
assert (vid._0 != ast::local_crate);
|
||||
auto sym = decoder::get_symbol(lcx.ccx.sess, vid);
|
||||
auto gvar =
|
||||
llvm::LLVMAddGlobal(lcx.ccx.llmod, T_int(), str::buf(sym));
|
||||
|
@ -2802,7 +2802,7 @@ fn def_has_ty_params(&ast::def def) -> bool {
|
||||
type variant_info = rec(vec[ty::t] args, ty::t ctor_ty, ast::def_id id);
|
||||
|
||||
fn tag_variants(&ctxt cx, &ast::def_id id) -> vec[variant_info] {
|
||||
if (cx.sess.get_targ_crate_num() != id._0) {
|
||||
if (ast::local_crate != id._0) {
|
||||
ret decoder::get_tag_variants(cx, id);
|
||||
}
|
||||
auto item = alt (cx.items.find(id._1)) {
|
||||
@ -2857,7 +2857,7 @@ fn tag_variant_with_id(&ctxt cx, &ast::def_id tag_id, &ast::def_id variant_id)
|
||||
// If the given item is in an external crate, looks up its type and adds it to
|
||||
// the type cache. Returns the type parameters and type.
|
||||
fn lookup_item_type(ctxt cx, ast::def_id did) -> ty_param_count_and_ty {
|
||||
if (did._0 == cx.sess.get_targ_crate_num()) {
|
||||
if (did._0 == ast::local_crate) {
|
||||
// The item is in this crate. The caller should have added it to the
|
||||
// type cache already; we simply return it.
|
||||
|
||||
|
@ -521,9 +521,8 @@ mod collect {
|
||||
ret tpt;
|
||||
}
|
||||
fn getter(@ctxt cx, &ast::def_id id) -> ty::ty_param_count_and_ty {
|
||||
if (id._0 != cx.tcx.sess.get_targ_crate_num()) {
|
||||
if (id._0 != ast::local_crate) {
|
||||
// This is a type we need to load in from the crate reader.
|
||||
|
||||
ret decoder::get_type(cx.tcx, id);
|
||||
}
|
||||
auto it = cx.tcx.items.find(id._1);
|
||||
|
Loading…
x
Reference in New Issue
Block a user