Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
move builtins module to vm::stdlib::builtlins for consistency
  • Loading branch information
youknowone committed Sep 30, 2021
commit d42c4eb21e32f324cdb0eeafff2dc1b2aed54a85
3 changes: 0 additions & 3 deletions vm/src/builtins/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,4 @@ pub use zip::PyZip;
pub use float::try_to_bigint as try_f64_to_bigint;
pub use int::try_to_float as try_bigint_to_f64;

mod make_module;
pub use make_module::{ascii, make_module, print};

pub use crate::exceptions::types::*;
3 changes: 2 additions & 1 deletion vm/src/format.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
use crate::{
builtins::{self, PyBaseExceptionRef, PyStrRef},
builtins::{PyBaseExceptionRef, PyStrRef},
common::float_ops,
exceptions::IntoPyException,
function::FuncArgs,
stdlib::builtins,
ItemProtocol, PyObjectRef, PyResult, TypeProtocol, VirtualMachine,
};
use itertools::{Itertools, PeekingNext};
Expand Down
5 changes: 2 additions & 3 deletions vm/src/frame.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
use crate::common::{boxvec::BoxVec, lock::PyMutex};
use crate::{
builtins::PyBaseExceptionRef,
builtins::{
self,
asyncgenerator::PyAsyncGenWrappedValue,
coroutine::PyCoroutine,
function::{PyCell, PyCellRef, PyFunction},
generator::PyGenerator,
list, pystr, set,
traceback::PyTraceback,
tuple::{PyTuple, PyTupleTyped},
PyCode, PyDict, PyDictRef, PySlice, PyStr, PyStrRef, PyTypeRef,
PyBaseExceptionRef, PyCode, PyDict, PyDictRef, PySlice, PyStr, PyStrRef, PyTypeRef,
},
bytecode,
coroutine::Coro,
Expand All @@ -20,6 +18,7 @@ use crate::{
protocol::PyIter,
scope::Scope,
slots::PyComparisonOp,
stdlib::builtins,
IdProtocol, ItemProtocol, PyMethod, PyObjectRef, PyRef, PyResult, PyValue, TryFromObject,
TypeProtocol, VirtualMachine,
};
Expand Down
8 changes: 4 additions & 4 deletions vm/src/builtins/make_module.rs → vm/src/stdlib/builtins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ use crate::{PyObjectRef, VirtualMachine};
/// Built-in functions, exceptions, and other objects.
///
/// Noteworthy: None is the `nil' object; Ellipsis represents `...' in slices.
#[pymodule(name = "builtins")]
mod decl {
#[pymodule]
mod builtins {
use crate::builtins::{
enumerate::PyReverseSequenceIterator,
function::{PyCellRef, PyFunctionRef},
Expand Down Expand Up @@ -891,12 +891,12 @@ mod decl {
}
}

pub use decl::{ascii, print};
pub use builtins::{ascii, print};

pub fn make_module(vm: &VirtualMachine, module: PyObjectRef) {
let ctx = &vm.ctx;

decl::extend_module(vm, &module);
builtins::extend_module(vm, &module);

let debug_mode: bool = vm.state.settings.optimize == 0;
extend_module!(vm, module, {
Expand Down
1 change: 1 addition & 0 deletions vm/src/stdlib/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ pub(crate) mod ast;
mod atexit;
mod binascii;
mod bisect;
pub mod builtins;
mod cmath;
mod codecs;
mod collections;
Expand Down
18 changes: 10 additions & 8 deletions vm/src/stdlib/sys.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
use num_traits::ToPrimitive;
use std::{env, mem, path};

use crate::builtins::{PyStr, PyStrRef, PyTypeRef};
use crate::common::{
ascii,
hash::{PyHash, PyUHash},
};
use crate::frame::FrameRef;
use crate::function::{FuncArgs, OptionalArg, PosArgs};
use crate::vm::{PySettings, VirtualMachine};
use crate::{builtins, exceptions, py_io, version};
use crate::{
builtins::{PyStr, PyStrRef, PyTypeRef},
exceptions,
frame::FrameRef,
function::{FuncArgs, OptionalArg, PosArgs},
py_io,
stdlib::builtins,
version,
vm::{PySettings, VirtualMachine},
ItemProtocol, PyClassImpl, PyContext, PyObjectRef, PyRefExact, PyResult, PyStructSequence,
};
use num_traits::ToPrimitive;
use std::{env, mem, path};

/*
* The magic sys module.
Expand Down
7 changes: 3 additions & 4 deletions vm/src/vm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@
use crate::compile::{self, CompileError, CompileErrorType, CompileOpts};
use crate::{
builtins::{
self,
code::{self, PyCode},
module, object,
tuple::{PyTuple, PyTupleRef, PyTupleTyped},
PyDictRef, PyInt, PyIntRef, PyList, PyModule, PyStr, PyStrRef, PyTypeRef,
PyBaseException, PyBaseExceptionRef, PyDictRef, PyInt, PyIntRef, PyList, PyModule, PyStr,
PyStrRef, PyTypeRef,
},
builtins::{PyBaseException, PyBaseExceptionRef},
bytecode,
codecs::CodecsRegistry,
common::{ascii, hash::HashSecret, lock::PyMutex, rc::PyRc},
Expand Down Expand Up @@ -325,7 +324,7 @@ impl VirtualMachine {
panic!("Double Initialize Error");
}

builtins::make_module(self, self.builtins.clone());
stdlib::builtins::make_module(self, self.builtins.clone());
stdlib::sys::make_module(self, self.sys_module.clone(), self.builtins.clone());

let mut inner_init = || -> PyResult<()> {
Expand Down