mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-05 11:33:04 +00:00
Make the interface to metadata::csearch more consistent
This commit is contained in:
parent
85212840c0
commit
06391dda02
@ -1,35 +1,37 @@
|
||||
import driver::session;
|
||||
import syntax::ast;
|
||||
import middle::ty;
|
||||
import std::io;
|
||||
|
||||
fn get_symbol(session::session sess, ast::def_id def) -> str {
|
||||
fn get_symbol(&cstore::cstore cstore, ast::def_id def) -> str {
|
||||
auto cnum = def._0;
|
||||
auto node_id = def._1;
|
||||
auto cstore = sess.get_cstore();
|
||||
auto cdata = cstore::get_crate_data(cstore, cnum).data;
|
||||
ret decoder::get_symbol(cdata, node_id);
|
||||
}
|
||||
|
||||
fn get_tag_variants(ty::ctxt tcx, ast::def_id def) -> ty::variant_info[] {
|
||||
decoder::get_tag_variants(tcx, def)
|
||||
auto cstore = tcx.sess.get_cstore();
|
||||
auto cnum = def._0;
|
||||
auto cdata = cstore::get_crate_data(cstore, cnum).data;
|
||||
ret decoder::get_tag_variants(cdata, def, tcx)
|
||||
}
|
||||
|
||||
fn get_type(ty::ctxt tcx, ast::def_id def) -> ty::ty_param_count_and_ty {
|
||||
decoder::get_type(tcx, def)
|
||||
auto cstore = tcx.sess.get_cstore();
|
||||
auto cnum = def._0;
|
||||
auto cdata = cstore::get_crate_data(cstore, cnum).data;
|
||||
decoder::get_type(cdata, def, tcx)
|
||||
}
|
||||
|
||||
fn get_type_param_count(ty::ctxt tcx, &ast::def_id def) -> uint {
|
||||
fn get_type_param_count(&cstore::cstore cstore, &ast::def_id def) -> uint {
|
||||
auto cnum = def._0;
|
||||
auto node_id = def._1;
|
||||
auto cstore = tcx.sess.get_cstore();
|
||||
auto cdata = cstore::get_crate_data(cstore, cnum).data;
|
||||
ret decoder::get_type_param_count(cdata, node_id);
|
||||
}
|
||||
|
||||
fn lookup_defs(session::session sess, ast::crate_num cnum,
|
||||
fn lookup_defs(&cstore::cstore cstore, ast::crate_num cnum,
|
||||
vec[ast::ident] path) -> vec[ast::def] {
|
||||
auto cstore = sess.get_cstore();
|
||||
auto cdata = cstore::get_crate_data(cstore, cnum).data;
|
||||
ret decoder::lookup_defs(cdata, cnum, path);
|
||||
}
|
||||
|
@ -171,12 +171,12 @@ fn lookup_def(ast::crate_num cnum, vec[u8] data,
|
||||
ret def;
|
||||
}
|
||||
|
||||
fn get_type(ty::ctxt tcx, ast::def_id def) -> ty::ty_param_count_and_ty {
|
||||
auto external_crate_id = def._0;
|
||||
auto data = cstore::get_crate_data(tcx.sess.get_cstore(),
|
||||
external_crate_id).data;
|
||||
auto item = lookup_item(def._1, data);
|
||||
auto t = item_type(item, external_crate_id, tcx);
|
||||
fn get_type(&vec[u8] data, ast::def_id def,
|
||||
&ty::ctxt tcx) -> ty::ty_param_count_and_ty {
|
||||
auto this_cnum = def._0;
|
||||
auto node_id = def._1;
|
||||
auto item = lookup_item(node_id, data);
|
||||
auto t = item_type(item, this_cnum, tcx);
|
||||
auto tp_count;
|
||||
auto kind_ch = item_kind(item);
|
||||
auto has_ty_params = kind_has_type_params(kind_ch);
|
||||
@ -194,7 +194,8 @@ fn get_symbol(&vec[u8] data, ast::node_id id) -> str {
|
||||
ret item_symbol(lookup_item(id, data));
|
||||
}
|
||||
|
||||
fn get_tag_variants(ty::ctxt tcx, ast::def_id def) -> ty::variant_info[] {
|
||||
fn get_tag_variants(&vec[u8] data, ast::def_id def,
|
||||
&ty::ctxt tcx) -> ty::variant_info[] {
|
||||
auto external_crate_id = def._0;
|
||||
auto data = cstore::get_crate_data(tcx.sess.get_cstore(),
|
||||
external_crate_id).data;
|
||||
|
@ -1143,7 +1143,7 @@ fn ns_for_def(def d) -> namespace {
|
||||
|
||||
fn lookup_external(&env e, int cnum, vec[ident] ids, namespace ns) ->
|
||||
option::t[def] {
|
||||
for (def d in csearch::lookup_defs(e.sess, cnum, ids)) {
|
||||
for (def d in csearch::lookup_defs(e.sess.get_cstore(), cnum, ids)) {
|
||||
e.ext_map.insert(ast::def_id_of_def(d), ids);
|
||||
if (ns == ns_for_def(d)) { ret some(d); }
|
||||
}
|
||||
|
@ -2220,12 +2220,13 @@ fn trans_res_drop(@block_ctxt cx, ValueRef rs, &ast::def_id did,
|
||||
case (_) { ccx.tcx.sess.bug("internal error in trans_res_drop") }
|
||||
}
|
||||
} else {
|
||||
auto params = csearch::get_type_param_count(ccx.tcx, did);
|
||||
auto params = csearch::get_type_param_count(ccx.sess.get_cstore(),
|
||||
did);
|
||||
auto f_t = type_of_fn(ccx, cx.sp, ast::proto_fn,
|
||||
~[rec(mode=ty::mo_alias(false), ty=inner_t)],
|
||||
ty::mk_nil(ccx.tcx), params);
|
||||
get_extern_const(ccx.externs, ccx.llmod,
|
||||
csearch::get_symbol(ccx.sess, did),
|
||||
csearch::get_symbol(ccx.sess.get_cstore(), did),
|
||||
T_fn_pair(ccx.tn, f_t))
|
||||
};
|
||||
auto dtor_addr = cx.build.Load
|
||||
@ -4942,7 +4943,7 @@ fn lval_val(&@block_ctxt cx, ValueRef val) -> lval_result {
|
||||
fn trans_external_path(&@block_ctxt cx, &ast::def_id did,
|
||||
&ty::ty_param_count_and_ty tpt) -> lval_result {
|
||||
auto lcx = cx.fcx.lcx;
|
||||
auto name = csearch::get_symbol(lcx.ccx.sess, did);
|
||||
auto name = csearch::get_symbol(lcx.ccx.sess.get_cstore(), did);
|
||||
auto v =
|
||||
get_extern_const(lcx.ccx.externs, lcx.ccx.llmod, name,
|
||||
type_of_ty_param_count_and_ty(lcx, cx.sp, tpt));
|
||||
@ -4988,7 +4989,7 @@ fn lookup_discriminant(&@local_ctxt lcx, &ast::def_id tid, &ast::def_id vid)
|
||||
// It's an external discriminant that we haven't seen yet.
|
||||
|
||||
assert (vid._0 != ast::local_crate);
|
||||
auto sym = csearch::get_symbol(lcx.ccx.sess, vid);
|
||||
auto sym = csearch::get_symbol(lcx.ccx.sess.get_cstore(), vid);
|
||||
auto gvar =
|
||||
llvm::LLVMAddGlobal(lcx.ccx.llmod, T_int(), str::buf(sym));
|
||||
llvm::LLVMSetLinkage(gvar,
|
||||
|
Loading…
Reference in New Issue
Block a user