feat: generalize env
This commit is contained in:
@@ -6,12 +6,12 @@ use derive_more::Constructor;
|
||||
use itertools::Itertools;
|
||||
|
||||
use crate::error::Result;
|
||||
use crate::vm::{LetEnv, VM};
|
||||
use crate::vm::{VmEnv, VM};
|
||||
|
||||
use super::super::public as p;
|
||||
use super::Value;
|
||||
|
||||
#[repr(C)]
|
||||
#[repr(transparent)]
|
||||
#[derive(Debug, Default, Constructor, Clone, PartialEq)]
|
||||
pub struct AttrSet<'jit: 'vm, 'vm> {
|
||||
data: HashMap<usize, Value<'jit, 'vm>>,
|
||||
@@ -52,7 +52,7 @@ impl<'jit: 'vm, 'vm> AttrSet<'jit, 'vm> {
|
||||
self.data.get(&sym).is_some()
|
||||
}
|
||||
|
||||
pub fn capture(&mut self, env: &Rc<LetEnv<'jit, 'vm>>) {
|
||||
pub fn capture(&mut self, env: &Rc<VmEnv<'jit, 'vm>>) {
|
||||
self.data.iter().for_each(|(_, v)| if let Value::Thunk(ref thunk) = v.clone() {
|
||||
thunk.capture(env.clone());
|
||||
})
|
||||
@@ -68,6 +68,10 @@ impl<'jit: 'vm, 'vm> AttrSet<'jit, 'vm> {
|
||||
&self.data
|
||||
}
|
||||
|
||||
pub fn into_inner(self: Rc<Self>) -> Rc<HashMap<usize, Value<'jit, 'vm>>> {
|
||||
unsafe { std::mem::transmute(self) }
|
||||
}
|
||||
|
||||
pub fn from_inner(data: HashMap<usize, Value<'jit, 'vm>>) -> Self {
|
||||
Self { data }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user