692 B
692 B
Object/Memory/Heap Concepts for Deimos/DVM
use std::any::TypeId;
trait Trace {
fn grays(&self) -> &[GcAny];
}
struct Gc<T: Trace> {
inner: *mut GcInner<T>,
}
impl<T> Gc {
fn data(&self) -> &T {
&self.inner.data
}
}
struct GcMut<T: Trace> {
inner: *mut GcInner<T>,
}
struct GcInner<T: Trace> {
data: T,
gc_count: usize,
gc_mut_count: bool,
next: Option<GcAny>,
color: bool,
}
struct GcAny {
inner: *mut (), // like void* in C
v_table: *const GcAnyVTable,
type_id: *const TypeId,
}
enum Value {
Object(Gc<Object>),
Int(i32),
String(Gc<String>),
Null
}
struct Object {
class: *const Class,
}