diff --git a/vm/src/lib.rs b/vm/src/lib.rs index b979ac9b0..a6d8f61de 100644 --- a/vm/src/lib.rs +++ b/vm/src/lib.rs @@ -22,9 +22,6 @@ mod frame; mod import; mod obj; mod objbool; -mod objfunction; -mod objobject; -mod objsequence; pub mod pyobject; pub mod stdlib; mod sysmodule; diff --git a/vm/src/obj/mod.rs b/vm/src/obj/mod.rs index fb1cad5ac..a5039ae02 100644 --- a/vm/src/obj/mod.rs +++ b/vm/src/obj/mod.rs @@ -1,7 +1,10 @@ pub mod objbytes; pub mod objdict; pub mod objfloat; +pub mod objfunction; pub mod objint; pub mod objlist; +pub mod objobject; +pub mod objsequence; pub mod objstr; pub mod objtype; diff --git a/vm/src/objfunction.rs b/vm/src/obj/objfunction.rs similarity index 87% rename from vm/src/objfunction.rs rename to vm/src/obj/objfunction.rs index 355754ec3..e6c165559 100644 --- a/vm/src/objfunction.rs +++ b/vm/src/obj/objfunction.rs @@ -1,5 +1,5 @@ -use super::pyobject::{AttributeProtocol, PyContext, PyFuncArgs, PyResult}; -use super::vm::VirtualMachine; +use super::super::pyobject::{AttributeProtocol, PyContext, PyFuncArgs, PyResult}; +use super::super::vm::VirtualMachine; pub fn init(context: &PyContext) { let ref function_type = context.function_type; diff --git a/vm/src/obj/objlist.rs b/vm/src/obj/objlist.rs index 983418271..2c1537a2c 100644 --- a/vm/src/obj/objlist.rs +++ b/vm/src/obj/objlist.rs @@ -1,8 +1,8 @@ -use super::super::objsequence::PySliceableSequence; use super::super::pyobject::{ AttributeProtocol, PyContext, PyFuncArgs, PyObjectKind, PyObjectRef, PyResult, TypeProtocol, }; use super::super::vm::VirtualMachine; +use super::objsequence::PySliceableSequence; use super::objstr; use super::objtype; diff --git a/vm/src/objobject.rs b/vm/src/obj/objobject.rs similarity index 94% rename from vm/src/objobject.rs rename to vm/src/obj/objobject.rs index 3dbcf388c..1de6cd83d 100644 --- a/vm/src/objobject.rs +++ b/vm/src/obj/objobject.rs @@ -1,10 +1,10 @@ -use super::obj::objdict; -use super::obj::objtype; -use super::pyobject::{ +use super::super::pyobject::{ AttributeProtocol, IdProtocol, PyContext, PyFuncArgs, PyObject, PyObjectKind, PyObjectRef, PyResult, TypeProtocol, }; -use super::vm::VirtualMachine; +use super::super::vm::VirtualMachine; +use super::objdict; +use super::objtype; pub fn new_instance(vm: &mut VirtualMachine, mut args: PyFuncArgs) -> PyResult { // more or less __new__ operator diff --git a/vm/src/objsequence.rs b/vm/src/obj/objsequence.rs similarity index 96% rename from vm/src/objsequence.rs rename to vm/src/obj/objsequence.rs index 7647b0fcd..9005b5f58 100644 --- a/vm/src/objsequence.rs +++ b/vm/src/obj/objsequence.rs @@ -1,5 +1,5 @@ -use super::pyobject::{PyObject, PyObjectKind, PyObjectRef, PyResult}; -use super::vm::VirtualMachine; +use super::super::pyobject::{PyObject, PyObjectKind, PyObjectRef, PyResult}; +use super::super::vm::VirtualMachine; use std::marker::Sized; pub trait PySliceableSequence { diff --git a/vm/src/obj/objstr.rs b/vm/src/obj/objstr.rs index 5c4976280..b64e862db 100644 --- a/vm/src/obj/objstr.rs +++ b/vm/src/obj/objstr.rs @@ -1,9 +1,9 @@ -use super::super::objsequence::PySliceableSequence; use super::super::pyobject::{ AttributeProtocol, PyContext, PyFuncArgs, PyObjectKind, PyObjectRef, PyResult, TypeProtocol, }; use super::super::vm::VirtualMachine; use super::objint; +use super::objsequence::PySliceableSequence; use super::objtype; pub fn init(context: &PyContext) { diff --git a/vm/src/pyobject.rs b/vm/src/pyobject.rs index c0bb6d1e4..2fbf025c8 100644 --- a/vm/src/pyobject.rs +++ b/vm/src/pyobject.rs @@ -3,13 +3,13 @@ use super::exceptions; use super::obj::objbytes; use super::obj::objdict; use super::obj::objfloat; +use super::obj::objfunction; use super::obj::objint; use super::obj::objlist; +use super::obj::objobject; use super::obj::objstr; use super::obj::objtype; use super::objbool; -use super::objfunction; -use super::objobject; use super::vm::VirtualMachine; use std::cell::RefCell; use std::cmp::Ordering; diff --git a/vm/src/stdlib/json.rs b/vm/src/stdlib/json.rs index c96f82522..63a2b296f 100644 --- a/vm/src/stdlib/json.rs +++ b/vm/src/stdlib/json.rs @@ -6,13 +6,13 @@ use serde::de::Visitor; use serde::ser::{SerializeMap, SerializeSeq}; use serde_json; -use super::super::obj::{objdict, objfloat, objint, objlist, objstr, objtype}; +use super::super::obj::{objdict, objfloat, objint, objlist, objsequence, objstr, objtype}; +use super::super::objbool; use super::super::pyobject::{ DictProtocol, PyContext, PyFuncArgs, PyObject, PyObjectKind, PyObjectRef, PyResult, TypeProtocol, }; use super::super::VirtualMachine; -use super::super::{objbool, objsequence}; // We need to have a VM available to serialise a PyObject based on its subclass, so we implement // PyObject serialisation via a proxy object which holds a reference to a VM diff --git a/vm/src/vm.rs b/vm/src/vm.rs index 22972c5ff..39c14ee20 100644 --- a/vm/src/vm.rs +++ b/vm/src/vm.rs @@ -16,10 +16,10 @@ use super::bytecode; use super::frame::{copy_code, Block, Frame}; use super::import::import; use super::obj::objlist; +use super::obj::objobject; use super::obj::objstr; use super::obj::objtype; use super::objbool; -use super::objobject; use super::pyobject::{ AttributeProtocol, DictProtocol, IdProtocol, ParentProtocol, PyContext, PyFuncArgs, PyObject, PyObjectKind, PyObjectRef, PyResult, ToRust, @@ -296,7 +296,7 @@ impl VirtualMachine { match &a2.kind { PyObjectKind::String { ref value } => objstr::subscript(self, value, b), PyObjectKind::List { ref elements } | PyObjectKind::Tuple { ref elements } => { - super::objsequence::get_item(self, &a, elements, b) + super::obj::objsequence::get_item(self, &a, elements, b) } _ => Err(self.new_type_error(format!( "TypeError: indexing type {:?} with index {:?} is not supported (yet?)",