librustc: De-`@mut` the entry function and entry type in the session
This commit is contained in:
parent
522743c9db
commit
5c63b1febc
|
@ -26,7 +26,7 @@ use middle;
|
|||
use util::common::time;
|
||||
use util::ppaux;
|
||||
|
||||
use std::cell::RefCell;
|
||||
use std::cell::{Cell, RefCell};
|
||||
use std::hashmap::{HashMap,HashSet};
|
||||
use std::io;
|
||||
use std::io::fs;
|
||||
|
@ -874,8 +874,8 @@ pub fn build_session_(sopts: @session::options,
|
|||
parse_sess: p_s,
|
||||
codemap: cm,
|
||||
// For a library crate, this is always none
|
||||
entry_fn: @mut None,
|
||||
entry_type: @mut None,
|
||||
entry_fn: RefCell::new(None),
|
||||
entry_type: Cell::new(None),
|
||||
span_diagnostic: span_diagnostic_handler,
|
||||
filesearch: filesearch,
|
||||
building_library: @mut false,
|
||||
|
|
|
@ -28,7 +28,7 @@ use syntax::abi;
|
|||
use syntax::parse::token;
|
||||
use syntax;
|
||||
|
||||
use std::cell::RefCell;
|
||||
use std::cell::{Cell, RefCell};
|
||||
use std::hashmap::{HashMap,HashSet};
|
||||
|
||||
pub struct config {
|
||||
|
@ -206,8 +206,8 @@ pub struct Session_ {
|
|||
parse_sess: @mut ParseSess,
|
||||
codemap: @codemap::CodeMap,
|
||||
// For a library crate, this is always none
|
||||
entry_fn: @mut Option<(NodeId, codemap::Span)>,
|
||||
entry_type: @mut Option<EntryFnType>,
|
||||
entry_fn: RefCell<Option<(NodeId, codemap::Span)>>,
|
||||
entry_type: Cell<Option<EntryFnType>>,
|
||||
span_diagnostic: @mut diagnostic::span_handler,
|
||||
filesearch: @filesearch::FileSearch,
|
||||
building_library: @mut bool,
|
||||
|
|
|
@ -212,7 +212,7 @@ fn create_and_seed_worklist(tcx: ty::ctxt,
|
|||
}
|
||||
|
||||
// Seed entry point
|
||||
match *tcx.sess.entry_fn {
|
||||
match tcx.sess.entry_fn.get() {
|
||||
Some((id, _)) => worklist.push(id),
|
||||
None => ()
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ pub fn find_entry_point(session: Session, crate: &Crate, ast_map: ast_map::map)
|
|||
|
||||
// If the user wants no main function at all, then stop here.
|
||||
if attr::contains_name(crate.attrs, "no_main") {
|
||||
*session.entry_type = Some(session::EntryNone);
|
||||
session.entry_type.set(Some(session::EntryNone));
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -122,14 +122,14 @@ fn find_item(item: @item, ctxt: &mut EntryContext) {
|
|||
|
||||
fn configure_main(this: &mut EntryContext) {
|
||||
if this.start_fn.is_some() {
|
||||
*this.session.entry_fn = this.start_fn;
|
||||
*this.session.entry_type = Some(session::EntryStart);
|
||||
this.session.entry_fn.set(this.start_fn);
|
||||
this.session.entry_type.set(Some(session::EntryStart));
|
||||
} else if this.attr_main_fn.is_some() {
|
||||
*this.session.entry_fn = this.attr_main_fn;
|
||||
*this.session.entry_type = Some(session::EntryMain);
|
||||
this.session.entry_fn.set(this.attr_main_fn);
|
||||
this.session.entry_type.set(Some(session::EntryMain));
|
||||
} else if this.main_fn.is_some() {
|
||||
*this.session.entry_fn = this.main_fn;
|
||||
*this.session.entry_type = Some(session::EntryMain);
|
||||
this.session.entry_fn.set(this.main_fn);
|
||||
this.session.entry_type.set(Some(session::EntryMain));
|
||||
} else {
|
||||
if !*this.session.building_library {
|
||||
// No main function
|
||||
|
|
|
@ -2382,7 +2382,7 @@ pub fn register_fn_llvmty(ccx: @CrateContext,
|
|||
}
|
||||
|
||||
pub fn is_entry_fn(sess: &Session, node_id: ast::NodeId) -> bool {
|
||||
match *sess.entry_fn {
|
||||
match sess.entry_fn.get() {
|
||||
Some((entry_id, _)) => node_id == entry_id,
|
||||
None => false
|
||||
}
|
||||
|
@ -2393,7 +2393,7 @@ pub fn is_entry_fn(sess: &Session, node_id: ast::NodeId) -> bool {
|
|||
pub fn create_entry_wrapper(ccx: @CrateContext,
|
||||
_sp: Span,
|
||||
main_llfn: ValueRef) {
|
||||
let et = ccx.sess.entry_type.unwrap();
|
||||
let et = ccx.sess.entry_type.get().unwrap();
|
||||
match et {
|
||||
session::EntryMain => {
|
||||
create_entry_fn(ccx, main_llfn, true);
|
||||
|
|
|
@ -439,8 +439,8 @@ fn check_start_fn_ty(ccx: &CrateCtxt,
|
|||
fn check_for_entry_fn(ccx: &CrateCtxt) {
|
||||
let tcx = ccx.tcx;
|
||||
if !*tcx.sess.building_library {
|
||||
match *tcx.sess.entry_fn {
|
||||
Some((id, sp)) => match *tcx.sess.entry_type {
|
||||
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),
|
||||
Some(session::EntryStart) => check_start_fn_ty(ccx, id, sp),
|
||||
Some(session::EntryNone) => {}
|
||||
|
|
Loading…
Reference in New Issue