From e0c398cbd5eb67087bae5a8d627d42c923d97d44 Mon Sep 17 00:00:00 2001 From: Adam Kelly Date: Wed, 6 Mar 2019 20:57:03 +0000 Subject: [PATCH] Eliminate NoPayload and just use a boxed (). --- vm/src/pyobject.rs | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/vm/src/pyobject.rs b/vm/src/pyobject.rs index f644e1698..0e8d31e65 100644 --- a/vm/src/pyobject.rs +++ b/vm/src/pyobject.rs @@ -155,7 +155,9 @@ pub struct PyContext { fn _nothing() -> PyObjectRef { PyObject { - payload: PyObjectPayload::NoPayload, + payload: PyObjectPayload::AnyRustValue { + value: Box::new(()), + }, typ: None, } .into_ref() @@ -223,14 +225,23 @@ impl PyContext { let exceptions = exceptions::ExceptionZoo::new(&type_type, &object_type, &dict_type); let none = PyObject::new( - PyObjectPayload::NoPayload, + PyObjectPayload::AnyRustValue { + value: Box::new(()), + }, create_type("NoneType", &type_type, &object_type, &dict_type), ); - let ellipsis = PyObject::new(PyObjectPayload::NoPayload, ellipsis_type.clone()); + let ellipsis = PyObject::new( + PyObjectPayload::AnyRustValue { + value: Box::new(()), + }, + ellipsis_type.clone(), + ); let not_implemented = PyObject::new( - PyObjectPayload::NoPayload, + PyObjectPayload::AnyRustValue { + value: Box::new(()), + }, create_type("NotImplementedType", &type_type, &object_type, &dict_type), ); @@ -1484,7 +1495,6 @@ pub enum PyObjectPayload { name: String, scope: ScopeRef, }, - NoPayload, Class { name: String, dict: RefCell, @@ -1525,7 +1535,6 @@ impl fmt::Debug for PyObjectPayload { ref object, } => write!(f, "bound-method: {:?} of {:?}", function, object), PyObjectPayload::Module { .. } => write!(f, "module"), - PyObjectPayload::NoPayload => write!(f, "NoPayload"), PyObjectPayload::Class { ref name, .. } => write!(f, "class {:?}", name), PyObjectPayload::Instance { .. } => write!(f, "instance"), PyObjectPayload::RustFunction { .. } => write!(f, "rust function"),