Skip to content

Commit 1a79e18

Browse files
committed
---
yaml --- r: 12790 b: refs/heads/master c: fce6a47 h: refs/heads/master v: v3
1 parent a3780e0 commit 1a79e18

File tree

8 files changed

+57
-42
lines changed

8 files changed

+57
-42
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 5c864e9de0d3b09bc682e95d067883216faa17aa
2+
refs/heads/master: fce6a474b1dc1f46b041703f9f66941c0fa4cff2
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
55
refs/heads/try: 2898dcc5d97da9427ac367542382b6239d9c0bbf

trunk/src/rustc/metadata.rs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,3 @@
1-
export maps;
2-
3-
// Auxiliary maps of things to be encoded
4-
type maps = {
5-
mutbl_map: middle::borrowck::mutbl_map,
6-
copy_map: middle::alias::copy_map,
7-
last_uses: middle::last_use::last_uses,
8-
impl_map: middle::resolve::impl_map,
9-
method_map: middle::typeck::method_map,
10-
vtable_map: middle::typeck::vtable_map,
11-
spill_map: middle::last_use::spill_map
12-
};
13-
141
// Define the rustc API's that the metadata module has access to
152
// Over time we will reduce these dependencies and, once metadata has
163
// no dependencies on rustc it can move into its own crate.
@@ -32,8 +19,6 @@ mod middle {
3219
export borrowck;
3320
import alias = middle_::alias;
3421
export alias;
35-
import astencode = middle_::astencode;
36-
export astencode;
3722
}
3823

3924
mod front {

trunk/src/rustc/metadata/csearch.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,13 @@ enum found_ast {
9898
// Finds the AST for this item in the crate metadata, if any. If the item was
9999
// not marked for inlining, then the AST will not be present and hence none
100100
// will be returned.
101-
fn maybe_get_item_ast(tcx: ty::ctxt, maps: maps, def: ast::def_id)
101+
fn maybe_get_item_ast(tcx: ty::ctxt, def: ast::def_id,
102+
decode_inlined_item: decoder::decode_inlined_item)
102103
-> found_ast {
103104
let cstore = tcx.sess.cstore;
104105
let cdata = cstore::get_crate_data(cstore, def.crate);
105-
decoder::maybe_get_item_ast(cdata, tcx, maps, def.node)
106+
decoder::maybe_get_item_ast(cdata, tcx, def.node,
107+
decode_inlined_item)
106108
}
107109

108110
fn get_enum_variants(tcx: ty::ctxt, def: ast::def_id) -> [ty::variant_info] {

trunk/src/rustc/metadata/decoder.rs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import syntax::print::pprust;
1515
import cmd=cstore::crate_metadata;
1616
import util::ppaux::ty_to_str;
1717
import ebml::deserializer;
18-
import middle::astencode;
1918

2019
export get_class_fields;
2120
export get_symbol;
@@ -41,6 +40,7 @@ export get_item_path;
4140
export maybe_find_item; // sketchy
4241
export item_type; // sketchy
4342
export maybe_get_item_ast;
43+
export decode_inlined_item;
4444

4545
// Used internally by astencode:
4646
export translate_def_id;
@@ -339,19 +339,27 @@ fn get_item_path(cdata: cmd, id: ast::node_id) -> ast_map::path {
339339
item_path(lookup_item(id, cdata.data))
340340
}
341341

342-
fn maybe_get_item_ast(cdata: cmd, tcx: ty::ctxt, maps: maps,
343-
id: ast::node_id) -> csearch::found_ast {
342+
type decode_inlined_item = fn(
343+
cdata: cstore::crate_metadata,
344+
tcx: ty::ctxt,
345+
path: ast_map::path,
346+
par_doc: ebml::doc) -> option<ast::inlined_item>;
347+
348+
fn maybe_get_item_ast(cdata: cmd, tcx: ty::ctxt,
349+
id: ast::node_id,
350+
decode_inlined_item: decode_inlined_item
351+
) -> csearch::found_ast {
344352
#debug("Looking up item: %d", id);
345353
let item_doc = lookup_item(id, cdata.data);
346354
let path = vec::init(item_path(item_doc));
347-
alt astencode::decode_inlined_item(cdata, tcx, maps, path, item_doc) {
355+
alt decode_inlined_item(cdata, tcx, path, item_doc) {
348356
some(ii) { csearch::found(ii) }
349357
none {
350358
alt item_parent_item(item_doc) {
351359
some(did) {
352360
let did = translate_def_id(cdata, did);
353361
let parent_item = lookup_item(did.node, cdata.data);
354-
alt astencode::decode_inlined_item(cdata, tcx, maps, path,
362+
alt decode_inlined_item(cdata, tcx, path,
355363
parent_item) {
356364
some(ii) { csearch::found_parent(did, ii) }
357365
none { csearch::not_found }

trunk/src/rustc/metadata/encoder.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,23 +44,23 @@ type encode_parms = {
4444
tcx: ty::ctxt,
4545
reachable: hashmap<ast::node_id, ()>,
4646
exp_map: resolve::exp_map,
47+
impl_map: resolve::impl_map,
4748
item_symbols: hashmap<ast::node_id, str>,
4849
discrim_symbols: hashmap<ast::node_id, str>,
4950
link_meta: back::link::link_meta,
5051
cstore: cstore::cstore,
51-
maps: maps,
5252
encode_inlined_item: encode_inlined_item
5353
};
5454

5555
enum encode_ctxt = {
5656
tcx: ty::ctxt,
5757
reachable: hashmap<ast::node_id, ()>,
5858
exp_map: resolve::exp_map,
59+
impl_map: resolve::impl_map,
5960
item_symbols: hashmap<ast::node_id, str>,
6061
discrim_symbols: hashmap<ast::node_id, str>,
6162
link_meta: back::link::link_meta,
6263
cstore: cstore::cstore,
63-
maps: maps,
6464
encode_inlined_item: encode_inlined_item,
6565
type_abbrevs: abbrev_map
6666
};
@@ -396,7 +396,7 @@ fn encode_info_for_mod(ecx: @encode_ctxt, ebml_w: ebml::writer, md: _mod,
396396
encode_def_id(ebml_w, local_def(id));
397397
encode_family(ebml_w, 'm');
398398
encode_name(ebml_w, name);
399-
alt ecx.maps.impl_map.get(id) {
399+
alt ecx.impl_map.get(id) {
400400
list::cons(impls, @list::nil) {
401401
for vec::each(*impls) {|i|
402402
if ast_util::is_exported(i.ident, md) {
@@ -1056,11 +1056,11 @@ fn encode_metadata(parms: encode_parms, crate: @crate) -> [u8] {
10561056
tcx: parms.tcx,
10571057
reachable: parms.reachable,
10581058
exp_map: parms.exp_map,
1059+
impl_map: parms.impl_map,
10591060
item_symbols: parms.item_symbols,
10601061
discrim_symbols: parms.discrim_symbols,
10611062
link_meta: parms.link_meta,
10621063
cstore: parms.cstore,
1063-
maps: parms.maps,
10641064
encode_inlined_item: parms.encode_inlined_item,
10651065
type_abbrevs: ty::new_ty_hash()
10661066
});

trunk/src/rustc/middle/astencode.rs

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ import middle::freevars::{freevar_entry,
3030
import c = metadata::common;
3131
import e = metadata::encoder;
3232
import cstore = metadata::cstore;
33-
import metadata::maps;
3433
import metadata::encoder;
3534
import metadata::decoder;
3635
import metadata::tyencode;
@@ -43,9 +42,21 @@ import syntax::codemap;
4342
import syntax::parse;
4443
import syntax::print::pprust;
4544

45+
export maps;
4646
export encode_inlined_item;
4747
export decode_inlined_item;
4848

49+
// Auxiliary maps of things to be encoded
50+
type maps = {
51+
mutbl_map: middle::borrowck::mutbl_map,
52+
copy_map: middle::alias::copy_map,
53+
last_uses: middle::last_use::last_uses,
54+
impl_map: middle::resolve::impl_map,
55+
method_map: middle::typeck::method_map,
56+
vtable_map: middle::typeck::vtable_map,
57+
spill_map: middle::last_use::spill_map
58+
};
59+
4960
type decode_ctxt = @{
5061
cdata: cstore::crate_metadata,
5162
tcx: ty::ctxt,
@@ -68,7 +79,8 @@ iface tr {
6879
fn encode_inlined_item(ecx: @e::encode_ctxt,
6980
ebml_w: ebml::writer,
7081
path: ast_map::path,
71-
ii: ast::inlined_item) {
82+
ii: ast::inlined_item,
83+
maps: maps) {
7284
#debug["> Encoding inlined item: %s::%s (%u)",
7385
ast_map::path_to_str(path), ii.ident(),
7486
ebml_w.writer.tell()];
@@ -77,7 +89,7 @@ fn encode_inlined_item(ecx: @e::encode_ctxt,
7789
ebml_w.wr_tag(c::tag_ast as uint) {||
7890
encode_id_range(ebml_w, id_range);
7991
encode_ast(ebml_w, simplify_ast(ii));
80-
encode_side_tables_for_ii(ecx, ebml_w, ii);
92+
encode_side_tables_for_ii(ecx, maps, ebml_w, ii);
8193
}
8294

8395
#debug["< Encoded inlined fn: %s::%s (%u)",
@@ -719,19 +731,21 @@ impl writer for ebml::writer {
719731
}
720732

721733
fn encode_side_tables_for_ii(ecx: @e::encode_ctxt,
734+
maps: maps,
722735
ebml_w: ebml::writer,
723736
ii: ast::inlined_item) {
724737
ebml_w.wr_tag(c::tag_table as uint) {||
725738
visit_ids(ii, fn@(id: ast::node_id) {
726739
// Note: this will cause a copy of ebml_w, which is bad as
727740
// it has mut fields. But I believe it's harmless since
728741
// we generate balanced EBML.
729-
encode_side_tables_for_id(ecx, ebml_w, id)
742+
encode_side_tables_for_id(ecx, maps, ebml_w, id)
730743
});
731744
}
732745
}
733746

734747
fn encode_side_tables_for_id(ecx: @e::encode_ctxt,
748+
maps: maps,
735749
ebml_w: ebml::writer,
736750
id: ast::node_id) {
737751
let tcx = ecx.tcx;
@@ -808,25 +822,25 @@ fn encode_side_tables_for_id(ecx: @e::encode_ctxt,
808822
// }
809823
//}
810824

811-
option::iter(ecx.maps.mutbl_map.find(id)) {|_m|
825+
option::iter(maps.mutbl_map.find(id)) {|_m|
812826
ebml_w.tag(c::tag_table_mutbl) {||
813827
ebml_w.id(id);
814828
}
815829
}
816830

817-
option::iter(ecx.maps.copy_map.find(id)) {|_m|
831+
option::iter(maps.copy_map.find(id)) {|_m|
818832
ebml_w.tag(c::tag_table_copy) {||
819833
ebml_w.id(id);
820834
}
821835
}
822836

823-
option::iter(ecx.maps.spill_map.find(id)) {|_m|
837+
option::iter(maps.spill_map.find(id)) {|_m|
824838
ebml_w.tag(c::tag_table_spill) {||
825839
ebml_w.id(id);
826840
}
827841
}
828842

829-
option::iter(ecx.maps.last_uses.find(id)) {|m|
843+
option::iter(maps.last_uses.find(id)) {|m|
830844
ebml_w.tag(c::tag_table_last_use) {||
831845
ebml_w.id(id);
832846
ebml_w.tag(c::tag_table_val) {||
@@ -838,7 +852,7 @@ fn encode_side_tables_for_id(ecx: @e::encode_ctxt,
838852
// impl_map is not used except when emitting metadata,
839853
// don't need to keep it.
840854

841-
option::iter(ecx.maps.method_map.find(id)) {|mo|
855+
option::iter(maps.method_map.find(id)) {|mo|
842856
ebml_w.tag(c::tag_table_method_map) {||
843857
ebml_w.id(id);
844858
ebml_w.tag(c::tag_table_val) {||
@@ -847,7 +861,7 @@ fn encode_side_tables_for_id(ecx: @e::encode_ctxt,
847861
}
848862
}
849863

850-
option::iter(ecx.maps.vtable_map.find(id)) {|dr|
864+
option::iter(maps.vtable_map.find(id)) {|dr|
851865
ebml_w.tag(c::tag_table_vtable_map) {||
852866
ebml_w.id(id);
853867
ebml_w.tag(c::tag_table_val) {||

trunk/src/rustc/middle/trans/base.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2066,7 +2066,10 @@ fn maybe_instantiate_inline(ccx: @crate_ctxt, fn_id: ast::def_id)
20662066
}
20672067
some(none) { fn_id } // Not inlinable
20682068
none { // Not seen yet
2069-
alt check csearch::maybe_get_item_ast(ccx.tcx, ccx.maps, fn_id) {
2069+
alt check csearch::maybe_get_item_ast(
2070+
ccx.tcx, fn_id,
2071+
bind astencode::decode_inlined_item(_, _, ccx.maps, _, _)) {
2072+
20702073
csearch::not_found {
20712074
ccx.external.insert(fn_id, none);
20722075
fn_id
@@ -4991,16 +4994,19 @@ fn fill_crate_map(ccx: @crate_ctxt, map: ValueRef) {
49914994
fn crate_ctxt_to_encode_parms(cx: @crate_ctxt)
49924995
-> encoder::encode_parms {
49934996

4997+
let encode_inlined_item =
4998+
bind astencode::encode_inlined_item(_, _, _, _, cx.maps);
4999+
49945000
{
49955001
tcx: cx.tcx,
49965002
reachable: cx.reachable,
49975003
exp_map: cx.exp_map,
5004+
impl_map: cx.maps.impl_map,
49985005
item_symbols: cx.item_symbols,
49995006
discrim_symbols: cx.discrim_symbols,
50005007
link_meta: cx.link_meta,
50015008
cstore: cx.sess.cstore,
5002-
maps: cx.maps,
5003-
encode_inlined_item: middle::astencode::encode_inlined_item
5009+
encode_inlined_item: encode_inlined_item
50045010
}
50055011

50065012
}
@@ -5036,7 +5042,7 @@ fn write_abi_version(ccx: @crate_ctxt) {
50365042

50375043
fn trans_crate(sess: session::session, crate: @ast::crate, tcx: ty::ctxt,
50385044
output: str, emap: resolve::exp_map,
5039-
maps: metadata::maps)
5045+
maps: astencode::maps)
50405046
-> (ModuleRef, link::link_meta) {
50415047
let sha = std::sha1::sha1();
50425048
let link_meta = link::build_link_meta(sess, *crate, output, sha);

trunk/src/rustc/middle/trans/common.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ type crate_ctxt = {
101101
type_short_names: hashmap<ty::t, str>,
102102
all_llvm_symbols: set<str>,
103103
tcx: ty::ctxt,
104-
maps: metadata::maps,
104+
maps: astencode::maps,
105105
stats: stats,
106106
upcalls: @upcall::upcalls,
107107
tydesc_type: TypeRef,

0 commit comments

Comments
 (0)