TaggedStack

Struct TaggedStack 

Source
#[repr(C)]
pub struct TaggedStack { pub base: *mut StackValue, pub sp: usize, pub capacity: usize, }
Expand description

Stack state for the tagged value stack

This struct is passed to/from runtime functions and represents the complete state of a strand’s value stack.

Uses 32-byte StackValue slots for FFI compatibility.

Fields§

§base: *mut StackValue

Pointer to the base of the stack array (array of StackValue)

§sp: usize

Current stack pointer (index into array, points to next free slot)

§capacity: usize

Total capacity of the stack (number of slots)

Implementations§

Source§

impl TaggedStack

Source

pub fn new(capacity: usize) -> Self

Create a new tagged stack with the given capacity

Source

pub fn with_default_capacity() -> Self

Create a new tagged stack with default capacity

Source

pub fn depth(&self) -> usize

Get the current stack depth

Source

pub fn is_empty(&self) -> bool

Check if the stack is empty

Source

pub fn has_capacity(&self, n: usize) -> bool

Check if the stack has room for n more values

Source

pub fn grow(&mut self, min_capacity: usize)

Grow the stack to accommodate more values

Doubles capacity by default, or grows to min_capacity if larger.

Source

pub fn push(&mut self, val: StackValue)

Push a StackValue onto the stack

Grows the stack if necessary.

Source

pub fn pop(&mut self) -> StackValue

Pop a StackValue from the stack

Panics if the stack is empty.

Source

pub fn peek(&self) -> StackValue

Peek at the top value without removing it

Panics if the stack is empty.

Source

pub fn sp_ptr(&self) -> *mut StackValue

Get a pointer to the current stack pointer position

This is used by generated code for inline stack operations. Returns pointer to next free StackValue slot.

Source

pub fn push_int(&mut self, val: i64)

Push an integer value using Value::Int layout slot0 = 0 (Int discriminant), slot1 = value

Source

pub fn pop_int(&mut self) -> i64

Pop and return an integer value

Panics if the top value is not an integer.

Source

pub fn clone_stack(&self) -> Self

Clone this stack (for spawn)

Creates a deep copy. For heap objects, properly clones them using the clone_stack_value function which handles each type correctly.

Trait Implementations§

Source§

impl Drop for TaggedStack

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

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> 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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. 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.