feat(env): move env out of vm,

This commit is contained in:
2025-05-23 19:19:20 +08:00
parent 5291e49313
commit b41fd38bcc
10 changed files with 62 additions and 41 deletions

View File

@@ -5,8 +5,9 @@ use hashbrown::{HashMap, HashSet};
use derive_more::Constructor;
use itertools::Itertools;
use crate::env::VmEnv;
use crate::error::Result;
use crate::vm::{VM, VmEnv};
use crate::vm::VM;
use super::super::public as p;
use super::Value;

View File

@@ -6,11 +6,12 @@ use inkwell::execution_engine::JitFunction;
use itertools::Itertools;
use crate::bytecode::Func as BFunc;
use crate::env::VmEnv;
use crate::error::Result;
use crate::ir;
use crate::jit::JITFunc;
use crate::ty::internal::{Thunk, Value};
use crate::vm::{VM, VmEnv};
use crate::vm::VM;
#[derive(Debug, Clone)]
pub enum Param {
@@ -63,7 +64,8 @@ impl<'vm, 'jit: 'vm> Func<'jit, 'vm> {
alias,
} => {
let arg = arg.unwrap_attr_set();
let mut new = HashMap::with_capacity_in(formals.len() + alias.iter().len(), &vm.bump);
let mut new =
HashMap::with_capacity_in(formals.len() + alias.iter().len(), &vm.bump);
if !ellipsis
&& arg
.as_inner()

View File

@@ -10,8 +10,9 @@ use super::common::*;
use super::public as p;
use crate::bytecode::OpCodes;
use crate::env::VmEnv;
use crate::error::*;
use crate::vm::{VM, VmEnv};
use crate::vm::VM;
mod attrset;
mod func;
@@ -231,7 +232,7 @@ impl<'jit, 'vm> Value<'jit, 'vm> {
pub fn lt(&mut self, other: Self) {
use Const::*;
*self = VmConst(Bool(match (&*self, other) {
*self = VmConst(Bool(match (&*self, other) {
(VmConst(Int(a)), VmConst(Int(b))) => *a < b,
(VmConst(Int(a)), VmConst(Float(b))) => (*a as f64) < b,
(VmConst(Float(a)), VmConst(Int(b))) => *a < b as f64,
@@ -241,7 +242,7 @@ impl<'jit, 'vm> Value<'jit, 'vm> {
(_, x @ Value::Catchable(_)) => {
*self = x;
return;
},
}
_ => todo!(),
}))
}

View File

@@ -69,6 +69,6 @@ impl<'jit: 'vm, 'vm> PartialPrimOp<'jit, 'vm> {
} else {
let args = std::mem::take(&mut self_mut.args);
(self.func)(vm, args)
}
}
}
}