1
Fork 0

librustc: De-@mut CrateContext::tydescs

This commit is contained in:
Patrick Walton 2013-12-18 18:15:27 -08:00
parent b5aa6eb69f
commit 519db34722
3 changed files with 12 additions and 9 deletions

View file

@ -439,16 +439,19 @@ pub fn get_tydesc_simple(ccx: &mut CrateContext, t: ty::t) -> ValueRef {
}
pub fn get_tydesc(ccx: &mut CrateContext, t: ty::t) -> @mut tydesc_info {
match ccx.tydescs.find(&t) {
Some(&inf) => {
return inf;
}
{
let tydescs = ccx.tydescs.borrow();
match tydescs.get().find(&t) {
Some(&inf) => return inf,
_ => { }
}
}
ccx.stats.n_static_tydescs += 1u;
let inf = glue::declare_tydesc(ccx, t);
ccx.tydescs.insert(t, inf);
let mut tydescs = ccx.tydescs.borrow_mut();
tydescs.get().insert(t, inf);
return inf;
}

View file

@ -52,7 +52,7 @@ pub struct CrateContext {
reachable: @mut HashSet<ast::NodeId>,
item_symbols: RefCell<HashMap<ast::NodeId, ~str>>,
link_meta: LinkMeta,
tydescs: HashMap<ty::t, @mut tydesc_info>,
tydescs: RefCell<HashMap<ty::t, @mut tydesc_info>>,
// Set when running emit_tydescs to enforce that no more tydescs are
// created.
finished_tydescs: bool,
@ -188,7 +188,7 @@ impl CrateContext {
reachable: reachable,
item_symbols: RefCell::new(HashMap::new()),
link_meta: link_meta,
tydescs: HashMap::new(),
tydescs: RefCell::new(HashMap::new()),
finished_tydescs: false,
external: HashMap::new(),
external_srcs: HashMap::new(),

View file

@ -696,8 +696,8 @@ pub fn emit_tydescs(ccx: &mut CrateContext) {
// As of this point, allow no more tydescs to be created.
ccx.finished_tydescs = true;
let glue_fn_ty = Type::generic_glue_fn(ccx).ptr_to();
let tyds = &mut ccx.tydescs;
for (_, &val) in tyds.iter() {
let mut tyds = ccx.tydescs.borrow_mut();
for (_, &val) in tyds.get().iter() {
let ti = val;
// Each of the glue functions needs to be cast to a generic type