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>
impl<'a> StackTracker<'a>
Sourcepub fn new_root(assigner: &'a VarAssigner) -> Self
pub fn new_root(assigner: &'a VarAssigner) -> Self
Create a new root StackTracker.
Sourcepub fn make_child(&self) -> Self
pub fn make_child(&self) -> Self
Create a stack tracker with a clone of this one as its parent.
Sourcepub fn root_with_stack(
assigner: &'a VarAssigner,
initial_stack: Vec<VarAssignment>,
) -> Self
pub fn root_with_stack( assigner: &'a VarAssigner, initial_stack: Vec<VarAssignment>, ) -> Self
Create a new root variable assigner with the specified initial stack.
Sourcepub fn pop(&mut self, val: ValType) -> (VarAssignment, Vec<Conversion>)
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.
Sourcepub fn push(&mut self, val: ValType) -> VarAssignment
pub fn push(&mut self, val: ValType) -> VarAssignment
Push a value onto the local stack, returning the variable that it will be assigned to.
Sourcepub fn local_bytes(&self) -> usize
pub fn local_bytes(&self) -> usize
Get the number of bytes in the local portion of the stack.
Sourcepub fn total_bytes(&self) -> usize
pub fn total_bytes(&self) -> usize
Get the total number of bytes in the stack including the local stack and the parent’s stack.
Sourcepub fn snapshot(&self) -> Vec<VarAssignment>
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>
impl<'a> Clone for StackTracker<'a>
Source§fn clone(&self) -> StackTracker<'a>
fn clone(&self) -> StackTracker<'a>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more