Skip to main content

HeapObject

Enum HeapObject 

Source
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

§type_name: String

the declared struct name, e.g. "Point" – what type_of returns.

§fields: Vec<Value>

the field values, in the struct’s declaration order.

§

EnumVariant

an enum-variant instance: the enum name, the variant name, and the variant’s payload values (empty for a payload-less variant).

Fields

§type_name: String

the enum’s declared name, e.g. "Shape".

§variant: String

the variant’s name, e.g. "Circle".

§payload: Vec<Value>

the variant’s payload values, in declaration order.

§

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.

Fields

§path: String

the path passed to open. purely informational in the mock.

§content: String

the mock file content; read_all returns this.

§closed: bool

true once close has run on this handle.

Trait Implementations§

Source§

impl Clone for HeapObject

Source§

fn clone(&self) -> HeapObject

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl PartialEq for HeapObject

Source§

fn eq(&self, other: &HeapObject) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for HeapObject

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more