From a2762fe3c933b7774a39771d47f59574bd59234d Mon Sep 17 00:00:00 2001 From: pjh456 <147148383@qq.com> Date: Sat, 6 Jun 2026 18:18:31 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=20do=20while=20?= =?UTF-8?q?=E4=B8=8E=20for-in=20=E8=AF=AD=E6=B3=95=E6=9E=9A=E4=B8=BE?= =?UTF-8?q?=E6=8C=87=E4=BB=A4=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Cargo.lock | 1 + Cargo.toml | 2 +- crates/oxide_compiler/src/compiler.rs | 22 ++++++++++++++++++++++ crates/oxide_compiler/src/hash.rs | 22 ++++++++++++++++++++++ crates/oxide_compiler/src/module.rs | 4 ++++ crates/oxide_compiler/src/opcode.rs | 15 +++++++++++++++ crates/oxide_kernel/src/string_forge.rs | 5 +++++ 7 files changed, 70 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 8b7852ea..d0245c21 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -817,6 +817,7 @@ dependencies = [ name = "oxide_vm" version = "0.1.0" dependencies = [ + "bumpalo", "fast-float", "oxide_compiler", "oxide_kernel", diff --git a/Cargo.toml b/Cargo.toml index 71bf293e..af87c4b3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -30,7 +30,7 @@ serde = "1" serde_json = "1" dashmap = "6" rayon = "1" -bumpalo = "3" +bumpalo = { version = "3", features = ["collections"] } hashbrown = "0.14" proptest = "1" rustc-hash = "2" diff --git a/crates/oxide_compiler/src/compiler.rs b/crates/oxide_compiler/src/compiler.rs index 09dfad1b..258ba40f 100644 --- a/crates/oxide_compiler/src/compiler.rs +++ b/crates/oxide_compiler/src/compiler.rs @@ -26,6 +26,7 @@ pub(crate) fn is_side_effect_free(expr: &Expression) -> bool { } #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] +#[allow(dead_code)] pub(crate) enum Label { IfElse(u32), IfEnd(u32), @@ -36,6 +37,12 @@ pub(crate) enum Label { ForEnd(u32), TernaryEnd(u32), TernaryElse(u32), + DoWhileStart(u32), + DoWhileEnd(u32), + ForInStart(u32), + ForInEnd(u32), + SwitchEnd(u32), + SwitchCase(u32), } pub(crate) struct CompileCtx { @@ -46,6 +53,8 @@ pub(crate) struct CompileCtx { symbols: SymbolTable, pub(crate) label_map: HashMap, pub(crate) loop_stack: Vec<(Label, Label)>, + #[allow(dead_code)] + pub(crate) switch_stack: Vec