mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-05 11:33:04 +00:00
Begin splitting metadata::decoder into decoding and crate search modules
This commit is contained in:
parent
cc2924068f
commit
7ae711fc03
43
src/comp/metadata/csearch.rs
Normal file
43
src/comp/metadata/csearch.rs
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
import driver::session;
|
||||||
|
import syntax::ast;
|
||||||
|
import middle::ty;
|
||||||
|
import std::io;
|
||||||
|
|
||||||
|
fn get_symbol(session::session sess, ast::def_id def) -> str {
|
||||||
|
decoder::get_symbol(sess, def)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_tag_variants(ty::ctxt ctx, ast::def_id def) -> ty::variant_info[] {
|
||||||
|
decoder::get_tag_variants(ctx, def)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_type(ty::ctxt tcx, ast::def_id def) -> ty::ty_param_count_and_ty {
|
||||||
|
decoder::get_type(tcx, def)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_type_param_count(ty::ctxt tcx, &ast::def_id def) -> uint {
|
||||||
|
decoder::get_type_param_count(tcx, def)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn lookup_defs(session::session sess, ast::crate_num cnum,
|
||||||
|
vec[ast::ident] path) -> vec[ast::def] {
|
||||||
|
decoder::lookup_defs(sess, cnum, path)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_crate_attributes(&vec[u8] data) -> ast::attribute[] {
|
||||||
|
decoder::get_crate_attributes(data)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn list_crate_metadata(vec[u8] data, io::writer out) {
|
||||||
|
decoder::list_crate_metadata(data, out)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Local Variables:
|
||||||
|
// mode: rust
|
||||||
|
// fill-column: 78;
|
||||||
|
// indent-tabs-mode: nil
|
||||||
|
// c-basic-offset: 4
|
||||||
|
// buffer-file-coding-system: utf-8-unix
|
||||||
|
// compile-command: "make -k -C $RBUILD 2>&1 | sed -e 's/\\/x\\//x:\\//g'";
|
||||||
|
// End:
|
@ -7,7 +7,7 @@ import ast::def_id;
|
|||||||
import ast::node_id;
|
import ast::node_id;
|
||||||
import ast::local_def;
|
import ast::local_def;
|
||||||
|
|
||||||
import metadata::decoder;
|
import metadata::csearch;
|
||||||
import metadata::cstore;
|
import metadata::cstore;
|
||||||
import driver::session::session;
|
import driver::session::session;
|
||||||
import util::common::new_def_hash;
|
import util::common::new_def_hash;
|
||||||
@ -1143,7 +1143,7 @@ fn ns_for_def(def d) -> namespace {
|
|||||||
|
|
||||||
fn lookup_external(&env e, int cnum, vec[ident] ids, namespace ns) ->
|
fn lookup_external(&env e, int cnum, vec[ident] ids, namespace ns) ->
|
||||||
option::t[def] {
|
option::t[def] {
|
||||||
for (def d in decoder::lookup_defs(e.sess, cnum, ids)) {
|
for (def d in csearch::lookup_defs(e.sess, cnum, ids)) {
|
||||||
e.ext_map.insert(ast::def_id_of_def(d), ids);
|
e.ext_map.insert(ast::def_id_of_def(d), ids);
|
||||||
if (ns == ns_for_def(d)) { ret some(d); }
|
if (ns == ns_for_def(d)) { ret some(d); }
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,7 @@ import link::mangle_internal_name_by_path_and_seq;
|
|||||||
import link::mangle_exported_name;
|
import link::mangle_exported_name;
|
||||||
import metadata::tyencode;
|
import metadata::tyencode;
|
||||||
import metadata::creader;
|
import metadata::creader;
|
||||||
import metadata::decoder;
|
import metadata::csearch;
|
||||||
import metadata::cstore;
|
import metadata::cstore;
|
||||||
import util::ppaux::ty_to_str;
|
import util::ppaux::ty_to_str;
|
||||||
import util::ppaux::ty_to_short_str;
|
import util::ppaux::ty_to_short_str;
|
||||||
@ -2220,12 +2220,12 @@ fn trans_res_drop(@block_ctxt cx, ValueRef rs, &ast::def_id did,
|
|||||||
case (_) { ccx.tcx.sess.bug("internal error in trans_res_drop") }
|
case (_) { ccx.tcx.sess.bug("internal error in trans_res_drop") }
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
auto params = decoder::get_type_param_count(ccx.tcx, did);
|
auto params = csearch::get_type_param_count(ccx.tcx, did);
|
||||||
auto f_t = type_of_fn(ccx, cx.sp, ast::proto_fn,
|
auto f_t = type_of_fn(ccx, cx.sp, ast::proto_fn,
|
||||||
~[rec(mode=ty::mo_alias(false), ty=inner_t)],
|
~[rec(mode=ty::mo_alias(false), ty=inner_t)],
|
||||||
ty::mk_nil(ccx.tcx), params);
|
ty::mk_nil(ccx.tcx), params);
|
||||||
get_extern_const(ccx.externs, ccx.llmod,
|
get_extern_const(ccx.externs, ccx.llmod,
|
||||||
decoder::get_symbol(ccx.sess, did),
|
csearch::get_symbol(ccx.sess, did),
|
||||||
T_fn_pair(ccx.tn, f_t))
|
T_fn_pair(ccx.tn, f_t))
|
||||||
};
|
};
|
||||||
auto dtor_addr = cx.build.Load
|
auto dtor_addr = cx.build.Load
|
||||||
@ -4942,7 +4942,7 @@ fn lval_val(&@block_ctxt cx, ValueRef val) -> lval_result {
|
|||||||
fn trans_external_path(&@block_ctxt cx, &ast::def_id did,
|
fn trans_external_path(&@block_ctxt cx, &ast::def_id did,
|
||||||
&ty::ty_param_count_and_ty tpt) -> lval_result {
|
&ty::ty_param_count_and_ty tpt) -> lval_result {
|
||||||
auto lcx = cx.fcx.lcx;
|
auto lcx = cx.fcx.lcx;
|
||||||
auto name = decoder::get_symbol(lcx.ccx.sess, did);
|
auto name = csearch::get_symbol(lcx.ccx.sess, did);
|
||||||
auto v =
|
auto v =
|
||||||
get_extern_const(lcx.ccx.externs, lcx.ccx.llmod, name,
|
get_extern_const(lcx.ccx.externs, lcx.ccx.llmod, name,
|
||||||
type_of_ty_param_count_and_ty(lcx, cx.sp, tpt));
|
type_of_ty_param_count_and_ty(lcx, cx.sp, tpt));
|
||||||
@ -4988,7 +4988,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.
|
// It's an external discriminant that we haven't seen yet.
|
||||||
|
|
||||||
assert (vid._0 != ast::local_crate);
|
assert (vid._0 != ast::local_crate);
|
||||||
auto sym = decoder::get_symbol(lcx.ccx.sess, vid);
|
auto sym = csearch::get_symbol(lcx.ccx.sess, vid);
|
||||||
auto gvar =
|
auto gvar =
|
||||||
llvm::LLVMAddGlobal(lcx.ccx.llmod, T_int(), str::buf(sym));
|
llvm::LLVMAddGlobal(lcx.ccx.llmod, T_int(), str::buf(sym));
|
||||||
llvm::LLVMSetLinkage(gvar,
|
llvm::LLVMSetLinkage(gvar,
|
||||||
|
@ -21,8 +21,7 @@ import ast::controlflow;
|
|||||||
import ast::path_to_str;
|
import ast::path_to_str;
|
||||||
import ast::spanned;
|
import ast::spanned;
|
||||||
import syntax::codemap::span;
|
import syntax::codemap::span;
|
||||||
import metadata::creader;
|
import metadata::csearch;
|
||||||
import metadata::decoder;
|
|
||||||
import util::common::*;
|
import util::common::*;
|
||||||
import syntax::util::interner;
|
import syntax::util::interner;
|
||||||
import util::ppaux::ty_to_str;
|
import util::ppaux::ty_to_str;
|
||||||
@ -2814,7 +2813,7 @@ fn def_has_ty_params(&ast::def def) -> bool {
|
|||||||
type variant_info = rec(ty::t[] args, ty::t ctor_ty, ast::def_id id);
|
type variant_info = rec(ty::t[] args, ty::t ctor_ty, ast::def_id id);
|
||||||
|
|
||||||
fn tag_variants(&ctxt cx, &ast::def_id id) -> variant_info[] {
|
fn tag_variants(&ctxt cx, &ast::def_id id) -> variant_info[] {
|
||||||
if (ast::local_crate != id._0) { ret decoder::get_tag_variants(cx, id); }
|
if (ast::local_crate != id._0) { ret csearch::get_tag_variants(cx, id); }
|
||||||
auto item = alt (cx.items.find(id._1)) {
|
auto item = alt (cx.items.find(id._1)) {
|
||||||
case (some(?i)) { i }
|
case (some(?i)) { i }
|
||||||
case (none) {
|
case (none) {
|
||||||
@ -2875,7 +2874,7 @@ fn lookup_item_type(ctxt cx, ast::def_id did) -> ty_param_count_and_ty {
|
|||||||
alt (cx.tcache.find(did)) {
|
alt (cx.tcache.find(did)) {
|
||||||
case (some(?tpt)) { ret tpt; }
|
case (some(?tpt)) { ret tpt; }
|
||||||
case (none) {
|
case (none) {
|
||||||
auto tyt = decoder::get_type(cx, did);
|
auto tyt = csearch::get_type(cx, did);
|
||||||
cx.tcache.insert(did, tyt);
|
cx.tcache.insert(did, tyt);
|
||||||
ret tyt;
|
ret tyt;
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@ import ast::local_def;
|
|||||||
import ast::path_to_str;
|
import ast::path_to_str;
|
||||||
import ast::respan;
|
import ast::respan;
|
||||||
import syntax::walk;
|
import syntax::walk;
|
||||||
import metadata::decoder;
|
import metadata::csearch;
|
||||||
import driver::session;
|
import driver::session;
|
||||||
import util::common;
|
import util::common;
|
||||||
import syntax::codemap::span;
|
import syntax::codemap::span;
|
||||||
@ -522,7 +522,7 @@ mod collect {
|
|||||||
fn getter(@ctxt cx, &ast::def_id id) -> ty::ty_param_count_and_ty {
|
fn getter(@ctxt cx, &ast::def_id id) -> ty::ty_param_count_and_ty {
|
||||||
if (id._0 != ast::local_crate) {
|
if (id._0 != ast::local_crate) {
|
||||||
// This is a type we need to load in from the crate reader.
|
// This is a type we need to load in from the crate reader.
|
||||||
ret decoder::get_type(cx.tcx, id);
|
ret csearch::get_type(cx.tcx, id);
|
||||||
}
|
}
|
||||||
auto it = cx.tcx.items.find(id._1);
|
auto it = cx.tcx.items.find(id._1);
|
||||||
auto tpt;
|
auto tpt;
|
||||||
|
@ -79,9 +79,9 @@ mod back {
|
|||||||
mod metadata {
|
mod metadata {
|
||||||
export tyencode;
|
export tyencode;
|
||||||
export encoder;
|
export encoder;
|
||||||
export decoder;
|
|
||||||
export creader;
|
export creader;
|
||||||
export cstore;
|
export cstore;
|
||||||
|
export csearch;
|
||||||
|
|
||||||
mod common;
|
mod common;
|
||||||
mod tyencode;
|
mod tyencode;
|
||||||
@ -90,6 +90,7 @@ mod metadata {
|
|||||||
mod decoder;
|
mod decoder;
|
||||||
mod creader;
|
mod creader;
|
||||||
mod cstore;
|
mod cstore;
|
||||||
|
mod csearch;
|
||||||
}
|
}
|
||||||
|
|
||||||
mod driver {
|
mod driver {
|
||||||
|
Loading…
Reference in New Issue
Block a user