StackTracker

Struct StackTracker 

Source
pub struct StackTracker<'a> {
    pub parent: Option<Box<StackTracker<'a>>>,
    pub local_stack: Vec<VarAssignment>,
    /* private fields */
}
Expand description

Tracks the stack of assignments.

Fields§

§parent: Option<Box<StackTracker<'a>>>

Stack from the parent.

§local_stack: Vec<VarAssignment>

Variables assigned in the local space.

Implementations§

Source§

impl<'a> StackTracker<'a>

Source

pub fn new_root(assigner: &'a VarAssigner) -> Self

Create a new root StackTracker.

Source

pub fn make_child(&self) -> Self

Create a stack tracker with a clone of this one as its parent.

Source

pub fn root_with_stack( assigner: &'a VarAssigner, initial_stack: Vec<VarAssignment>, ) -> Self

Create a new root variable assigner with the specified initial stack.

Source

pub fn pop(&mut self, val: ValType) -> (VarAssignment, Vec<Conversion>)

Remove a value of the specified type from this stack, returning both the variable assignment corresponding to the value as well as any conversions required to get the value, in the order they must be performed. Any excess bytes that had to be popped from the parent’s stack to get down to the correct type but aren’t used in this value are pushed to the local stack.

Source

pub fn push(&mut self, val: ValType) -> VarAssignment

Push a value onto the local stack, returning the variable that it will be assigned to.

Source

pub fn local_bytes(&self) -> usize

Get the number of bytes in the local portion of the stack.

Source

pub fn total_bytes(&self) -> usize

Get the total number of bytes in the stack including the local stack and the parent’s stack.

Source

pub fn snapshot(&self) -> Vec<VarAssignment>

Get a snapshot of the cumulative stack at this layer + all parents.

Trait Implementations§

Source§

impl<'a> Clone for StackTracker<'a>

Source§

fn clone(&self) -> StackTracker<'a>

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<'a> PartialEq for StackTracker<'a>

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · 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.

Auto Trait Implementations§

§

impl<'a> Freeze for StackTracker<'a>

§

impl<'a> RefUnwindSafe for StackTracker<'a>

§

impl<'a> Send for StackTracker<'a>

§

impl<'a> Sync for StackTracker<'a>

§

impl<'a> Unpin for StackTracker<'a>

§

impl<'a> UnwindSafe for StackTracker<'a>

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.