Struct ValidationStack

Source
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 to validate a block of type [] -> []

Source

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

Initialize a new ValidationStack to validate a block of type block_ty

Source

pub fn len(&self) -> usize

Source

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

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<()>

Mark the current control block as unreachable, removing all of the types pushed to the stack since the current control block was entered. pop operations from the stack will yield Ok(ValidationStackEntry::Bottom) if the stack height is the same as the height when this control block was entered.

Returns Ok(()) if called during validation of a control block. Returns Err(Error::ValidationCtrlStackEmpty) if no control block context is found in the control block stack.

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 pushed after the current control block is entered. May also return Ok(ValidationStackEntry::Bottom) if make_unspecified is called within the current control block.
  • Returns Err(_) otherwise.
Source

pub fn assert_pop_ref_type( &mut self, expected_ty: Option<RefType>, ) -> Result<()>

Attempt popping Valtype::RefType(expected_ty) from type stack.

§Returns
  • Returns Ok(()) if Valtype::RefType(expected_ty) unifies to the item returned by pop_valtype operation and Err(_) otherwise.
Source

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

Attempt popping expected_ty from type stack.

§Returns
  • Returns Ok(()) if expected_ty unifies to the item returned by pop_valtype operation and Err(_) otherwise.
Source

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

Source

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

Source

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

Assert that the types retrieved from the type stack by pop_valtype unify to expected_val_types, and after this operation the type stack would be the same as the first time the current control block is entered. This method will unify the types on the stack to the expected valtypes if unify_to_expected_types is set. Any occurence of an error may leave the stack in an invalid state.

§Returns
  • Ok(_), the tail of the stack unifies to the expected_val_types
  • Err(_) otherwise
Source

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

Assert that the types retrieved from the type stack by pop_valtype unify to expected_val_types. This method will unify the types on the stack to the expected valtypes if unify_to_expected_types is set. Any occurence of an error may leave the stack in an invalid state.

§Returns
  • Ok(_), the tail of the stack unifies to the expected_val_types
  • Err(_) otherwise
Source

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

Call assert_val_types_on_top for the label signature of the label_idxth outer control block (0 corresponds to the current control block). Label signature of all controi blocks are the output signature of the control blocks except for the Loop block. For Loop blocks, it is the input signature. This method will unify the types on the stack to the expected valtypes if unify_to_expected_types is set.

§Returns
  • Ok(_), the tail of the stack unifies to the label signature of the label_idxth outer control block
  • Err(_) otherwise
Source

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

Signal to this struct that a new control block is entered, and calls assert_val_types_on_top with the input signature of the new control block. This method will unify the types on the stack to the expected valtypes if unify_to_expected_types is set.

§Returns
  • Ok(_), the tail of the stack unifies to the input signature of the new control block
  • Err(_) otherwise
Source

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

Signal to this struct that the current control block is exited, and calls assert_val_types_on_top with the output signature of the new control block. This method will unify the types on the stack to the expected valtypes if unify_to_expected_types is set.

§Returns
  • Ok(_), the tail of the stack unifies to the output signature of the current control block
  • Err(_) otherwise
Source

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

Validate the SELECT instruction within the current control block. Returns OK(()) on success, Err(_) otherwise.

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

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

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.