Remove outer RefCell from PyObjectRef

This commit is contained in:
Joey Hain
2019-02-25 19:01:01 -08:00
parent 027a6847e5
commit f10fa6db44
33 changed files with 380 additions and 425 deletions

View File

@@ -61,7 +61,7 @@ fn float_init(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
// Retrieve inner float value:
pub fn get_value(obj: &PyObjectRef) -> f64 {
if let PyObjectPayload::Float { value } = &obj.borrow().payload {
if let PyObjectPayload::Float { value } = &obj.payload {
*value
} else {
panic!("Inner error getting float");
@@ -81,12 +81,12 @@ pub fn make_float(vm: &mut VirtualMachine, obj: &PyObjectRef) -> Result<f64, PyO
)?;
Ok(get_value(&res))
} else {
Err(vm.new_type_error(format!("Cannot cast {} to float", obj.borrow())))
Err(vm.new_type_error(format!("Cannot cast {} to float", obj)))
}
}
fn set_value(obj: &PyObjectRef, value: f64) {
obj.borrow_mut().payload = PyObjectPayload::Float { value };
//obj.payload = PyObjectPayload::Float { value }; // FIXME
}
fn float_eq(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {