refactor: 拆分 bytecode/cache crate 并模块化 counter

This commit is contained in:
爱特每羊队
2026-06-23 17:06:39 +08:00
parent f7db0230f7
commit dbc15f6d1f
38 changed files with 1332 additions and 1306 deletions
+2
View File
@@ -11,6 +11,8 @@ name = "oxide"
path = "src/main.rs"
[dependencies]
oxide_bytecode = { path = "../oxide_bytecode" }
oxide_code_cache = { path = "../oxide_code_cache" }
oxide_parser = { path = "../oxide_parser" }
oxide_types = { path = "../oxide_types" }
oxide_compiler = { path = "../oxide_compiler" }
+3 -2
View File
@@ -6,7 +6,7 @@ use std::sync::Arc;
use ansi_term::Colour::Red;
use clap::{Parser, Subcommand};
use oxide_compiler::compiler::Compiler;
use oxide_compiler::compiler::{compiled_module_hash, Compiler};
use oxide_kernel::kernel::{KernelConfig, KernelCore};
use oxide_kernel::shape_forge::{ShapeForge, EMPTY_SHAPE_ID};
use oxide_kernel::string_forge::StringForge;
@@ -91,7 +91,8 @@ fn eval(code: &str, kernel: &Arc<KernelCore>, pool: &Arc<VmPool>) -> ExitCode {
};
let compiler = Compiler::new();
let module = match kernel.code_forge().get_or_compile(&program, &compiler) {
let hash = compiled_module_hash(&program);
let module = match kernel.code_forge().get_or_insert_with(hash, || compiler.compile(&program)) {
Ok(m) => m,
Err(err) => {
eprintln!("{}", Red.paint(err));