diff --git a/Cargo.lock b/Cargo.lock index 35435cabd..917b87061 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -918,6 +918,17 @@ dependencies = [ "xdg 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "rustpython_bytecode" +version = "0.1.0" +dependencies = [ + "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "num-bigint 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "num-complex 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "rustpython_parser 0.0.1", + "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "rustpython_compiler" version = "0.1.0" @@ -926,6 +937,7 @@ dependencies = [ "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", "num-bigint 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "num-complex 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "rustpython_bytecode 0.1.0", "rustpython_parser 0.0.1", "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -938,6 +950,7 @@ dependencies = [ "proc-macro-hack 0.5.7 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", + "rustpython_bytecode 0.1.0", "rustpython_compiler 0.1.0", "syn 0.15.35 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -984,6 +997,7 @@ dependencies = [ "rand 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version_runtime 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "rustpython_bytecode 0.1.0", "rustpython_compiler 0.1.0", "rustpython_derive 0.1.0", "rustpython_parser 0.0.1", diff --git a/Cargo.toml b/Cargo.toml index 2a4fc23bf..315b5114c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,11 +1,11 @@ [package] name = "rustpython" version = "0.0.1" -authors = ["Windel Bouwman", "Shing Lyu "] +authors = ["Windel Bouwman ", "Shing Lyu "] edition = "2018" [workspace] -members = [".", "derive", "vm", "wasm/lib", "parser", "compiler"] +members = [".", "derive", "vm", "wasm/lib", "parser", "compiler", "bytecode"] [[bench]] name = "bench" diff --git a/bytecode/Cargo.toml b/bytecode/Cargo.toml new file mode 100644 index 000000000..a67328bcd --- /dev/null +++ b/bytecode/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "rustpython_bytecode" +version = "0.1.0" +authors = ["Windel Bouwman "] +edition = "2018" + +[dependencies] +bitflags = "1.1" +num-bigint = { version = "0.2", features = ["serde"] } +num-complex = { version = "0.2", features = ["serde"] } +serde = { version = "1.0", features = ["derive"] } +rustpython_parser = { path = "../parser" } diff --git a/compiler/src/bytecode.rs b/bytecode/src/bytecode.rs similarity index 100% rename from compiler/src/bytecode.rs rename to bytecode/src/bytecode.rs diff --git a/bytecode/src/lib.rs b/bytecode/src/lib.rs new file mode 100644 index 000000000..c6e3077a9 --- /dev/null +++ b/bytecode/src/lib.rs @@ -0,0 +1 @@ +pub mod bytecode; diff --git a/compiler/Cargo.toml b/compiler/Cargo.toml index fc0d19593..d0aa09262 100644 --- a/compiler/Cargo.toml +++ b/compiler/Cargo.toml @@ -1,11 +1,12 @@ [package] name = "rustpython_compiler" version = "0.1.0" -authors = ["coolreader18 <33094578+coolreader18@users.noreply.github.com>"] +authors = ["coolreader18 <33094578+coolreader18@users.noreply.github.com>", "Windel Bouwman "] edition = "2018" [dependencies] bitflags = "1.1" +rustpython_bytecode = { path = "../bytecode" } rustpython_parser = { path = "../parser" } serde = { version = "1.0", features = ["derive"] } num-complex = { version = "0.2", features = ["serde"] } diff --git a/compiler/src/compile.rs b/compiler/src/compile.rs index c4e4a1a2d..b50ae3329 100644 --- a/compiler/src/compile.rs +++ b/compiler/src/compile.rs @@ -5,10 +5,10 @@ //! https://github.com/python/cpython/blob/master/Python/compile.c //! https://github.com/micropython/micropython/blob/master/py/compile.c -use crate::bytecode::{self, CallType, CodeObject, Instruction, Varargs}; use crate::error::{CompileError, CompileErrorType}; use crate::symboltable::{make_symbol_table, statements_to_symbol_table, SymbolRole, SymbolScope}; use num_complex::Complex64; +use rustpython_bytecode::bytecode::{self, CallType, CodeObject, Instruction, Varargs}; use rustpython_parser::{ast, parser}; struct Compiler { diff --git a/compiler/src/lib.rs b/compiler/src/lib.rs index 382647d15..e0e6fb2bf 100644 --- a/compiler/src/lib.rs +++ b/compiler/src/lib.rs @@ -4,7 +4,6 @@ #[macro_use] extern crate log; -pub mod bytecode; pub mod compile; pub mod error; mod symboltable; diff --git a/derive/Cargo.toml b/derive/Cargo.toml index 8ef896562..bcf56dc6f 100644 --- a/derive/Cargo.toml +++ b/derive/Cargo.toml @@ -12,5 +12,6 @@ syn = { version = "0.15.29", features = ["full"] } quote = "0.6.11" proc-macro2 = "0.4.27" rustpython_compiler = { path = "../compiler" } +rustpython_bytecode = { path = "../bytecode" } bincode = "1.1" proc-macro-hack = "0.5" diff --git a/derive/src/compile_bytecode.rs b/derive/src/compile_bytecode.rs index e344746e5..8fa9f0c7f 100644 --- a/derive/src/compile_bytecode.rs +++ b/derive/src/compile_bytecode.rs @@ -17,7 +17,8 @@ use crate::{extract_spans, Diagnostic}; use bincode; use proc_macro2::{Span, TokenStream as TokenStream2}; use quote::quote; -use rustpython_compiler::{bytecode::CodeObject, compile}; +use rustpython_bytecode::bytecode::CodeObject; +use rustpython_compiler::compile; use std::env; use std::fs; use std::path::PathBuf; diff --git a/vm/Cargo.toml b/vm/Cargo.toml index d2dc30e42..f608546e6 100644 --- a/vm/Cargo.toml +++ b/vm/Cargo.toml @@ -15,6 +15,7 @@ log = "0.3" rustpython_derive = {path = "../derive"} rustpython_parser = {path = "../parser"} rustpython_compiler = {path = "../compiler"} +rustpython_bytecode = { path = "../bytecode" } serde = { version = "1.0.66", features = ["derive"] } serde_json = "1.0.26" byteorder = "1.2.6" diff --git a/vm/src/lib.rs b/vm/src/lib.rs index f60be1c7d..13fd3b5d3 100644 --- a/vm/src/lib.rs +++ b/vm/src/lib.rs @@ -65,6 +65,7 @@ mod vm; // pub use self::pyobject::Executor; pub use self::exceptions::print_exception; pub use self::vm::VirtualMachine; +pub use rustpython_bytecode::*; pub use rustpython_compiler::*; #[doc(hidden)]