Skip to content

Method-ify CStore #11146

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 26, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions src/librustc/back/link.rs
Original file line number Diff line number Diff line change
@@ -838,7 +838,7 @@ fn link_rlib(sess: Session,
out_filename: &Path) -> Archive {
let mut a = Archive::create(sess, out_filename, obj_filename);

for &(ref l, kind) in cstore::get_used_libraries(sess.cstore).iter() {
for &(ref l, kind) in sess.cstore.get_used_libraries().iter() {
match kind {
cstore::NativeStatic => {
a.add_native_library(l.as_slice());
@@ -912,9 +912,9 @@ fn link_staticlib(sess: Session, obj_filename: &Path, out_filename: &Path) {
let mut a = link_rlib(sess, None, obj_filename, out_filename);
a.add_native_library("morestack");

let crates = cstore::get_used_crates(sess.cstore, cstore::RequireStatic);
let crates = sess.cstore.get_used_crates(cstore::RequireStatic);
for &(cnum, ref path) in crates.iter() {
let name = cstore::get_crate_data(sess.cstore, cnum).name;
let name = sess.cstore.get_crate_data(cnum).name;
let p = match *path {
Some(ref p) => p.clone(), None => {
sess.err(format!("could not find rlib for: `{}`", name));
@@ -1072,7 +1072,7 @@ fn link_args(sess: Session,
// Finally add all the linker arguments provided on the command line along
// with any #[link_args] attributes found inside the crate
args.push_all(sess.opts.linker_args);
for arg in cstore::get_used_link_args(sess.cstore).iter() {
for arg in sess.cstore.get_used_link_args().iter() {
args.push(arg.clone());
}
return args;
@@ -1101,7 +1101,7 @@ fn add_local_native_libraries(args: &mut ~[~str], sess: Session) {
args.push("-L" + path.as_str().unwrap().to_owned());
}

for &(ref l, kind) in cstore::get_used_libraries(sess.cstore).iter() {
for &(ref l, kind) in sess.cstore.get_used_libraries().iter() {
match kind {
cstore::NativeUnknown | cstore::NativeStatic => {
args.push("-l" + *l);
@@ -1143,7 +1143,7 @@ fn add_upstream_rust_crates(args: &mut ~[~str], sess: Session,
// all dynamic libaries require dynamic dependencies (see above), so
// it's satisfactory to include either all static libraries or all
// dynamic libraries.
let crates = cstore::get_used_crates(cstore, cstore::RequireStatic);
let crates = cstore.get_used_crates(cstore::RequireStatic);
if crates.iter().all(|&(_, ref p)| p.is_some()) {
for (cnum, path) in crates.move_iter() {
let cratepath = path.unwrap();
@@ -1163,7 +1163,7 @@ fn add_upstream_rust_crates(args: &mut ~[~str], sess: Session,
// If we're not doing LTO, then our job is simply to just link
// against the archive.
if sess.lto() {
let name = cstore::get_crate_data(sess.cstore, cnum).name;
let name = sess.cstore.get_crate_data(cnum).name;
time(sess.time_passes(), format!("altering {}.rlib", name),
(), |()| {
let dst = tmpdir.join(cratepath.filename().unwrap());
@@ -1196,13 +1196,13 @@ fn add_upstream_rust_crates(args: &mut ~[~str], sess: Session,
// this case is the fallback
// * If an executable is being created, and one of the inputs is missing as
// a static library, then this is the fallback case.
let crates = cstore::get_used_crates(cstore, cstore::RequireDynamic);
let crates = cstore.get_used_crates(cstore::RequireDynamic);
for &(cnum, ref path) in crates.iter() {
let cratepath = match *path {
Some(ref p) => p.clone(),
None => {
sess.err(format!("could not find dynamic library for: `{}`",
cstore::get_crate_data(sess.cstore, cnum).name));
sess.cstore.get_crate_data(cnum).name));
return
}
};
@@ -1235,7 +1235,7 @@ fn add_upstream_rust_crates(args: &mut ~[~str], sess: Session,
// also be resolved in the target crate.
fn add_upstream_native_libraries(args: &mut ~[~str], sess: Session) {
let cstore = sess.cstore;
cstore::iter_crate_data(cstore, |cnum, _| {
cstore.iter_crate_data(|cnum, _| {
let libs = csearch::get_native_libraries(cstore, cnum);
for &(kind, ref lib) in libs.iter() {
match kind {
4 changes: 2 additions & 2 deletions src/librustc/back/lto.rs
Original file line number Diff line number Diff line change
@@ -33,9 +33,9 @@ pub fn run(sess: session::Session, llmod: ModuleRef,
// For each of our upstream dependencies, find the corresponding rlib and
// load the bitcode from the archive. Then merge it into the current LLVM
// module that we've got.
let crates = cstore::get_used_crates(sess.cstore, cstore::RequireStatic);
let crates = sess.cstore.get_used_crates(cstore::RequireStatic);
for (cnum, path) in crates.move_iter() {
let name = cstore::get_crate_data(sess.cstore, cnum).name;
let name = sess.cstore.get_crate_data(cnum).name;
let path = match path {
Some(p) => p,
None => {
2 changes: 1 addition & 1 deletion src/librustc/back/rpath.rs
Original file line number Diff line number Diff line change
@@ -41,7 +41,7 @@ pub fn get_rpath_flags(sess: session::Session, out_filename: &Path) -> ~[~str] {

let sysroot = sess.filesearch.sysroot();
let output = out_filename;
let libs = cstore::get_used_crates(sess.cstore, cstore::RequireDynamic);
let libs = sess.cstore.get_used_crates(cstore::RequireDynamic);
let libs = libs.move_iter().filter_map(|(_, l)| l.map(|p| p.clone())).collect();
// We don't currently rpath extern libraries, but we know
// where rustrt is and we know every rust program needs it
5 changes: 3 additions & 2 deletions src/librustc/driver/driver.rs
Original file line number Diff line number Diff line change
@@ -18,7 +18,8 @@ use front;
use lib::llvm::llvm;
use lib::llvm::{ContextRef, ModuleRef};
use metadata::common::LinkMeta;
use metadata::{creader, cstore, filesearch};
use metadata::{creader, filesearch};
use metadata::cstore::CStore;
use metadata;
use middle::{trans, freevars, kind, ty, typeck, lint, astencode, reachable};
use middle;
@@ -853,7 +854,7 @@ pub fn build_session_(sopts: @session::options,
let target_cfg = build_target_config(sopts, demitter);
let p_s = parse::new_parse_sess_special_handler(span_diagnostic_handler,
cm);
let cstore = @mut cstore::mk_cstore(token::get_ident_interner());
let cstore = @mut CStore::new(token::get_ident_interner());
let filesearch = filesearch::mk_filesearch(
&sopts.maybe_sysroot,
sopts.target_triple,
12 changes: 6 additions & 6 deletions src/librustc/metadata/creader.rs
Original file line number Diff line number Diff line change
@@ -114,7 +114,7 @@ fn visit_crate(e: &Env, c: &ast::Crate) {
for a in c.attrs.iter().filter(|m| "link_args" == m.name()) {
match a.value_str() {
Some(ref linkarg) => {
cstore::add_used_link_args(cstore, *linkarg);
cstore.add_used_link_args(*linkarg);
}
None => {/* fallthrough */ }
}
@@ -149,7 +149,7 @@ fn visit_view_item(e: @mut Env, i: &ast::view_item) {
version,
@"",
i.span);
cstore::add_extern_mod_stmt_cnum(e.sess.cstore, id, cnum);
e.sess.cstore.add_extern_mod_stmt_cnum(id, cnum);
}
_ => ()
}
@@ -170,7 +170,7 @@ fn visit_item(e: &Env, i: @ast::item) {
for m in link_args.iter() {
match m.value_str() {
Some(linkarg) => {
cstore::add_used_link_args(cstore, linkarg);
cstore.add_used_link_args(linkarg);
}
None => { /* fallthrough */ }
}
@@ -222,7 +222,7 @@ fn visit_item(e: &Env, i: @ast::item) {
if n.is_empty() {
e.sess.span_err(m.span, "#[link(name = \"\")] given with empty name");
} else {
cstore::add_used_library(cstore, n.to_owned(), kind);
cstore.add_used_library(n.to_owned(), kind);
}
}
None => {}
@@ -296,8 +296,8 @@ fn resolve_crate(e: @mut Env,
};

let cstore = e.sess.cstore;
cstore::set_crate_data(cstore, cnum, cmeta);
cstore::add_used_crate_source(cstore, cstore::CrateSource {
cstore.set_crate_data(cnum, cmeta);
cstore.add_used_crate_source(cstore::CrateSource {
dylib: dylib,
rlib: rlib,
cnum: cnum,
Loading