Skip to content

Commit dd8ab24

Browse files
committed
Add a map from external cnums to local cnums in cstore::crate_metadata
Once populated, this will allow us to load type info for types defined in external crates referenced by other external crates.
1 parent 061bcb2 commit dd8ab24

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

src/comp/metadata/creader.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import std::option;
2222
import std::option::none;
2323
import std::option::some;
2424
import std::map::hashmap;
25+
import std::map::new_int_hash;
2526
import syntax::print::pprust;
2627
import common::*;
2728

@@ -225,8 +226,10 @@ fn load_library_crate(&session::session sess, span span, ast::crate_num cnum,
225226
alt (find_library_crate(sess, ident, metas, library_search_paths)) {
226227
case (some(?t)) {
227228
auto cstore = sess.get_cstore();
228-
cstore::set_crate_data(cstore, cnum,
229-
rec(name=ident, data=t._1));
229+
auto cmeta = rec(name=ident,
230+
data=t._1,
231+
cnum_map = new_int_hash[ast::crate_num]());
232+
cstore::set_crate_data(cstore, cnum, cmeta);
230233
cstore::add_used_crate_file(cstore, t._0);
231234
ret;
232235
}

src/comp/metadata/cstore.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,15 @@ import std::vec;
66
import std::str;
77
import syntax::ast;
88

9-
type crate_metadata = rec(str name, vec[u8] data);
9+
// A map from external crate numbers (as decoded from some crate file) to
10+
// local crate numbers (as generated during this session). Each external
11+
// crate may refer to types in other external crates, and each has their
12+
// own crate numbers.
13+
type cnum_map = map::hashmap[ast::crate_num, ast::crate_num];
14+
15+
type crate_metadata = rec(str name,
16+
vec[u8] data,
17+
cnum_map cnum_map);
1018

1119
// Map from node_id's of local use statements to crate numbers
1220
type use_crate_map = map::hashmap[ast::node_id, ast::crate_num];

0 commit comments

Comments
 (0)