feat: gc-arena

finally...
This commit is contained in:
2025-05-28 21:52:13 +08:00
parent c3ace28af1
commit 99dce2e778
7 changed files with 98 additions and 99 deletions

View File

@@ -604,13 +604,13 @@ impl<'gc> Thunk<'gc> {
}
}
pub fn suspend(&self, mc: &Mutation<'gc>) -> (&'gc OpCodes, Gc<'gc, VmEnv<'gc>>) {
pub fn suspend(&self, mc: &Mutation<'gc>) -> Result<(&'gc OpCodes, Gc<'gc, VmEnv<'gc>>)> {
let _Thunk::Code(opcodes, env) =
std::mem::replace(&mut *self.thunk.borrow_mut(mc), _Thunk::Suspended)
else {
unreachable!()
return Err(Error::EvalError("infinite recursion occured".into()))
};
(opcodes, env.unwrap())
Ok((opcodes, env.unwrap()))
}
pub fn insert_value(&self, value: Value<'gc>, mc: &Mutation<'gc>) {