Skip to content

Commit 7ae711f

Browse files
committed
Begin splitting metadata::decoder into decoding and crate search modules
1 parent cc29240 commit 7ae711f

File tree

6 files changed

+57
-14
lines changed

6 files changed

+57
-14
lines changed

src/comp/metadata/csearch.rs

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import driver::session;
2+
import syntax::ast;
3+
import middle::ty;
4+
import std::io;
5+
6+
fn get_symbol(session::session sess, ast::def_id def) -> str {
7+
decoder::get_symbol(sess, def)
8+
}
9+
10+
fn get_tag_variants(ty::ctxt ctx, ast::def_id def) -> ty::variant_info[] {
11+
decoder::get_tag_variants(ctx, def)
12+
}
13+
14+
fn get_type(ty::ctxt tcx, ast::def_id def) -> ty::ty_param_count_and_ty {
15+
decoder::get_type(tcx, def)
16+
}
17+
18+
fn get_type_param_count(ty::ctxt tcx, &ast::def_id def) -> uint {
19+
decoder::get_type_param_count(tcx, def)
20+
}
21+
22+
fn lookup_defs(session::session sess, ast::crate_num cnum,
23+
vec[ast::ident] path) -> vec[ast::def] {
24+
decoder::lookup_defs(sess, cnum, path)
25+
}
26+
27+
fn get_crate_attributes(&vec[u8] data) -> ast::attribute[] {
28+
decoder::get_crate_attributes(data)
29+
}
30+
31+
fn list_crate_metadata(vec[u8] data, io::writer out) {
32+
decoder::list_crate_metadata(data, out)
33+
}
34+
35+
36+
// Local Variables:
37+
// mode: rust
38+
// fill-column: 78;
39+
// indent-tabs-mode: nil
40+
// c-basic-offset: 4
41+
// buffer-file-coding-system: utf-8-unix
42+
// compile-command: "make -k -C $RBUILD 2>&1 | sed -e 's/\\/x\\//x:\\//g'";
43+
// End:

src/comp/middle/resolve.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import ast::def_id;
77
import ast::node_id;
88
import ast::local_def;
99

10-
import metadata::decoder;
10+
import metadata::csearch;
1111
import metadata::cstore;
1212
import driver::session::session;
1313
import util::common::new_def_hash;
@@ -1143,7 +1143,7 @@ fn ns_for_def(def d) -> namespace {
11431143

11441144
fn lookup_external(&env e, int cnum, vec[ident] ids, namespace ns) ->
11451145
option::t[def] {
1146-
for (def d in decoder::lookup_defs(e.sess, cnum, ids)) {
1146+
for (def d in csearch::lookup_defs(e.sess, cnum, ids)) {
11471147
e.ext_map.insert(ast::def_id_of_def(d), ids);
11481148
if (ns == ns_for_def(d)) { ret some(d); }
11491149
}

src/comp/middle/trans.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ import link::mangle_internal_name_by_path_and_seq;
6565
import link::mangle_exported_name;
6666
import metadata::tyencode;
6767
import metadata::creader;
68-
import metadata::decoder;
68+
import metadata::csearch;
6969
import metadata::cstore;
7070
import util::ppaux::ty_to_str;
7171
import util::ppaux::ty_to_short_str;
@@ -2220,12 +2220,12 @@ fn trans_res_drop(@block_ctxt cx, ValueRef rs, &ast::def_id did,
22202220
case (_) { ccx.tcx.sess.bug("internal error in trans_res_drop") }
22212221
}
22222222
} else {
2223-
auto params = decoder::get_type_param_count(ccx.tcx, did);
2223+
auto params = csearch::get_type_param_count(ccx.tcx, did);
22242224
auto f_t = type_of_fn(ccx, cx.sp, ast::proto_fn,
22252225
~[rec(mode=ty::mo_alias(false), ty=inner_t)],
22262226
ty::mk_nil(ccx.tcx), params);
22272227
get_extern_const(ccx.externs, ccx.llmod,
2228-
decoder::get_symbol(ccx.sess, did),
2228+
csearch::get_symbol(ccx.sess, did),
22292229
T_fn_pair(ccx.tn, f_t))
22302230
};
22312231
auto dtor_addr = cx.build.Load
@@ -4942,7 +4942,7 @@ fn lval_val(&@block_ctxt cx, ValueRef val) -> lval_result {
49424942
fn trans_external_path(&@block_ctxt cx, &ast::def_id did,
49434943
&ty::ty_param_count_and_ty tpt) -> lval_result {
49444944
auto lcx = cx.fcx.lcx;
4945-
auto name = decoder::get_symbol(lcx.ccx.sess, did);
4945+
auto name = csearch::get_symbol(lcx.ccx.sess, did);
49464946
auto v =
49474947
get_extern_const(lcx.ccx.externs, lcx.ccx.llmod, name,
49484948
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)
49884988
// It's an external discriminant that we haven't seen yet.
49894989

49904990
assert (vid._0 != ast::local_crate);
4991-
auto sym = decoder::get_symbol(lcx.ccx.sess, vid);
4991+
auto sym = csearch::get_symbol(lcx.ccx.sess, vid);
49924992
auto gvar =
49934993
llvm::LLVMAddGlobal(lcx.ccx.llmod, T_int(), str::buf(sym));
49944994
llvm::LLVMSetLinkage(gvar,

src/comp/middle/ty.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ import ast::controlflow;
2121
import ast::path_to_str;
2222
import ast::spanned;
2323
import syntax::codemap::span;
24-
import metadata::creader;
25-
import metadata::decoder;
24+
import metadata::csearch;
2625
import util::common::*;
2726
import syntax::util::interner;
2827
import util::ppaux::ty_to_str;
@@ -2814,7 +2813,7 @@ fn def_has_ty_params(&ast::def def) -> bool {
28142813
type variant_info = rec(ty::t[] args, ty::t ctor_ty, ast::def_id id);
28152814

28162815
fn tag_variants(&ctxt cx, &ast::def_id id) -> variant_info[] {
2817-
if (ast::local_crate != id._0) { ret decoder::get_tag_variants(cx, id); }
2816+
if (ast::local_crate != id._0) { ret csearch::get_tag_variants(cx, id); }
28182817
auto item = alt (cx.items.find(id._1)) {
28192818
case (some(?i)) { i }
28202819
case (none) {
@@ -2875,7 +2874,7 @@ fn lookup_item_type(ctxt cx, ast::def_id did) -> ty_param_count_and_ty {
28752874
alt (cx.tcache.find(did)) {
28762875
case (some(?tpt)) { ret tpt; }
28772876
case (none) {
2878-
auto tyt = decoder::get_type(cx, did);
2877+
auto tyt = csearch::get_type(cx, did);
28792878
cx.tcache.insert(did, tyt);
28802879
ret tyt;
28812880
}

src/comp/middle/typeck.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import ast::local_def;
55
import ast::path_to_str;
66
import ast::respan;
77
import syntax::walk;
8-
import metadata::decoder;
8+
import metadata::csearch;
99
import driver::session;
1010
import util::common;
1111
import syntax::codemap::span;
@@ -522,7 +522,7 @@ mod collect {
522522
fn getter(@ctxt cx, &ast::def_id id) -> ty::ty_param_count_and_ty {
523523
if (id._0 != ast::local_crate) {
524524
// This is a type we need to load in from the crate reader.
525-
ret decoder::get_type(cx.tcx, id);
525+
ret csearch::get_type(cx.tcx, id);
526526
}
527527
auto it = cx.tcx.items.find(id._1);
528528
auto tpt;

src/comp/rustc.rc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,9 @@ mod back {
7979
mod metadata {
8080
export tyencode;
8181
export encoder;
82-
export decoder;
8382
export creader;
8483
export cstore;
84+
export csearch;
8585

8686
mod common;
8787
mod tyencode;
@@ -90,6 +90,7 @@ mod metadata {
9090
mod decoder;
9191
mod creader;
9292
mod cstore;
93+
mod csearch;
9394
}
9495

9596
mod driver {

0 commit comments

Comments
 (0)