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

@@ -1,11 +1,16 @@
use gc_arena::{Gc, Mutation};
use hashbrown::HashMap;
use crate::env::VmEnv;
use crate::env::{IrEnv, VmEnv};
use crate::ty::internal::{AttrSet, CoW, PrimOp, Value};
use crate::vm::VM;
pub fn env<'gc>(vm: &VM, mc: &Mutation<'gc>) -> Gc<'gc, VmEnv<'gc>> {
pub fn ir_env<'gc>(mc: &Mutation<'gc>) -> Gc<'gc, IrEnv<'gc>> {
// TODO:
IrEnv::new(Gc::new(mc, HashMap::new()), mc)
}
pub fn vm_env<'gc>(vm: &VM, mc: &Mutation<'gc>) -> Gc<'gc, VmEnv<'gc>> {
let primops = [
PrimOp::new("add", 2, |args, _, mc| {
let Ok([mut first, second]): Result<[Value; 2], _> = args.try_into() else {