From 339189aff43af934cddbde694779c18e798fcd77 Mon Sep 17 00:00:00 2001 From: Adam Kelly Date: Thu, 9 Aug 2018 08:58:36 +0100 Subject: [PATCH] Remove special Type type. Type is just a class. --- vm/src/objtype.rs | 13 +++++++++---- vm/src/pyobject.rs | 2 -- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/vm/src/objtype.rs b/vm/src/objtype.rs index 07d624ba1..5193f1f18 100644 --- a/vm/src/objtype.rs +++ b/vm/src/objtype.rs @@ -1,5 +1,4 @@ -// use std::rc::Rc; -// use std::cell::RefCell; +use std::collections::HashMap; /* * The magical type type @@ -9,8 +8,14 @@ use super::pyobject::{PyObject, PyObjectKind, PyObjectRef}; pub fn create_type() -> PyObjectRef { let typ = PyObject::default().into_ref(); - (*typ.borrow_mut()).kind = PyObjectKind::Type; + let dict = PyObject::new( + PyObjectKind::Dict { + elements: HashMap::new(), + }, typ.clone()); + (*typ.borrow_mut()).kind = PyObjectKind::Class { + name: String::from("type"), + dict: dict, + }; (*typ.borrow_mut()).typ = Some(typ.clone()); - // typ.borrow_mut().dict.insert("__str__".to_string(), PyObject::new(PyObjectKind::RustFunction { function: str })); typ } diff --git a/vm/src/pyobject.rs b/vm/src/pyobject.rs index 903c4d63e..76d442d8c 100644 --- a/vm/src/pyobject.rs +++ b/vm/src/pyobject.rs @@ -347,7 +347,6 @@ pub enum PyObjectKind { RustFunction { function: RustPyFunc, }, - Type } impl fmt::Debug for PyObjectKind { @@ -371,7 +370,6 @@ impl fmt::Debug for PyObjectKind { &PyObjectKind::Class { name: _, dict: _ } => write!(f, "class"), &PyObjectKind::Instance { dict: _ } => write!(f, "instance"), &PyObjectKind::RustFunction { function: _ } => write!(f, "rust function"), - &PyObjectKind::Type => write!(f, "type"), } } }