pub enum HeapObject {
Int(i64),
Array(Vec<Value>),
Tuple(Vec<Value>),
Str(String),
Struct {
type_name: String,
fields: Vec<Value>,
},
EnumVariant {
type_name: String,
variant: String,
payload: Vec<Value>,
},
FileHandle {
path: String,
content: String,
closed: bool,
},
}Expand description
a value living on the VM heap, reached through a TAG_PTR Value.
every variant a MAKE_* opcode builds, plus HeapObject::Int – because
i64 is uniformly heap-boxed (the codec in value.rs has no integer tag).
a HeapObject::FileHandle that is freed while still open is a resource
leak the VM logs.
derives Clone, PartialEq but NOT Debug – a variant carries Value,
and Value’s locked derive list (the NaN-box newtype) omits Debug. tests
compare HeapObjects with == rather than assert_eq! for that reason.
Variants§
Int(i64)
a 64-bit signed integer. i64 has no NaN-box tag, so every integer
runtime value is one of these, reached through a pointer.
Array(Vec<Value>)
a dynamic array of values, built by MAKE_ARRAY. push / pop mutate
it; INDEX reads an element; LEN reports the element count.
Tuple(Vec<Value>)
a fixed-shape tuple of values, built by MAKE_TUPLE. distinct from
HeapObject::Array so the stdlib’s type_of (plan 05-05) can render
a tuple’s structural type (i64, str) rather than an array type. INDEX
reads an element exactly as it does for an array.
Str(String)
an owned string, built by a CONST of a ConstValue::Str or by
CONCAT_N / TO_STR.
Struct
a struct instance: the declared type name (from Program.structs) plus
the field values in declaration order.
Fields
EnumVariant
an enum-variant instance: the enum name, the variant name, and the variant’s payload values (empty for a payload-less variant).
Fields
FileHandle
a mock file handle – open builds one, close marks it closed. the
VM does no real file I/O (it runs in a WASM sandbox); the handle backs
the effect system and defer close(f) demonstrations. a handle freed
while still open is a leak.
Trait Implementations§
Source§impl Clone for HeapObject
impl Clone for HeapObject
Source§fn clone(&self) -> HeapObject
fn clone(&self) -> HeapObject
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl PartialEq for HeapObject
impl PartialEq for HeapObject
Source§fn eq(&self, other: &HeapObject) -> bool
fn eq(&self, other: &HeapObject) -> bool
self and other values to be equal, and is used by ==.