feat: no clone in JIT

IMPORTANT: should not drop or create values in JIT anymore
This commit is contained in:
2025-05-21 20:48:56 +08:00
parent 177acfabcf
commit 2a19ddb279
11 changed files with 105 additions and 82 deletions

View File

@@ -1,5 +1,5 @@
use std::{hash::Hash, rc::Rc};
use std::fmt::Debug;
use std::{hash::Hash, rc::Rc};
use hashbrown::HashMap;
@@ -7,21 +7,24 @@ use crate::ty::internal::{AttrSet, Value};
pub struct Env<K: Hash + Eq, V> {
map: Node<K, V>,
last: Option<Rc<Env<K, V>>>
last: Option<Rc<Env<K, V>>>,
}
impl<K: Clone + Hash + Eq, V: Clone> Clone for Env<K, V> {
fn clone(&self) -> Self {
Self {
map: self.map.clone(),
last: self.last.clone()
last: self.last.clone(),
}
}
}
impl<K: Debug + Hash + Eq, V: Debug> Debug for Env<K, V> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("Env").field("map", &self.map).field("last", &self.last).finish()
f.debug_struct("Env")
.field("map", &self.map)
.field("last", &self.last)
.finish()
}
}
@@ -86,7 +89,8 @@ impl<K: Hash + Eq, V> Env<K, V> {
pub fn enter_with(self: Rc<Self>, map: Rc<HashMap<K, V>>) -> Rc<Self> {
let map = Node::Let(map);
let last = Some(self);Env { last, map }.into()
let last = Some(self);
Env { last, map }.into()
}
pub fn leave(self: Rc<Self>) -> Rc<Self> {