refactor: reorganize crate hierarchy

This commit is contained in:
2026-06-06 20:53:02 +08:00
parent 9412c319f9
commit 81ac08fb5a
53 changed files with 1422 additions and 1547 deletions
+11 -11
View File
@@ -7,10 +7,9 @@
use std::path::PathBuf;
use fix_builtins::{BUILTINS, BuiltinId};
use fix_codegen::InstructionPtr;
use fix_common::StringId;
use fix_bytecode::{InstructionPtr, PrimOpPhase};
use fix_error::{Error, Result, Source};
use fix_lang::{BUILTINS, BuiltinId, StringId};
use gc_arena::metrics::Pacing;
use gc_arena::{Arena, Collect, Gc, Mutation, RefLock, Rootable};
use hashbrown::HashMap;
@@ -19,8 +18,9 @@ use smallvec::SmallVec;
#[cfg(feature = "tailcall")]
mod dispatch_tailcall;
pub use fix_abstract_vm::*;
pub use fix_runtime::*;
mod instructions;
mod primops;
type VmResult<T> = std::result::Result<T, VmError>;
@@ -46,7 +46,7 @@ pub struct Vm<'gc> {
force_mode: ForceMode,
#[collect(require_static)]
result: Option<Result<fix_common::Value>>,
result: Option<Result<fix_lang::Value>>,
#[collect(require_static)]
pending_load: Option<PendingLoad>,
@@ -61,7 +61,7 @@ fn init_builtins<'gc>(mc: &Mutation<'gc>, ctx: &mut impl VmRuntimeCtx) -> Value<
let id = BuiltinId::try_from_primitive(idx as u8).expect("infallible");
let name = name.strip_prefix("__").unwrap_or(name);
let name = ctx.intern_string(name);
let dispatch_ip = id.entry_phase().ip();
let dispatch_ip = PrimOpPhase::entry_for_builtin(id).ip();
entries.push((
name,
Value::new_inline(PrimOp {
@@ -139,7 +139,7 @@ impl<'gc> Vm<'gc> {
}
#[inline(always)]
fn finish_ok(&mut self, val: fix_common::Value) -> Step {
fn finish_ok(&mut self, val: fix_lang::Value) -> Step {
self.result = Some(Ok(val));
Step::Break(Break::Done)
}
@@ -409,7 +409,7 @@ impl<'gc> Machine<'gc> for Vm<'gc> {
}
#[inline(always)]
fn finish_ok(&mut self, val: fix_common::Value) -> Step {
fn finish_ok(&mut self, val: fix_lang::Value) -> Step {
self.finish_ok(val)
}
@@ -481,7 +481,7 @@ impl<'gc> Machine<'gc> for Vm<'gc> {
enum Action {
Continue { pc: usize },
Done(Result<fix_common::Value>),
Done(Result<fix_lang::Value>),
LoadFile(PendingLoad),
}
@@ -504,7 +504,7 @@ impl Vm<'_> {
ctx: &mut C,
ip: InstructionPtr,
force_mode: ForceMode,
) -> Result<fix_common::Value> {
) -> Result<fix_lang::Value> {
let (code, runtime) = ctx.split();
let mut arena: Arena<Rootable![Vm<'_>]> = Arena::new(|mc| Vm::new(force_mode, mc, runtime));
arena.metrics().set_pacing(Pacing {
@@ -589,7 +589,7 @@ impl<'gc> Vm<'gc> {
pc: usize,
mc: &Mutation<'gc>,
) -> Action {
use fix_codegen::Op::*;
use fix_bytecode::Op::*;
let mut reader = BytecodeReader::new(bytecode, pc);
let mut fuel = Self::DEFAULT_FUEL_AMOUNT;