From c16e6500718da1ab1f075bc4e70f17f70bb5a0b0 Mon Sep 17 00:00:00 2001 From: Jeong YunWon Date: Mon, 22 Aug 2022 07:34:30 +0900 Subject: [PATCH] rustpython-bytecode -> rustpython-compiler-core --- Cargo.toml | 2 +- ast/Cargo.toml | 2 +- ast/src/constant.rs | 2 +- {bytecode => core}/Cargo.toml | 2 +- bytecode/src/lib.rs => core/src/bytecode.rs | 18 ++++++------------ core/src/lib.rs | 8 ++++++++ {bytecode => core}/src/mode.rs | 0 7 files changed, 18 insertions(+), 16 deletions(-) rename {bytecode => core}/Cargo.toml (93%) rename bytecode/src/lib.rs => core/src/bytecode.rs (98%) create mode 100644 core/src/lib.rs rename {bytecode => core}/src/mode.rs (100%) diff --git a/Cargo.toml b/Cargo.toml index 00fc914..118286f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,7 +6,7 @@ authors = ["RustPython Team"] edition = "2021" [dependencies] -rustpython-bytecode = { path = "bytecode" } +rustpython-compiler-core = { path = "core" } rustpython-codegen = { path = "codegen" } rustpython-parser = { path = "parser" } diff --git a/ast/Cargo.toml b/ast/Cargo.toml index 39eedf4..7efefb3 100644 --- a/ast/Cargo.toml +++ b/ast/Cargo.toml @@ -12,5 +12,5 @@ unparse = ["rustpython-common"] [dependencies] num-bigint = "0.4.3" -rustpython-bytecode = { path = "../bytecode" } +rustpython-compiler-core = { path = "../core" } rustpython-common = { path = "../../common", optional = true } diff --git a/ast/src/constant.rs b/ast/src/constant.rs index 1d16559..b73bab6 100644 --- a/ast/src/constant.rs +++ b/ast/src/constant.rs @@ -1,5 +1,5 @@ use num_bigint::BigInt; -pub use rustpython_bytecode::ConversionFlag; +pub use rustpython_compiler_core::ConversionFlag; #[derive(Debug, PartialEq)] pub enum Constant { diff --git a/bytecode/Cargo.toml b/core/Cargo.toml similarity index 93% rename from bytecode/Cargo.toml rename to core/Cargo.toml index 05d698e..5821ddc 100644 --- a/bytecode/Cargo.toml +++ b/core/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "rustpython-bytecode" +name = "rustpython-compiler-core" description = "RustPython specific bytecode." version = "0.1.2" authors = ["RustPython Team"] diff --git a/bytecode/src/lib.rs b/core/src/bytecode.rs similarity index 98% rename from bytecode/src/lib.rs rename to core/src/bytecode.rs index c53697b..8e9cc75 100644 --- a/bytecode/src/lib.rs +++ b/core/src/bytecode.rs @@ -1,12 +1,6 @@ //! Implement python as a virtual machine with bytecodes. This module //! implements bytecode structure. -#![doc(html_logo_url = "https://raw.githubusercontent.com/RustPython/RustPython/main/logo.png")] -#![doc(html_root_url = "https://docs.rs/rustpython-bytecode/")] - -mod mode; -pub use mode::Mode; - use bitflags::bitflags; use bstr::ByteSlice; use itertools::Itertools; @@ -27,7 +21,7 @@ impl Location { /// /// # Example /// ``` - /// use rustpython_bytecode::Location; + /// use rustpython_compiler_core::Location; /// let loc = Location::new(10, 10); /// ``` pub fn new(row: usize, column: usize) -> Self { @@ -433,7 +427,7 @@ bitflags! { /// /// # Examples /// ``` -/// use rustpython_bytecode::ConstantData; +/// use rustpython_compiler_core::ConstantData; /// let a = ConstantData::Float {value: 120f64}; /// let b = ConstantData::Boolean {value: false}; /// assert_ne!(a, b); @@ -599,8 +593,8 @@ pub enum TestOperator { /// # Examples /// /// ``` -/// use rustpython_bytecode::Instruction::BinaryOperation; -/// use rustpython_bytecode::BinaryOperator::Add; +/// use rustpython_compiler_core::Instruction::BinaryOperation; +/// use rustpython_compiler_core::BinaryOperator::Add; /// let op = BinaryOperation {op: Add}; /// ``` #[derive(Debug, Copy, Clone, PartialEq, Eq, Serialize, Deserialize)] @@ -943,7 +937,7 @@ impl Instruction { /// # Examples /// /// ``` - /// use rustpython_bytecode::{Instruction, Label}; + /// use rustpython_compiler_core::{Instruction, Label}; /// let label = Label(0xF); /// let jump_inst = Instruction::Jump {target: label}; /// assert!(jump_inst.unconditional_branch()) @@ -960,7 +954,7 @@ impl Instruction { /// # Examples /// /// ``` - /// use rustpython_bytecode::{Instruction, Label, UnaryOperator}; + /// use rustpython_compiler_core::{Instruction, Label, UnaryOperator}; /// let jump_instruction = Instruction::Jump {target: Label(0xF)}; /// let invert_instruction = Instruction::UnaryOperation {op: UnaryOperator::Invert}; /// assert_eq!(jump_instruction.stack_effect(true), 0); diff --git a/core/src/lib.rs b/core/src/lib.rs new file mode 100644 index 0000000..ac798da --- /dev/null +++ b/core/src/lib.rs @@ -0,0 +1,8 @@ +#![doc(html_logo_url = "https://raw.githubusercontent.com/RustPython/RustPython/main/logo.png")] +#![doc(html_root_url = "https://docs.rs/rustpython-compiler-core/")] + +pub mod bytecode; +mod mode; + +pub use bytecode::*; +pub use mode::Mode; diff --git a/bytecode/src/mode.rs b/core/src/mode.rs similarity index 100% rename from bytecode/src/mode.rs rename to core/src/mode.rs