refactor(downgrade): MaybeThunk

This commit is contained in:
2026-04-12 16:19:29 +08:00
parent e34cfc7add
commit 9d4c37950e
5 changed files with 226 additions and 221 deletions
+15 -15
View File
@@ -413,9 +413,7 @@ impl<'gc> GcRoot<'gc> {
let Ok(ty) = AttrKeyType::try_from_primitive(tag)
.map_err(|err| panic!("unknown key tag: {:#04x}", err.number));
match ty {
AttrKeyType::Static => {
keys.push(SelectKeyData::Static(read!(StringId)))
}
AttrKeyType::Static => keys.push(SelectKeyData::Static(read!(StringId))),
AttrKeyType::Dynamic => keys.push(SelectKeyData::Dynamic),
};
}
@@ -598,14 +596,15 @@ impl<'gc> GcRoot<'gc> {
}
Call => {
// force func
try_force!(0, inst_start_pc);
if self.call_depth > 10000 {
return Action::Done(Err(Error::eval_error("stack overflow; max-call-depth exceeded")))
return Action::Done(Err(Error::eval_error(
"stack overflow; max-call-depth exceeded",
)));
}
self.call_depth += 1;
let func = self.pop_stack();
let arg = self.pop_stack();
let arg = read!(OperandData).resolve(mc, self);
if let Some(closure) = func.as_gc::<Closure>() {
let ip = closure.ip;
let n_locals = closure.n_locals;
@@ -783,16 +782,17 @@ impl<'gc> GcRoot<'gc> {
};
if let Some(attrset) = current_val.as_gc::<AttrSet>()
&& let Some(v) = attrset.lookup(key_sid) {
if i < n - 1 {
current_val = v.restrict().unwrap_or_else(|_| {
panic!("intermediate select values must be forced")
});
} else {
result_val = Some(v);
}
continue;
&& let Some(v) = attrset.lookup(key_sid)
{
if i < n - 1 {
current_val = v.restrict().unwrap_or_else(|_| {
panic!("intermediate select values must be forced")
});
} else {
result_val = Some(v);
}
continue;
}
use_default = true;
break;