feat: ir env (WIP)

This commit is contained in:
2025-05-30 18:29:04 +08:00
parent c548c4c6ac
commit 7d6168fdae
10 changed files with 500 additions and 164 deletions

View File

@@ -5,7 +5,7 @@ use hashbrown::{HashMap, HashSet};
use inkwell::context::Context;
use itertools::Itertools;
use crate::builtins::env;
use crate::builtins::vm_env;
use crate::bytecode::{BinOp, Func as F, OpCode, OpCodes, Program, UnOp};
use crate::env::VmEnv;
use crate::error::*;
@@ -22,7 +22,6 @@ use ecow::EcoString;
mod test;
const STACK_SIZE: usize = 8 * 1024 / size_of::<Value>();
type GcArena = Arena<Rootable!['gc => GcRoot<'gc>]>;
#[derive(Collect)]
#[collect(require_static)]
@@ -53,7 +52,7 @@ pub fn run(mut prog: Program) -> Result<p::Value> {
vm,
jit,
stack: Stack::new(),
envs: vec![env(&vm, mc)],
envs: vec![vm_env(&vm, mc)],
}
});
prog.top_level.reverse();
@@ -331,7 +330,7 @@ fn single_op<'gc, const CAP: usize>(
}
OpCode::LookUp { sym } => {
stack.push(
env.lookup(&sym)
env.lookup_slow(&sym)
.ok_or_else(|| Error::EvalError(format!("{} not found", vm.get_sym(sym))))?
.clone(),
)?;