|
11 | 11 | #[allow(non_uppercase_pattern_statics)];
|
12 | 12 |
|
13 | 13 | use std::c_str::ToCStr;
|
| 14 | +use std::cell::RefCell; |
14 | 15 | use std::hashmap::HashMap;
|
15 | 16 | use std::libc::{c_uint, c_ushort, c_void, free};
|
16 | 17 | use std::str::raw::from_c_str;
|
@@ -1804,22 +1805,24 @@ pub fn SetFunctionAttribute(Fn: ValueRef, attr: Attribute) {
|
1804 | 1805 | /* Memory-managed object interface to type handles. */
|
1805 | 1806 |
|
1806 | 1807 | pub struct TypeNames {
|
1807 |
| - named_types: HashMap<~str, TypeRef> |
| 1808 | + named_types: RefCell<HashMap<~str, TypeRef>>, |
1808 | 1809 | }
|
1809 | 1810 |
|
1810 | 1811 | impl TypeNames {
|
1811 | 1812 | pub fn new() -> TypeNames {
|
1812 | 1813 | TypeNames {
|
1813 |
| - named_types: HashMap::new() |
| 1814 | + named_types: RefCell::new(HashMap::new()) |
1814 | 1815 | }
|
1815 | 1816 | }
|
1816 | 1817 |
|
1817 |
| - pub fn associate_type(&mut self, s: &str, t: &Type) { |
1818 |
| - assert!(self.named_types.insert(s.to_owned(), t.to_ref())); |
| 1818 | + pub fn associate_type(&self, s: &str, t: &Type) { |
| 1819 | + let mut named_types = self.named_types.borrow_mut(); |
| 1820 | + assert!(named_types.get().insert(s.to_owned(), t.to_ref())); |
1819 | 1821 | }
|
1820 | 1822 |
|
1821 | 1823 | pub fn find_type(&self, s: &str) -> Option<Type> {
|
1822 |
| - self.named_types.find_equiv(&s).map(|x| Type::from_ref(*x)) |
| 1824 | + let named_types = self.named_types.borrow(); |
| 1825 | + named_types.get().find_equiv(&s).map(|x| Type::from_ref(*x)) |
1823 | 1826 | }
|
1824 | 1827 |
|
1825 | 1828 | pub fn type_to_str(&self, ty: Type) -> ~str {
|
|
0 commit comments