Struct Stack

Source
pub struct Stack {
    pub frames: Vec<usize>,
    pub stack: Vec<Tagged>,
}
Expand description

A stack of Tagged Data. Note that in general the stack is expected to follow the following pattern:

FV...V...F V...T... ...

Or in other words, a frame followed by a block of n values that are locals followed by n temporaries, ad infinitum.

Fields§

§frames: Vec<usize>§stack: Vec<Tagged>

Implementations§

Source§

impl Stack

Source

pub fn init() -> Stack

Create a new Stack with a single frame.

Source

pub fn push_data(&mut self, data: Data)

Pushes some Data onto the Stack, tagging it along the way

Source

pub fn push_tagged(&mut self, tagged: Tagged)

Pushes some Tagged Data onto the Stack without unwrapping it.

Source

pub fn pop_data(&mut self) -> Data

Pops some Data of the Stack, panicking if what it pops is not Data. Note that this will never return a Heaped value, rather cloning the value inside.

Source

pub fn pop_frame(&mut self) -> Suspend

Pops a stack frame from the Stack, restoring the previous frame. Panics if there are no frames left on the stack.

Source

pub fn push_frame(&mut self, suspend: Suspend)

Pushes a new stack frame onto the Stack. Takes the old suspended closure / ip, and stores that on the stack.

Source

pub fn push_not_init(&mut self)

Shorcut for pushing a Tagged(Slot::NotInit) on top of the stack.

Source

pub fn declare(&mut self, decls: usize)

Shortcut for calling push_not_init N times.

Source

pub fn heapify(&mut self, index: usize)

Wraps the top data value on the stack in Data::Heaped, data must not already be on the heap

Source

pub fn unwind_frame(&mut self) -> bool

Truncates the stack to the last frame. Returns true if the stack can not be unwound further.

Source

pub fn local_slot(&mut self, index: usize) -> Slot

returns a copy of the Slot of a local variable on the stack.

Source

pub fn local_data(&mut self, index: usize) -> Data

Returns a copy of the Data stored in a local variable on the stack.

Source

pub fn set_local(&mut self, index: usize)

Sets a local - note that this function doesn’t do much. It’s a simple swap-and-drop. If a new local is being declared, it’s literally a bounds-check and no-op.

Trait Implementations§

Source§

impl Debug for Stack

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Stack

§

impl RefUnwindSafe for Stack

§

impl Send for Stack

§

impl Sync for Stack

§

impl Unpin for Stack

§

impl UnwindSafe for Stack

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, 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.