pub struct ValidationStack {
    stack: Vec<ValidationStackEntry>,
    pub ctrl_stack: Vec<CtrlStackEntry>,
}

Fields§

§stack: Vec<ValidationStackEntry>§ctrl_stack: Vec<CtrlStackEntry>

Implementations§

source§

impl ValidationStack

source

pub fn new() -> Self

Initialize a new ValidationStack

source

pub(super) fn new_for_func(block_ty: FuncType) -> Self

source

pub fn len(&self) -> usize

source

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

source

pub fn peek_const_validation_stack(&self) -> Option<ValidationStackEntry>

DANGER! only to be used within const validation! use within non-const validation may result in algorithmically incorrect validation

source

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

Similar to ValidationStack::pop_valtype, 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) -> Result<()>

source

fn pop_valtype(&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 fn assert_pop_ref_type( &mut self, expected_ty: Option<RefType> ) -> Result<()>

source

pub 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 This assertion will unify the the top-most entry with expected_ty.

§Returns
source

fn assert_val_types_on_top_with_custom_stacks( stack: &mut Vec<ValidationStackEntry>, ctrl_stack: &[CtrlStackEntry], expected_val_types: &[ValType] ) -> Result<()>

source

fn assert_val_types_with_custom_stacks( stack: &mut Vec<ValidationStackEntry>, ctrl_stack: &[CtrlStackEntry], expected_val_types: &[ValType] ) -> Result<()>

source

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

Asserts that the values on top of the stack match those of a value iterator This method will unify the types on the stack to the expected valtypes. The last element of expected_val_types is unified to the top-most ValidationStackEntry, the second last expected_val_types element to the second top-most ValidationStackEntry etc.

Any unification failure or arity mismatch will cause an error.

Any occurence of an error may leave the stack in an invalid state.

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

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

Asserts that the valtypes on the stack match the expected valtypes and no other type is on the stack. This method will unify the types on the stack to 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

pub fn assert_val_types_of_label_jump_types_on_top( &mut self, label_idx: usize ) -> Result<()>

source

pub fn assert_push_ctrl( &mut self, label_info: LabelInfo, block_ty: FuncType ) -> Result<()>

source

pub fn assert_pop_ctrl(&mut self) -> Result<(LabelInfo, FuncType)>

source

pub fn validate_polymorphic_select(&mut self) -> Result<()>

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.