feat: JIT (WIP)

This commit is contained in:
2025-06-22 17:17:33 +08:00
parent f679ff2ec9
commit e26789f3b7
6 changed files with 373 additions and 133 deletions

View File

@@ -25,7 +25,10 @@ impl Env {
}
}
pub fn with_new_cache<T>(&mut self, f: impl FnOnce(&mut Self) -> T) -> (T, HashMap<usize, Value>) {
pub fn with_new_cache<T>(
&mut self,
f: impl FnOnce(&mut Self) -> T,
) -> (T, HashMap<usize, Value>) {
self.cache.push(HashMap::new());
let ret = f(self);
(ret, self.cache.pop().unwrap())
@@ -76,7 +79,7 @@ impl Env {
self.args[self.args.len() - level - 1].clone()
}
pub fn lookup_with(&self, symbol: &EcoString) -> Option<Value> {
pub fn lookup_with(&self, symbol: &str) -> Option<Value> {
for with in self.with.iter().rev() {
if let Some(ret) = with.get(symbol) {
return Some(ret.clone());