pub struct RtObject { /* private fields */ }Expand description
The core runtime value representation.
RtObject uses a tagged encoding to store small values inline
(in the u64 itself) and reference heap-allocated objects for
larger values. This avoids allocation for common cases like
small naturals, booleans, and unit.
Implementations§
Source§impl RtObject
impl RtObject
Sourcepub fn float_bits(bits: u64) -> Self
pub fn float_bits(bits: u64) -> Self
Create a float from reduced-precision bits.
Source§impl RtObject
impl RtObject
Sourcepub fn from_raw_bits(bits: u64) -> Self
pub fn from_raw_bits(bits: u64) -> Self
Create from raw bits (used for deserialization).
Source§impl RtObject
impl RtObject
Sourcepub fn is_small_ctor(&self) -> bool
pub fn is_small_ctor(&self) -> bool
Check if this is a small constructor.
Sourcepub fn is_closure(&self) -> bool
pub fn is_closure(&self) -> bool
Check if this is a closure reference.
Sourcepub fn is_string_ref(&self) -> bool
pub fn is_string_ref(&self) -> bool
Check if this is a string reference.
Sourcepub fn is_array_ref(&self) -> bool
pub fn is_array_ref(&self) -> bool
Check if this is an array reference.
Sourcepub fn is_thunk_ref(&self) -> bool
pub fn is_thunk_ref(&self) -> bool
Check if this is a thunk reference.
Sourcepub fn is_io_action(&self) -> bool
pub fn is_io_action(&self) -> bool
Check if this is an IO action reference.
Sourcepub fn is_task_ref(&self) -> bool
pub fn is_task_ref(&self) -> bool
Check if this is a task reference.
Sourcepub fn is_external_ref(&self) -> bool
pub fn is_external_ref(&self) -> bool
Check if this is an external object reference.
Sourcepub fn as_small_nat(&self) -> Option<u64>
pub fn as_small_nat(&self) -> Option<u64>
Extract a small natural number.
Sourcepub fn as_small_ctor(&self) -> Option<u32>
pub fn as_small_ctor(&self) -> Option<u32>
Extract a small constructor index.
Sourcepub fn as_small_int(&self) -> Option<i64>
pub fn as_small_int(&self) -> Option<i64>
Extract a small signed integer.
Sourcepub fn as_float_bits(&self) -> Option<u64>
pub fn as_float_bits(&self) -> Option<u64>
Extract float bits.
Source§impl RtObject
impl RtObject
Sourcepub fn small_ctor(index: u32) -> Self
pub fn small_ctor(index: u32) -> Self
Create a small constructor tag.
For inductives with no fields and a small number of constructors, we can encode the constructor index inline.
Source§impl RtObject
impl RtObject
Sourcepub fn with_heap<R>(&self, f: impl FnOnce(&HeapObject) -> R) -> Option<R>
pub fn with_heap<R>(&self, f: impl FnOnce(&HeapObject) -> R) -> Option<R>
Access the heap object for this reference (if heap-allocated).
Sourcepub fn with_heap_mut<R>(
&self,
f: impl FnOnce(&mut HeapObject) -> R,
) -> Option<R>
pub fn with_heap_mut<R>( &self, f: impl FnOnce(&mut HeapObject) -> R, ) -> Option<R>
Access the heap object mutably.
Sourcepub fn constructor(ctor_index: u32, fields: Vec<RtObject>) -> Self
pub fn constructor(ctor_index: u32, fields: Vec<RtObject>) -> Self
Create a constructor object with fields.
Sourcepub fn named_constructor(
name: Name,
ctor_index: u32,
fields: Vec<RtObject>,
) -> Self
pub fn named_constructor( name: Name, ctor_index: u32, fields: Vec<RtObject>, ) -> Self
Create a named constructor object.
Sourcepub fn boxed_float(value: f64) -> Self
pub fn boxed_float(value: f64) -> Self
Create a boxed float.
Sourcepub fn byte_array(bytes: Vec<u8>) -> Self
pub fn byte_array(bytes: Vec<u8>) -> Self
Create a byte array.