pub(super) struct ValidationStack {
    stack: Vec<ValidationStackEntry>,
}

Fields§

§stack: Vec<ValidationStackEntry>

Implementations§

source§

impl ValidationStack

source

pub(super) fn new() -> Self

Initialize a new ValidationStack

source

pub(super) fn len(&self) -> usize

source

pub(super) fn push_valtype(&mut self, valtype: ValType)

source

pub(super) fn push_label(&mut self, label_info: LabelInfo)

source

pub(super) fn drop_val(&mut self) -> Result<()>

Similar to ValidationStack::pop, because it pops a value from the stack, but more public and doesn’t actually return the popped value.

source

pub(super) fn make_unspecified(&mut self)

This puts an unspecified element on top of the stack. While the top of the stack is unspecified, arbitrary value types can be popped. To undo this, a new label has to be pushed or an existing one has to be popped.

See the documentation for ValidationStackEntry::UnspecifiedValTypes for more info.

source

fn pop(&mut self) -> Result<ValidationStackEntry>

Pop a ValidationStackEntry from the ValidationStack

§Returns
  • Returns Ok(_) with the former top-most ValidationStackEntry inside, if the stack had at least one element.
  • Returns Err(_) if the stack was already empty.
source

pub(super) fn assert_pop_val_type(&mut self, expected_ty: ValType) -> Result<()>

Assert the top-most ValidationStackEntry is a specific ValType, after popping it from the ValidationStack

§Returns
source

pub(super) fn assert_val_types_on_top( &self, expected_val_types: &[ValType] ) -> Result<()>

Asserts that the values on top of the stack match those of a value iterator

The last element of expected_val_types is compared to the top-most ValidationStackEntry, the second last expected_val_types element to the second top-most ValidationStackEntry etc.

Any occurence of the ValidationStackEntry::Label variant in the stack tail will cause an error. This method does not mutate the ValidationStack::stack in any way.

§Returns
  • Ok(_), the tail of the stack matches the expected_val_types
  • Err(_) otherwise
source

pub(super) fn assert_val_types( &self, expected_val_types: &[ValType] ) -> Result<()>

Asserts that the valtypes on the stack match the expected valtypes.

This starts by comparing the top-most valtype with the last element from expected_val_types and then continues downwards on the stack. If a label is reached and not all expected_val_types have been checked, the assertion fails.

§Returns
  • Ok(()) if all expected valtypes were found
  • Err(_) otherwise
source

fn find_topmost_label_idx(&self) -> Option<usize>

A helper to find the index of the top-most label in ValidationStack::stack

source

fn pop_label_and_above(&mut self) -> Option<LabelInfo>

Searches for the top-most label, then pops the label and all entry on top of that label. Only the label’s LabelInfo is returned.

§Returns
  • Ok(LabelInfo) if a label has been found and popped
  • None if no label was found on the stack
source

pub(super) fn has_remaining_label(&self) -> bool

Return true if the stack has at least one remaining label

Trait Implementations§

source§

impl Debug for ValidationStack

source§

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

Formats the value using the given formatter. Read more
source§

impl PartialEq for ValidationStack

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Eq for ValidationStack

source§

impl StructuralPartialEq for ValidationStack

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, U> TryFrom<U> for T
where U: Into<T>,

§

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

§

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.