refactor: use GAT in enum Ir
This commit is contained in:
+12
-5
@@ -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!(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user