Make the interface to metadata::csearch more consistent
This commit is contained in:
parent
85212840c0
commit
06391dda02
4 changed files with 25 additions and 21 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue