feat: generalize env

This commit is contained in:
2025-05-21 09:33:43 +08:00
parent 36f29a9cac
commit 177acfabcf
8 changed files with 77 additions and 70 deletions

View File

@@ -11,7 +11,7 @@ use super::public as p;
use crate::bytecode::OpCodes;
use crate::error::*;
use crate::vm::{LetEnv, VM};
use crate::vm::{VmEnv, VM};
mod attrset;
mod func;
@@ -477,7 +477,7 @@ pub struct Thunk<'jit, 'vm> {
#[derive(Debug, IsVariant, Unwrap, Clone)]
pub enum _Thunk<'jit, 'vm> {
Code(&'vm OpCodes, OnceCell<Rc<LetEnv<'jit, 'vm>>>),
Code(&'vm OpCodes, OnceCell<Rc<VmEnv<'jit, 'vm>>>),
SuspendedFrom(*const Thunk<'jit, 'vm>),
Value(Value<'jit, 'vm>),
}
@@ -489,7 +489,7 @@ impl<'jit, 'vm> Thunk<'jit, 'vm> {
}
}
pub fn capture(&self, env: Rc<LetEnv<'jit, 'vm>>) {
pub fn capture(&self, env: Rc<VmEnv<'jit, 'vm>>) {
if let _Thunk::Code(_, envcell) = &*self.thunk.borrow() {
envcell.get_or_init(|| env);
}