librustc: De-@mut RefCell::const_globals.

This commit is contained in:
Patrick Walton 2013-12-18 17:03:55 -08:00
parent 0e2041c54b
commit 28943e96cb
2 changed files with 6 additions and 4 deletions

View File

@ -79,7 +79,8 @@ pub fn const_lit(cx: &mut CrateContext, e: &ast::Expr, lit: ast::lit)
pub fn const_ptrcast(cx: &mut CrateContext, a: ValueRef, t: Type) -> ValueRef {
unsafe {
let b = llvm::LLVMConstPointerCast(a, t.ptr_to().to_ref());
assert!(cx.const_globals.insert(b as int, a));
let mut const_globals = cx.const_globals.borrow_mut();
assert!(const_globals.get().insert(b as int, a));
b
}
}
@ -111,7 +112,8 @@ fn const_addr_of(cx: &mut CrateContext, cv: ValueRef) -> ValueRef {
}
fn const_deref_ptr(cx: &mut CrateContext, v: ValueRef) -> ValueRef {
let v = match cx.const_globals.find(&(v as int)) {
let const_globals = cx.const_globals.borrow();
let v = match const_globals.get().find(&(v as int)) {
Some(&v) => v,
None => v
};

View File

@ -81,7 +81,7 @@ pub struct CrateContext {
// when we ptrcast, and we have to ptrcast during translation
// of a [T] const because we form a slice, a [*T,int] pair, not
// a pointer to an LLVM array type.
const_globals: HashMap<int, ValueRef>,
const_globals: RefCell<HashMap<int, ValueRef>>,
// Cache of emitted const values
const_values: HashMap<ast::NodeId, ValueRef>,
@ -198,7 +198,7 @@ impl CrateContext {
monomorphizing: RefCell::new(HashMap::new()),
vtables: RefCell::new(HashMap::new()),
const_cstr_cache: RefCell::new(HashMap::new()),
const_globals: HashMap::new(),
const_globals: RefCell::new(HashMap::new()),
const_values: HashMap::new(),
extern_const_values: HashMap::new(),
impl_method_cache: HashMap::new(),