Skip to main content

Arena

Struct Arena 

Source
pub struct Arena<T: ArenaTypes> {
    pub type_names: Vec<String>,
    pub type_field_names: Vec<Vec<String>>,
    pub type_variant_names: Vec<Vec<String>>,
    pub type_variant_ctor_ids: Vec<Vec<u32>>,
    pub ctor_to_type_variant: Vec<(u32, u16)>,
    pub symbol_entries: Vec<ArenaSymbol<T>>,
    pub type_aliases: Vec<(String, u32)>,
    /* private fields */
}

Fields§

§type_names: Vec<String>§type_field_names: Vec<Vec<String>>§type_variant_names: Vec<Vec<String>>§type_variant_ctor_ids: Vec<Vec<u32>>§ctor_to_type_variant: Vec<(u32, u16)>§symbol_entries: Vec<ArenaSymbol<T>>§type_aliases: Vec<(String, u32)>

Qualified-name aliases for types (e.g. “Data.Shape” → type_id for “Shape”).

Implementations§

Source§

impl<T: ArenaTypes> Arena<T>

Source

pub fn new() -> Self

Source

pub fn clone_static(&self) -> Self

Create a fresh Arena with only the static context (symbols, type metadata, stable constants) from this Arena. Dynamic runtime entries are empty. Used for independent product threads: each gets a clean Arena with just the compile-time context needed to execute functions and builtins.

Source

pub fn deep_import(&mut self, value: NanValue, source: &Arena<T>) -> NanValue

Deep-import a NanValue from source arena into self. Inline values (int, float, bool, unit, none, empty containers) are returned as-is. Heap-referenced values are recursively copied into self with new indices.

Source

pub fn push(&mut self, entry: ArenaEntry<T>) -> u32

Source

pub fn push_symbol(&mut self, symbol: ArenaSymbol<T>) -> u32

Source

pub fn get(&self, index: u32) -> &ArenaEntry<T>

Source

pub fn get_mut(&mut self, index: u32) -> &mut ArenaEntry<T>

Source

pub fn is_stable_index(index: u32) -> bool

Source

pub fn is_yard_index_in_region(&self, index: u32, mark: u32) -> bool

Source

pub fn is_handoff_index_in_region(&self, index: u32, mark: u32) -> bool

Source

pub fn is_young_index_in_region(&self, index: u32, mark: u32) -> bool

Source

pub fn young_len(&self) -> usize

Source

pub fn yard_len(&self) -> usize

Source

pub fn handoff_len(&self) -> usize

Source

pub fn stable_len(&self) -> usize

Source

pub fn usage(&self) -> ArenaUsage

Source

pub fn peak_usage(&self) -> ArenaUsage

Source

pub fn is_frame_local_index( &self, index: u32, arena_mark: u32, yard_mark: u32, handoff_mark: u32, ) -> bool

Source

pub fn with_alloc_space<R>( &mut self, space: AllocSpace, f: impl FnOnce(&mut Arena<T>) -> R, ) -> R

Source

pub fn push_inheriting_source_space( &mut self, entry: ArenaEntry<T>, source: NanValue, ) -> u32

Push an entry, inheriting the allocation space from a source value. If the source lives in yard or handoff, the result is placed there too, avoiding a pointless young→yard/handoff promotion later.

Source

pub fn push_i64(&mut self, val: i64) -> u32

Source

pub fn push_string(&mut self, s: &str) -> u32

Source

pub fn push_boxed(&mut self, val: NanValue) -> u32

Source

pub fn push_record(&mut self, type_id: u32, fields: Vec<NanValue>) -> u32

Source

pub fn push_variant( &mut self, type_id: u32, variant_id: u16, fields: Vec<NanValue>, ) -> u32

Source

pub fn push_list(&mut self, items: Vec<NanValue>) -> u32

Source

pub fn push_map(&mut self, map: T::Map) -> u32

Source

pub fn push_tuple(&mut self, items: Vec<NanValue>) -> u32

Source

pub fn push_vector(&mut self, items: Vec<NanValue>) -> u32

Source

pub fn push_fn(&mut self, f: Rc<T::Fn>) -> u32

Source

pub fn push_builtin(&mut self, name: &str) -> u32

Source

pub fn push_nullary_variant_symbol(&mut self, ctor_id: u32) -> u32

Source

pub fn get_i64(&self, index: u32) -> i64

Source

pub fn get_string(&self, index: u32) -> &str

Source

pub fn get_string_value(&self, value: NanValue) -> NanString<'_>

Source

pub fn get_boxed(&self, index: u32) -> NanValue

Source

pub fn get_record(&self, index: u32) -> (u32, &[NanValue])

Source

pub fn get_variant(&self, index: u32) -> (u32, u16, &[NanValue])

Source

pub fn get_list(&self, index: u32) -> &ArenaList

Source

pub fn get_tuple(&self, index: u32) -> &[NanValue]

Source

pub fn get_vector(&self, index: u32) -> &[NanValue]

Source

pub fn get_vector_mut(&mut self, index: u32) -> &mut Vec<NanValue>

Source

pub fn vector_ref_value(&self, value: NanValue) -> &[NanValue]

Source

pub fn clone_vector_value(&self, value: NanValue) -> Vec<NanValue>

Source

pub fn take_vector_value(&mut self, value: NanValue) -> Vec<NanValue>

Take ownership of a vector, replacing the arena slot with an empty vec.

Source

pub fn get_map(&self, index: u32) -> &T::Map

Source

pub fn get_map_mut(&mut self, index: u32) -> &mut T::Map

Source

pub fn map_ref_value(&self, map: NanValue) -> &T::Map

Source

pub fn clone_map_value(&self, map: NanValue) -> T::Map

Source

pub fn take_map_value(&mut self, map: NanValue) -> T::Map

Take ownership of a map value, replacing it with an empty map in the arena. Use when the caller is the sole owner (reuse analysis says owned = true). Avoids the O(n) clone — the original slot becomes empty.

Source

pub fn get_fn(&self, index: u32) -> &T::Fn

Source

pub fn get_fn_rc(&self, index: u32) -> &Rc<T::Fn>

Source

pub fn get_builtin(&self, index: u32) -> &str

Source

pub fn get_namespace(&self, index: u32) -> (&str, &[(Rc<str>, NanValue)])

Source

pub fn get_nullary_variant_ctor(&self, index: u32) -> u32

Source

pub fn register_record_type( &mut self, name: &str, field_names: Vec<String>, ) -> u32

Source

pub fn register_sum_type( &mut self, name: &str, variant_names: Vec<String>, ) -> u32

Source

pub fn register_variant_name( &mut self, type_id: u32, variant_name: String, ) -> u16

Source

pub fn get_type_name(&self, type_id: u32) -> &str

Source

pub fn type_count(&self) -> u32

Source

pub fn get_field_names(&self, type_id: u32) -> &[String]

Source

pub fn get_variant_name(&self, type_id: u32, variant_id: u16) -> &str

Source

pub fn register_type_alias(&mut self, alias: &str, type_id: u32)

Source

pub fn find_type_id(&self, name: &str) -> Option<u32>

Source

pub fn find_variant_id(&self, type_id: u32, variant_name: &str) -> Option<u16>

Source

pub fn find_ctor_id(&self, type_id: u32, variant_id: u16) -> Option<u32>

Source

pub fn get_ctor_parts(&self, ctor_id: u32) -> (u32, u16)

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source§

impl<T: ArenaTypes> Arena<T>

Source

pub fn push_list_prepend(&mut self, head: NanValue, tail: NanValue) -> u32

Source

pub fn push_list_append(&mut self, list: NanValue, value: NanValue) -> u32

Source

pub fn push_list_concat(&mut self, left: NanValue, right: NanValue) -> u32

Source

pub fn list_len_value(&self, list: NanValue) -> usize

Source

pub fn list_is_empty_value(&self, list: NanValue) -> bool

Source

pub fn list_get_value( &self, list: NanValue, position: usize, ) -> Option<NanValue>

Source

pub fn list_to_vec_value(&self, list: NanValue) -> Vec<NanValue>

Source

pub fn list_len(&self, index: u32) -> usize

Source

pub fn list_is_empty(&self, index: u32) -> bool

Source

pub fn list_get(&self, index: u32, position: usize) -> Option<NanValue>

Source

pub fn list_to_vec(&self, index: u32) -> Vec<NanValue>

Source

pub fn list_uncons(&mut self, list: NanValue) -> Option<(NanValue, NanValue)>

Source§

impl<T: ArenaTypes> Arena<T>

Source

pub fn truncate_to(&mut self, mark: u32)

Source

pub fn collect_young_from_roots(&mut self, mark: u32, roots: &mut [NanValue])

Source

pub fn truncate_yard_to(&mut self, mark: u32)

Source

pub fn truncate_handoff_to(&mut self, mark: u32)

Source

pub fn evacuate_frame_to_yard( &mut self, young_mark: u32, yard_mark: u32, handoff_mark: u32, roots: &mut [NanValue], ) -> (bool, bool)

Source

pub fn evacuate_frame_to_handoff( &mut self, young_mark: u32, yard_mark: u32, handoff_mark: u32, roots: &mut [NanValue], ) -> (bool, bool)

Source

pub fn flatten_deep_list(&mut self, value: NanValue) -> NanValue

Flatten a deep list (Prepend/Concat chain) into a single Flat entry.

Source

pub fn promote_young_roots_to_yard(&mut self, mark: u32, roots: &mut [NanValue])

Source

pub fn promote_young_roots_to_handoff( &mut self, mark: u32, roots: &mut [NanValue], )

Source

pub fn promote_roots_to_stable(&mut self, roots: &mut [NanValue])

Source

pub fn collect_yard_from_roots(&mut self, mark: u32, roots: &mut [NanValue])

Source

pub fn collect_stable_from_roots(&mut self, roots: &mut [NanValue])

Trait Implementations§

Source§

impl<T: Clone + ArenaTypes> Clone for Arena<T>

Source§

fn clone(&self) -> Arena<T>

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<T: Debug + ArenaTypes> Debug for Arena<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: ArenaTypes> Default for Arena<T>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<T> Freeze for Arena<T>

§

impl<T> RefUnwindSafe for Arena<T>

§

impl<T> Send for Arena<T>
where <T as ArenaTypes>::Map: Send, <T as ArenaTypes>::Fn: Sync + Send,

§

impl<T> Sync for Arena<T>
where <T as ArenaTypes>::Map: Sync, <T as ArenaTypes>::Fn: Sync + Send,

§

impl<T> Unpin for Arena<T>
where <T as ArenaTypes>::Map: Unpin,

§

impl<T> UnsafeUnpin for Arena<T>

§

impl<T> UnwindSafe for Arena<T>

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.