feat(gc): WIP

This commit is contained in:
2025-06-02 12:00:38 +08:00
parent 20b2b6f1ef
commit d3442e87e7
7 changed files with 72 additions and 77 deletions

View File

@@ -79,7 +79,7 @@ impl<'gc> Func<'gc> {
.borrow_mut(mc)
.get_or_insert_with(|| vm.compile_func(self.func))
.clone();
let ret = unsafe { compiled.call(env.as_ref() as *const VmEnv, mc as *const _) };
let ret = unsafe { compiled(env.as_ref() as *const VmEnv, mc as *const _) };
Ok(ret.into())
}
}

View File

@@ -7,19 +7,12 @@ use crate::env::VmEnv;
use super::Value;
#[derive(Clone, PartialEq)]
#[derive(Clone, PartialEq, Collect)]
#[collect(no_drop)]
pub struct List<'gc> {
data: Vec<Value<'gc>>,
}
unsafe impl<'gc> Collect<'gc> for List<'gc> {
fn trace<Tr: gc_arena::collect::Trace<'gc>>(&self, cc: &mut Tr) {
for v in self.data.iter() {
v.trace(cc);
}
}
}
impl<'gc> List<'gc> {
pub fn new() -> Self {
List {

View File

@@ -562,9 +562,9 @@ impl<'gc> Thunk<'gc> {
*self.thunk.borrow_mut(mc) = _Thunk::Value(value);
}
pub fn get_value(&self) -> Option<Value<'gc>> {
if let _Thunk::Value(val) = &*self.thunk.borrow() {
Some(val.clone())
pub fn get_value(&self) -> Option<&Value<'gc>> {
if let _Thunk::Value(val) = unsafe { &*self.thunk.as_ptr() } {
Some(val)
} else {
None
}