Struct brane_exe::frame_stack::FrameStack

source ·
pub struct FrameStack { /* private fields */ }
Expand description

Implements a FrameStack, which is used to keep track of function calls and their expected return types.

Implementations§

source§

impl FrameStack

source

pub fn new(size: usize, table: Arc<SymTable>) -> Self

Constructor for the FrameStack, which initializes it with the given size.

§Arguments
  • size: The size of the FrameStack.
  • table: The global scope to start with what (and what variables are) is in scope.
§Returns

A new FrameStack instance.

source

pub fn fork(&self) -> Self

Forks the framestack, which copies the existing variables in-scope into a single frame that is the new main.

§Returns

A new FrameStack instance that can be used in a forked thread.

source

pub fn update_table(&mut self, table: Arc<SymTable>)

Updates the internal table to be the same as the given one.

This is useful if the workflow is updating its own states.

§Arguments
  • table: The new table to use as ground truth.
§Returns

Nothing, but does update the internal table.

source

pub fn push(&mut self, def: usize, ret: ProgramCounter) -> Result<(), Error>

Pushes a new Frame onto the FrameStack.

§Arguments
  • def: The function to create a new frame for.
  • ret: The return address (pair) to return to.
§Returns

Nothing, but does set it internally.

§Errors

This function may error if the FrameStack overflows.

source

pub fn pop(&mut self) -> Result<(ProgramCounter, DataType), Error>

Pops the top value off of the FrameStack, returning the expected data type and return address.

§Returns

A ProgramCounter denoting the return address and expected return type, respectively. If the main was popped, however, then the return address is (usize::MAX, usize::MAX).

§Errors

This function may error if there was nothing left on the stack.

source

pub fn declare(&mut self, def: usize) -> Result<(), Error>

Declares a variable with the given index.

§Arguments
  • def: The variable to declare.
§Returns

Nothing, but does allow the variable to have a value from this point onwards.

§Errors

This function may error if the given definition is unknown.

source

pub fn undeclare(&mut self, def: usize) -> Result<(), Error>

Undclares a variable with the given index, effectively brining it back to uninitialized status.

§Arguments
  • def: The variable to undeclare.
§Returns

Nothing, but does require the variable to be declared before it can be used.

§Errors

This function may error if the given definition is unknown.

source

pub fn set(&mut self, def: usize, value: Value) -> Result<(), Error>

Sets the variable with the given index to the given Value.

§Arguments
  • def: The variable to set.
  • value: The new Value to set it to.
§Returns

Nothing, but does update the given variable’s value.

§Errors

This function may error if there was nothing left on the stack or if the given variable was not declared.

source

pub fn get(&self, def: usize) -> Result<&Value, Error>

Gets the value of the variable with the given index.

§Arguments
  • def: The variable to get.
§Returns

The current value of the variable.

§Errors

This function may error if there was nothing left on the stack or if the given variable was not declared.

source

pub fn capacity(&self) -> usize

Returns the total capacity of the FrameStack. Using any more than this will result in overflows.

source

pub fn is_empty(&self) -> bool

Returns if the framestack is currently empty.

source

pub fn len(&self) -> usize

Returns the number of frames currently on the FrameStack.

source

pub fn table(&self) -> &SymTable

Returns the internal table.

Trait Implementations§

source§

impl Clone for FrameStack

source§

fn clone(&self) -> FrameStack

Returns a copy 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 Debug for FrameStack

source§

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

Formats the value using the given formatter. 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> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> FromRef<T> for T
where T: Clone,

source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoRequest<T> for T

source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
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.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<T> ErasedDestructor for T
where T: 'static,

source§

impl<T> MaybeSendSync for T