Add generic logical guards and atomic storage publication

This commit is contained in:
2026-10-22 22:24:28 +01:00
parent f7d7c16753
commit d9b9eeb171
17 changed files with 749 additions and 4 deletions
@@ -87,3 +87,39 @@ mod tests {
assert_eq!(h.max_ns, 99);
}
}
/// Non-owning storage observations for engineering qualification. These values
/// never retain a guest object or a native string owner and cannot write storage.
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum StorageValue {
Null,
Int32(i32),
Int64(i64),
FloatBits(u64),
Boolean(bool),
Reference(prometeu_bytecode::HeapRef),
StringIdentity { address: usize, bytes: usize },
}
impl StorageValue {
pub(crate) fn observe(value: &prometeu_bytecode::Value) -> Self {
use prometeu_bytecode::Value;
match value {
Value::Null => Self::Null,
Value::Int32(n) => Self::Int32(*n),
Value::Int64(n) => Self::Int64(*n),
Value::Float(n) => Self::FloatBits(n.to_bits()),
Value::Boolean(n) => Self::Boolean(*n),
Value::HeapRef(r) => Self::Reference(*r),
Value::String(s) => Self::StringIdentity {
address: std::sync::Arc::as_ptr(s) as *const () as usize,
bytes: s.len(),
},
}
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct StorageObject {
pub reference: prometeu_bytecode::HeapRef,
pub type_id: prometeu_bytecode::registry::TypeId,
pub groups: Vec<Vec<StorageValue>>,
}