Skip to content

Commit c7cf5dc

Browse files
committed
Method-ify CStore
1 parent 4d5243d commit c7cf5dc

File tree

15 files changed

+176
-193
lines changed

15 files changed

+176
-193
lines changed

src/librustc/back/link.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -838,7 +838,7 @@ fn link_rlib(sess: Session,
838838
out_filename: &Path) -> Archive {
839839
let mut a = Archive::create(sess, out_filename, obj_filename);
840840

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

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

1104-
for &(ref l, kind) in cstore::get_used_libraries(sess.cstore).iter() {
1104+
for &(ref l, kind) in sess.cstore.get_used_libraries().iter() {
11051105
match kind {
11061106
cstore::NativeUnknown | cstore::NativeStatic => {
11071107
args.push("-l" + *l);
@@ -1143,7 +1143,7 @@ fn add_upstream_rust_crates(args: &mut ~[~str], sess: Session,
11431143
// all dynamic libaries require dynamic dependencies (see above), so
11441144
// it's satisfactory to include either all static libraries or all
11451145
// dynamic libraries.
1146-
let crates = cstore::get_used_crates(cstore, cstore::RequireStatic);
1146+
let crates = cstore.get_used_crates(cstore::RequireStatic);
11471147
if crates.iter().all(|&(_, ref p)| p.is_some()) {
11481148
for (cnum, path) in crates.move_iter() {
11491149
let cratepath = path.unwrap();
@@ -1163,7 +1163,7 @@ fn add_upstream_rust_crates(args: &mut ~[~str], sess: Session,
11631163
// If we're not doing LTO, then our job is simply to just link
11641164
// against the archive.
11651165
if sess.lto() {
1166-
let name = cstore::get_crate_data(sess.cstore, cnum).name;
1166+
let name = sess.cstore.get_crate_data(cnum).name;
11671167
time(sess.time_passes(), format!("altering {}.rlib", name),
11681168
(), |()| {
11691169
let dst = tmpdir.join(cratepath.filename().unwrap());
@@ -1196,13 +1196,13 @@ fn add_upstream_rust_crates(args: &mut ~[~str], sess: Session,
11961196
// this case is the fallback
11971197
// * If an executable is being created, and one of the inputs is missing as
11981198
// a static library, then this is the fallback case.
1199-
let crates = cstore::get_used_crates(cstore, cstore::RequireDynamic);
1199+
let crates = cstore.get_used_crates(cstore::RequireDynamic);
12001200
for &(cnum, ref path) in crates.iter() {
12011201
let cratepath = match *path {
12021202
Some(ref p) => p.clone(),
12031203
None => {
12041204
sess.err(format!("could not find dynamic library for: `{}`",
1205-
cstore::get_crate_data(sess.cstore, cnum).name));
1205+
sess.cstore.get_crate_data(cnum).name));
12061206
return
12071207
}
12081208
};
@@ -1235,7 +1235,7 @@ fn add_upstream_rust_crates(args: &mut ~[~str], sess: Session,
12351235
// also be resolved in the target crate.
12361236
fn add_upstream_native_libraries(args: &mut ~[~str], sess: Session) {
12371237
let cstore = sess.cstore;
1238-
cstore::iter_crate_data(cstore, |cnum, _| {
1238+
cstore.iter_crate_data(|cnum, _| {
12391239
let libs = csearch::get_native_libraries(cstore, cnum);
12401240
for &(kind, ref lib) in libs.iter() {
12411241
match kind {

src/librustc/back/lto.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ pub fn run(sess: session::Session, llmod: ModuleRef,
3333
// For each of our upstream dependencies, find the corresponding rlib and
3434
// load the bitcode from the archive. Then merge it into the current LLVM
3535
// module that we've got.
36-
let crates = cstore::get_used_crates(sess.cstore, cstore::RequireStatic);
36+
let crates = sess.cstore.get_used_crates(cstore::RequireStatic);
3737
for (cnum, path) in crates.move_iter() {
38-
let name = cstore::get_crate_data(sess.cstore, cnum).name;
38+
let name = sess.cstore.get_crate_data(cnum).name;
3939
let path = match path {
4040
Some(p) => p,
4141
None => {

src/librustc/back/rpath.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ pub fn get_rpath_flags(sess: session::Session, out_filename: &Path) -> ~[~str] {
4141

4242
let sysroot = sess.filesearch.sysroot();
4343
let output = out_filename;
44-
let libs = cstore::get_used_crates(sess.cstore, cstore::RequireDynamic);
44+
let libs = sess.cstore.get_used_crates(cstore::RequireDynamic);
4545
let libs = libs.move_iter().filter_map(|(_, l)| l.map(|p| p.clone())).collect();
4646
// We don't currently rpath extern libraries, but we know
4747
// where rustrt is and we know every rust program needs it

src/librustc/driver/driver.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ use front;
1818
use lib::llvm::llvm;
1919
use lib::llvm::{ContextRef, ModuleRef};
2020
use metadata::common::LinkMeta;
21-
use metadata::{creader, cstore, filesearch};
21+
use metadata::{creader, filesearch};
22+
use metadata::cstore::CStore;
2223
use metadata;
2324
use middle::{trans, freevars, kind, ty, typeck, lint, astencode, reachable};
2425
use middle;
@@ -853,7 +854,7 @@ pub fn build_session_(sopts: @session::options,
853854
let target_cfg = build_target_config(sopts, demitter);
854855
let p_s = parse::new_parse_sess_special_handler(span_diagnostic_handler,
855856
cm);
856-
let cstore = @mut cstore::mk_cstore(token::get_ident_interner());
857+
let cstore = @mut CStore::new(token::get_ident_interner());
857858
let filesearch = filesearch::mk_filesearch(
858859
&sopts.maybe_sysroot,
859860
sopts.target_triple,

src/librustc/metadata/creader.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ fn visit_crate(e: &Env, c: &ast::Crate) {
114114
for a in c.attrs.iter().filter(|m| "link_args" == m.name()) {
115115
match a.value_str() {
116116
Some(ref linkarg) => {
117-
cstore::add_used_link_args(cstore, *linkarg);
117+
cstore.add_used_link_args(*linkarg);
118118
}
119119
None => {/* fallthrough */ }
120120
}
@@ -149,7 +149,7 @@ fn visit_view_item(e: @mut Env, i: &ast::view_item) {
149149
version,
150150
@"",
151151
i.span);
152-
cstore::add_extern_mod_stmt_cnum(e.sess.cstore, id, cnum);
152+
e.sess.cstore.add_extern_mod_stmt_cnum(id, cnum);
153153
}
154154
_ => ()
155155
}
@@ -170,7 +170,7 @@ fn visit_item(e: &Env, i: @ast::item) {
170170
for m in link_args.iter() {
171171
match m.value_str() {
172172
Some(linkarg) => {
173-
cstore::add_used_link_args(cstore, linkarg);
173+
cstore.add_used_link_args(linkarg);
174174
}
175175
None => { /* fallthrough */ }
176176
}
@@ -222,7 +222,7 @@ fn visit_item(e: &Env, i: @ast::item) {
222222
if n.is_empty() {
223223
e.sess.span_err(m.span, "#[link(name = \"\")] given with empty name");
224224
} else {
225-
cstore::add_used_library(cstore, n.to_owned(), kind);
225+
cstore.add_used_library(n.to_owned(), kind);
226226
}
227227
}
228228
None => {}
@@ -296,8 +296,8 @@ fn resolve_crate(e: @mut Env,
296296
};
297297

298298
let cstore = e.sess.cstore;
299-
cstore::set_crate_data(cstore, cnum, cmeta);
300-
cstore::add_used_crate_source(cstore, cstore::CrateSource {
299+
cstore.set_crate_data(cnum, cmeta);
300+
cstore.add_used_crate_source(cstore::CrateSource {
301301
dylib: dylib,
302302
rlib: rlib,
303303
cnum: cnum,

0 commit comments

Comments
 (0)