feat: builtins env (WIP)

This commit is contained in:
2025-06-06 09:48:03 +08:00
parent 484cfa4610
commit 0fd846e844
5 changed files with 9 additions and 103 deletions

View File

@@ -8,7 +8,7 @@ use crate::{ir::Ir, ty::internal::Value};
pub struct Env<K: Hash + Eq, V> {
let_: Rc<LetEnv<V>>,
with: Rc<With<K, V>>,
args: Vec<V>,
args: Rc<Vec<V>>,
last: Option<Rc<Env<K, V>>>,
}
@@ -42,11 +42,11 @@ impl<K: Hash + Eq + Clone, V: Clone> Env<K, V> {
pub fn new(map: Vec<V>) -> Rc<Self> {
Rc::new(Self {
let_: LetEnv::new(map),
with: Rc::new(With {
with: With {
map: None,
last: None,
}),
args: Vec::new(),
}.into(),
args: Vec::new().into(),
last: None,
})
}
@@ -70,7 +70,7 @@ impl<K: Hash + Eq + Clone, V: Clone> Env<K, V> {
#[must_use]
pub fn enter_arg(self: Rc<Self>, val: V) -> Rc<Self> {
let mut args = self.args.clone();
args.push(val);
Rc::make_mut(&mut args).push(val);
Rc::new(Self {
let_: self.let_.clone(),
with: self.with.clone(),