chore: cargo fmt

This commit is contained in:
2025-05-19 11:33:18 +08:00
parent e17c48f2d9
commit 6d26716412
14 changed files with 209 additions and 79 deletions

View File

@@ -1,8 +1,8 @@
use std::cell::{Cell, OnceCell};
use derive_more::Constructor;
use inkwell::execution_engine::JitFunction;
use itertools::Itertools;
use derive_more::Constructor;
use crate::bytecode::Func as BFunc;
use crate::error::Result;
@@ -46,7 +46,7 @@ pub struct Func<'jit: 'vm, 'vm> {
pub func: &'vm BFunc,
pub env: Env<'jit, 'vm>,
pub compiled: OnceCell<JitFunction<'jit, JITFunc<'jit, 'vm>>>,
pub count: Cell<usize>
pub count: Cell<usize>,
}
impl<'vm, 'jit: 'vm> Func<'jit, 'vm> {
@@ -94,7 +94,7 @@ impl<'vm, 'jit: 'vm> Func<'jit, 'vm> {
if count >= 1 {
let compiled = self.compiled.get_or_init(|| vm.compile_func(self.func));
let ret = unsafe { compiled.call(vm as *const VM, &env as *const Env) };
return Ok(ret.into())
return Ok(ret.into());
}
vm.eval(self.func.opcodes.iter().copied(), env)
}

View File

@@ -76,7 +76,9 @@ impl<'jit: 'vm, 'vm> PartialEq for Value<'jit, 'vm> {
use Value::*;
match (self, other) {
(Const(a), Const(b)) => a.eq(b),
(AttrSet(a), AttrSet(b)) => (a.as_ref() as *const self::AttrSet).eq(&(b.as_ref() as *const _)),
(AttrSet(a), AttrSet(b)) => {
(a.as_ref() as *const self::AttrSet).eq(&(b.as_ref() as *const _))
}
(List(a), List(b)) => (a.as_ref() as *const self::List).eq(&(b.as_ref() as *const _)),
(Builtins(a), Builtins(b)) => a.ptr_eq(b),
_ => false,

View File

@@ -56,7 +56,11 @@ impl PartialEq for PartialPrimOp<'_, '_> {
}
impl<'jit: 'vm, 'vm> PartialPrimOp<'jit, 'vm> {
pub fn call(self: &Rc<Self>, vm: &'vm VM<'jit>, args: Vec<Value<'jit, 'vm>>) -> Result<Value<'jit, 'vm>> {
pub fn call(
self: &Rc<Self>,
vm: &'vm VM<'jit>,
args: Vec<Value<'jit, 'vm>>,
) -> Result<Value<'jit, 'vm>> {
let len = args.len();
let mut self_clone = self.clone();
let self_mut = Rc::make_mut(&mut self_clone);