refactor: use GAT in enum Ir

This commit is contained in:
2026-05-01 20:18:00 +08:00
parent 0df38f374f
commit 5dd160cc43
7 changed files with 331 additions and 214 deletions
+12 -5
View File
@@ -227,16 +227,21 @@ pub struct Vm<'gc> {
pub(crate) enum OperandData {
Const(StaticValue),
BigInt(i64),
Local { layer: u8, idx: u32 },
Builtins,
BigInt(i64),
ReplBinding(StringId),
ScopedImportBinding(StringId),
WithLookup(StringId),
}
impl OperandData {
pub(crate) fn resolve<'gc>(&self, mc: &Mutation<'gc>, root: &Vm<'gc>) -> Value<'gc> {
use OperandData::*;
match *self {
OperandData::Const(sv) => sv.into(),
OperandData::Local { layer, idx } => {
Const(sv) => sv.into(),
BigInt(val) => Value::new_gc(Gc::new(mc, val)),
Local { layer, idx } => {
let mut cur = root.env;
for _ in 0..layer {
let prev = cur.borrow().prev.expect("env chain too short");
@@ -244,8 +249,10 @@ impl OperandData {
}
cur.borrow().locals[idx as usize]
}
OperandData::Builtins => root.builtins,
OperandData::BigInt(val) => Value::new_gc(Gc::new(mc, val)),
Builtins => root.builtins,
ReplBinding(_id) => todo!(),
ScopedImportBinding(_id) => todo!(),
WithLookup(_id) => todo!(),
}
}
}