Move builtin types to own directory

This commit is contained in:
Windel Bouwman
2018-08-31 20:31:25 +02:00
parent c687db079a
commit f453c749ec
15 changed files with 51 additions and 49 deletions

View File

@@ -4,9 +4,9 @@ use std::collections::HashMap;
use std::io::{self, Write};
use super::compile;
use super::obj::objstr;
use super::obj::objtype;
use super::objbool;
use super::objstr;
use super::objtype;
use super::pyobject::{
AttributeProtocol, DictProtocol, IdProtocol, PyContext, PyFuncArgs, PyObject, PyObjectKind,
PyObjectRef, PyResult, Scope, TypeProtocol,

View File

@@ -1,4 +1,4 @@
use super::objstr;
use super::obj::objstr;
use super::pyobject::{
create_type, AttributeProtocol, PyContext, PyFuncArgs, PyObjectRef, PyResult,
};

View File

@@ -20,16 +20,11 @@ pub mod eval;
mod exceptions;
mod frame;
mod import;
mod obj;
mod objbool;
mod objdict;
mod objfloat;
mod objfunction;
mod objint;
mod objlist;
mod objobject;
mod objsequence;
mod objstr;
mod objtype;
pub mod pyobject;
pub mod stdlib;
mod sysmodule;

6
vm/src/obj/mod.rs Normal file
View File

@@ -0,0 +1,6 @@
pub mod objdict;
pub mod objfloat;
pub mod objint;
pub mod objlist;
pub mod objstr;
pub mod objtype;

View File

@@ -1,10 +1,10 @@
use super::objstr;
use super::objtype;
use super::pyobject::{
use super::super::pyobject::{
AttributeProtocol, PyContext, PyFuncArgs, PyObject, PyObjectKind, PyObjectRef, PyResult,
TypeProtocol,
};
use super::vm::VirtualMachine;
use super::super::vm::VirtualMachine;
use super::objstr;
use super::objtype;
use std::collections::HashMap;
pub fn _set_item(

View File

@@ -1,9 +1,9 @@
use super::objint;
use super::objtype;
use super::pyobject::{
use super::super::pyobject::{
AttributeProtocol, PyContext, PyFuncArgs, PyObjectKind, PyObjectRef, PyResult, TypeProtocol,
};
use super::vm::VirtualMachine;
use super::super::vm::VirtualMachine;
use super::objint;
use super::objtype;
fn str(vm: &mut VirtualMachine, args: PyFuncArgs) -> Result<PyObjectRef, PyObjectRef> {
arg_check!(vm, args, required = [(float, Some(vm.ctx.float_type()))]);

View File

@@ -1,9 +1,9 @@
use super::objfloat;
use super::objtype;
use super::pyobject::{
use super::super::pyobject::{
AttributeProtocol, PyContext, PyFuncArgs, PyObjectKind, PyObjectRef, PyResult, TypeProtocol,
};
use super::vm::VirtualMachine;
use super::super::vm::VirtualMachine;
use super::objfloat;
use super::objtype;
fn str(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
arg_check!(vm, args, required = [(int, Some(vm.ctx.int_type()))]);

View File

@@ -1,10 +1,10 @@
use super::objsequence::PySliceableSequence;
use super::objstr;
use super::objtype;
use super::pyobject::{
use super::super::objsequence::PySliceableSequence;
use super::super::pyobject::{
AttributeProtocol, PyContext, PyFuncArgs, PyObjectKind, PyObjectRef, PyResult, TypeProtocol,
};
use super::vm::VirtualMachine;
use super::super::vm::VirtualMachine;
use super::objstr;
use super::objtype;
// set_item:
pub fn set_item(

View File

@@ -1,10 +1,10 @@
use super::objint;
use super::objsequence::PySliceableSequence;
use super::objtype;
use super::pyobject::{
use super::super::objsequence::PySliceableSequence;
use super::super::pyobject::{
AttributeProtocol, PyContext, PyFuncArgs, PyObjectKind, PyObjectRef, PyResult, TypeProtocol,
};
use super::vm::VirtualMachine;
use super::super::vm::VirtualMachine;
use super::objint;
use super::objtype;
pub fn init(context: &PyContext) {
let ref str_type = context.str_type;

View File

@@ -1,10 +1,10 @@
use super::objdict;
use super::objtype; // Required for arg_check! to use isinstance
use super::pyobject::{
use super::super::pyobject::{
AttributeProtocol, IdProtocol, PyContext, PyFuncArgs, PyObject, PyObjectKind, PyObjectRef,
PyResult, ToRust, TypeProtocol,
};
use super::vm::VirtualMachine;
use super::super::vm::VirtualMachine;
use super::objdict;
use super::objtype; // Required for arg_check! to use isinstance
/*
* The magical type type

View File

@@ -1,4 +1,4 @@
use super::objtype;
use super::obj::objtype;
use super::pyobject::{
AttributeProtocol, PyContext, PyFuncArgs, PyObjectKind, PyObjectRef, PyResult, TypeProtocol,
};

View File

@@ -1,5 +1,5 @@
use super::objdict;
use super::objtype;
use super::obj::objdict;
use super::obj::objtype;
use super::pyobject::{
AttributeProtocol, IdProtocol, PyContext, PyFuncArgs, PyObject, PyObjectKind, PyObjectRef,
PyResult, TypeProtocol,

View File

@@ -1,14 +1,14 @@
use super::bytecode;
use super::exceptions;
use super::obj::objdict;
use super::obj::objfloat;
use super::obj::objint;
use super::obj::objlist;
use super::obj::objstr;
use super::obj::objtype;
use super::objbool;
use super::objdict;
use super::objfloat;
use super::objfunction;
use super::objint;
use super::objlist;
use super::objobject;
use super::objstr;
use super::objtype;
use super::vm::VirtualMachine;
use std::cell::RefCell;
use std::cmp::Ordering;

View File

@@ -6,12 +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::pyobject::{
DictProtocol, PyContext, PyFuncArgs, PyObject, PyObjectKind, PyObjectRef, PyResult,
TypeProtocol,
};
use super::super::VirtualMachine;
use super::super::{objbool, objdict, objfloat, objint, objlist, objsequence, objstr, objtype};
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

View File

@@ -15,11 +15,11 @@ use super::builtins;
use super::bytecode;
use super::frame::{copy_code, Block, Frame};
use super::import::import;
use super::obj::objlist;
use super::obj::objstr;
use super::obj::objtype;
use super::objbool;
use super::objlist;
use super::objobject;
use super::objstr;
use super::objtype;
use super::pyobject::{
AttributeProtocol, DictProtocol, IdProtocol, ParentProtocol, PyContext, PyFuncArgs, PyObject,
PyObjectKind, PyObjectRef, PyResult,
@@ -969,7 +969,7 @@ impl VirtualMachine {
#[cfg(test)]
mod tests {
use super::super::objint;
use super::super::obj::objint;
use super::objstr;
use super::VirtualMachine;