feat(vm): add reference identity and deterministic value hashing

This commit is contained in:
2026-10-23 14:29:00 +01:00
parent 57992cf214
commit 69ad1931de
41 changed files with 2521 additions and 121 deletions
@@ -221,6 +221,24 @@ pub(crate) fn unpack_dynamic(
// All reference operations validate complete source values before querying the
// underlying concrete object. Invalid handles/pairs never become false or null.
pub(crate) fn identity_reference(
registry: &Registry,
heap: &Heap,
source: TypeId,
values: &[Value],
) -> Result<Option<HeapRef>, ValueError> {
let kind = registry.declarations().types.get(source.0 as usize).ok_or(ValueError::Type)?;
if !kind.kind.is_identity_reference() {
return Err(ValueError::Type);
}
validate(registry, heap, source, values)?;
match values.first() {
Some(Value::Null) => Ok(None),
Some(Value::HeapRef(reference)) => Ok(Some(*reference)),
_ => Err(ValueError::Type),
}
}
fn reference(
registry: &Registry,
heap: &Heap,