Introduce metadata::cstore
I intend for this to be the location for storing all the data retrieved by creader, most of which is currently in the session.
This commit is contained in:
parent
c7bfef43c8
commit
b23ecd47ce
@ -352,8 +352,9 @@ fn build_session_options(str binary, getopts::match match, str binary_dir) ->
|
||||
|
||||
fn build_session(@session::options sopts) -> session::session {
|
||||
auto target_cfg = build_target_config();
|
||||
auto cstore = metadata::cstore::mk_cstore();
|
||||
auto crate_cache = std::map::new_int_hash[session::crate_metadata]();
|
||||
ret session::session(target_cfg, sopts, crate_cache, [],
|
||||
ret session::session(target_cfg, sopts, cstore, crate_cache, [],
|
||||
[], [], codemap::new_codemap(), 0u);
|
||||
}
|
||||
|
||||
|
@ -45,6 +45,7 @@ type crate_metadata = rec(str name, vec[u8] data);
|
||||
|
||||
obj session(@config targ_cfg,
|
||||
@options opts,
|
||||
metadata::cstore::cstore cstore,
|
||||
map::hashmap[int, crate_metadata] crates,
|
||||
mutable vec[str] used_crate_files,
|
||||
mutable vec[str] used_libraries,
|
||||
@ -53,6 +54,7 @@ obj session(@config targ_cfg,
|
||||
mutable uint err_count) {
|
||||
fn get_targ_cfg() -> @config { ret targ_cfg; }
|
||||
fn get_opts() -> @options { ret opts; }
|
||||
fn get_cstore() -> metadata::cstore::cstore { cstore }
|
||||
fn span_fatal(span sp, str msg) -> ! {
|
||||
// FIXME: Use constants, but rustboot doesn't know how to export them.
|
||||
codemap::emit_error(some(sp), msg, cm);
|
||||
|
37
src/comp/metadata/cstore.rs
Normal file
37
src/comp/metadata/cstore.rs
Normal file
@ -0,0 +1,37 @@
|
||||
import std::map;
|
||||
|
||||
type crate_metadata = rec(str name, vec[u8] data);
|
||||
|
||||
type cstore = @rec(map::hashmap[int, crate_metadata] metas,
|
||||
vec[str] used_crate_files,
|
||||
vec[str] used_libraries,
|
||||
vec[str] used_link_args);
|
||||
|
||||
fn mk_cstore() -> cstore {
|
||||
auto meta_cache = map::new_int_hash[crate_metadata]();
|
||||
ret @rec(metas = meta_cache,
|
||||
used_crate_files = [],
|
||||
used_libraries = [],
|
||||
used_link_args = []);
|
||||
}
|
||||
|
||||
fn get_crate_data(&cstore cstore, int cnum) -> crate_metadata {
|
||||
ret cstore.metas.get(cnum);
|
||||
}
|
||||
|
||||
fn set_crate_data(&cstore cstore, int cnum, &crate_metadata data) {
|
||||
cstore.metas.insert(cnum, data);
|
||||
}
|
||||
|
||||
fn have_crate_data(&cstore cstore, int cnum) -> bool {
|
||||
ret cstore.metas.contains_key(cnum);
|
||||
}
|
||||
|
||||
// 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:
|
@ -81,6 +81,7 @@ mod metadata {
|
||||
export encoder;
|
||||
export decoder;
|
||||
export creader;
|
||||
export cstore;
|
||||
|
||||
mod common;
|
||||
mod tyencode;
|
||||
@ -88,6 +89,7 @@ mod metadata {
|
||||
mod encoder;
|
||||
mod decoder;
|
||||
mod creader;
|
||||
mod cstore;
|
||||
}
|
||||
|
||||
mod driver {
|
||||
|
Loading…
Reference in New Issue
Block a user