提交 d7b15270 编写于 作者: P Patrick Walton

librustc: De-`@mut` `building_library` in the session

上级 c56bac7f
......@@ -166,7 +166,7 @@ pub fn phase_2_configure_and_expand(sess: Session,
mut crate: ast::Crate) -> ast::Crate {
let time_passes = sess.time_passes();
*sess.building_library = session::building_library(sess.opts, &crate);
sess.building_library.set(session::building_library(sess.opts, &crate));
*sess.outputs = session::collect_outputs(sess.opts, crate.attrs);
time(time_passes, "gated feature checking", (), |_|
......@@ -878,7 +878,7 @@ pub fn build_session_(sopts: @session::options,
entry_type: Cell::new(None),
span_diagnostic: span_diagnostic_handler,
filesearch: filesearch,
building_library: @mut false,
building_library: Cell::new(false),
working_dir: os::getcwd(),
lints: RefCell::new(HashMap::new()),
node_id: Cell::new(1),
......@@ -1039,7 +1039,7 @@ pub fn build_output_filenames(input: &input,
}
}
if *sess.building_library {
if sess.building_library.get() {
out_path = dirpath.join(os::dll_filename(stem));
obj_path = {
let mut p = dirpath.join(stem);
......@@ -1060,7 +1060,7 @@ pub fn build_output_filenames(input: &input,
out_file.with_extension(obj_suffix)
};
if *sess.building_library {
if sess.building_library.get() {
sess.warn("ignoring specified output filename for library.");
}
......
......@@ -210,7 +210,7 @@ pub struct Session_ {
entry_type: Cell<Option<EntryFnType>>,
span_diagnostic: @mut diagnostic::span_handler,
filesearch: @filesearch::FileSearch,
building_library: @mut bool,
building_library: Cell<bool>,
working_dir: Path,
lints: RefCell<HashMap<ast::NodeId,
~[(lint::lint, codemap::Span, ~str)]>>,
......
......@@ -69,7 +69,7 @@ fn fold_crate(&self, crate: ast::Crate) -> ast::Crate {
span: dummy_sp()
}];
if use_uv(&crate) && !*self.sess.building_library {
if use_uv(&crate) && !self.sess.building_library.get() {
vis.push(ast::view_item {
node: ast::view_item_extern_mod(self.sess.ident_of("green"),
None,
......
......@@ -127,7 +127,7 @@ fn fold_mod(&self, m: &ast::_mod) -> ast::_mod {
// the one we're going to add. Only if compiling an executable.
fn nomain(cx: @TestCtxt, item: @ast::item) -> @ast::item {
if !*cx.sess.building_library {
if !cx.sess.building_library.get() {
@ast::item {
attrs: item.attrs.iter().filter_map(|attr| {
if "main" != attr.name() {
......
......@@ -45,7 +45,7 @@ fn visit_item(&mut self, item:@item, _:()) {
}
pub fn find_entry_point(session: Session, crate: &Crate, ast_map: ast_map::map) {
if *session.building_library {
if session.building_library.get() {
// No need to find a main function
return;
}
......@@ -131,7 +131,7 @@ fn configure_main(this: &mut EntryContext) {
this.session.entry_fn.set(this.main_fn);
this.session.entry_type.set(Some(session::EntryMain));
} else {
if !*this.session.building_library {
if !this.session.building_library.get() {
// No main function
this.session.err("main function not found");
if !this.non_main_fns.is_empty() {
......
......@@ -303,7 +303,7 @@ fn propagate(&self) {
fn propagate_node(&self, node: &ast_map::ast_node,
search_item: ast::NodeId,
visitor: &mut MarkSymbolVisitor) {
if !*self.tcx.sess.building_library {
if !self.tcx.sess.building_library.get() {
// If we are building an executable, then there's no need to flag
// anything as external except for `extern fn` types. These
// functions may still participate in some form of native interface,
......
......@@ -2344,7 +2344,7 @@ fn finish_register_fn(ccx: @CrateContext, sp: Span, sym: ~str, node_id: ast::Nod
}
}
if is_entry_fn(&ccx.sess, node_id) && !*ccx.sess.building_library {
if is_entry_fn(&ccx.sess, node_id) && !ccx.sess.building_library.get() {
create_entry_wrapper(ccx, sp, llfn);
}
}
......@@ -2678,7 +2678,7 @@ pub fn get_item_val(ccx: @CrateContext, id: ast::NodeId) -> ValueRef {
// library then we've already declared the crate map
// so use that instead.
if attr::contains_name(ni.attrs, "crate_map") {
if *ccx.sess.building_library {
if ccx.sess.building_library.get() {
let s = "_rust_crate_map_toplevel";
let g = unsafe {
s.with_c_str(|buf| {
......@@ -3044,7 +3044,7 @@ pub fn decl_crate_map(sess: session::Session, mapmeta: LinkMeta,
let mut n_subcrates = 1;
let cstore = sess.cstore;
while cstore.have_crate_data(n_subcrates) { n_subcrates += 1; }
let is_top = !*sess.building_library || sess.gen_crate_map();
let is_top = !sess.building_library.get() || sess.gen_crate_map();
let sym_name = if is_top {
~"_rust_crate_map_toplevel"
} else {
......@@ -3154,7 +3154,9 @@ pub fn crate_ctxt_to_encode_parms<'r>(cx: &'r CrateContext, ie: encoder::encode_
pub fn write_metadata(cx: &CrateContext, crate: &ast::Crate) -> ~[u8] {
use extra::flate;
if !*cx.sess.building_library { return ~[]; }
if !cx.sess.building_library.get() {
return ~[]
}
let encode_inlined_item: encoder::encode_inlined_item =
|ecx, ebml_w, path, ii|
......@@ -3227,8 +3229,7 @@ pub fn trans_crate(sess: session::Session,
// __rust_crate_map_toplevel symbol (extra underscore) which it will
// subsequently fail to find. So to mitigate that we just introduce
// an alias from the symbol it expects to the one that actually exists.
if ccx.sess.targ_cfg.os == OsWin32 &&
!*ccx.sess.building_library {
if ccx.sess.targ_cfg.os == OsWin32 && !ccx.sess.building_library.get() {
let maptype = val_ty(ccx.crate_map).to_ref();
......
......@@ -438,7 +438,7 @@ fn check_start_fn_ty(ccx: &CrateCtxt,
fn check_for_entry_fn(ccx: &CrateCtxt) {
let tcx = ccx.tcx;
if !*tcx.sess.building_library {
if !tcx.sess.building_library.get() {
match tcx.sess.entry_fn.get() {
Some((id, sp)) => match tcx.sess.entry_type.get() {
Some(session::EntryMain) => check_main_fn_ty(ccx, id, sp),
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册