feat(registry): checkpoint PLN-0176 foundations and validated partial integrations
This commit is contained in:
@@ -7,9 +7,13 @@ pub trait RootVisitor {
|
||||
}
|
||||
|
||||
/// Helper: if `val` is a `Value::HeapRef`, call the visitor.
|
||||
pub(crate) fn value_heap_ref(value: &Value) -> Option<HeapRef> {
|
||||
if let Value::HeapRef(r) = value { Some(*r) } else { None }
|
||||
}
|
||||
|
||||
pub fn visit_value_for_roots<V: RootVisitor + ?Sized>(val: &Value, visitor: &mut V) {
|
||||
if let Value::HeapRef(r) = val {
|
||||
visitor.visit_heap_ref(*r);
|
||||
if let Some(r) = value_heap_ref(val) {
|
||||
visitor.visit_heap_ref(r);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,11 +35,11 @@ mod tests {
|
||||
fn visits_heapref_on_operand_stack() {
|
||||
let mut vm = VirtualMachine::default();
|
||||
// Place a HeapRef on the operand stack
|
||||
vm.push_operand_for_test(Value::HeapRef(HeapRef(123)));
|
||||
vm.push_operand_for_test(Value::HeapRef(HeapRef { index: 123, generation: 1 }));
|
||||
|
||||
let mut v = CollectVisitor { seen: vec![] };
|
||||
vm.visit_roots(&mut v);
|
||||
|
||||
assert_eq!(v.seen, vec![HeapRef(123)]);
|
||||
assert_eq!(v.seen, vec![HeapRef { index: 123, generation: 1 }]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user