Struct wasm::validation::validation_stack::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
impl ValidationStack
pub(super) fn new_for_func(block_ty: FuncType) -> Self
pub fn len(&self) -> usize
pub fn push_valtype(&mut self, valtype: ValType)
sourcepub fn peek_const_validation_stack(&self) -> Option<ValidationStackEntry>
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
sourcepub(super) fn drop_val(&mut self) -> Result<()>
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.
pub(super) fn make_unspecified(&mut self) -> Result<()>
sourcefn pop_valtype(&mut self) -> Result<ValidationStackEntry>
fn pop_valtype(&mut self) -> Result<ValidationStackEntry>
Pop a ValidationStackEntry
from the ValidationStack
§Returns
- Returns
Ok(_)
with the former top-mostValidationStackEntry
inside, if the stack had at least one element. - Returns
Err(_)
if the stack was already empty.
pub fn assert_pop_ref_type( &mut self, expected_ty: Option<RefType> ) -> Result<()>
sourcepub fn assert_pop_val_type(&mut self, expected_ty: ValType) -> Result<()>
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
- Returns
Ok(())
if the top-mostValidationStackEntry
is aValType
identical toexpected_ty
. - Returns
Err(_)
otherwise.
fn assert_val_types_on_top_with_custom_stacks( stack: &mut Vec<ValidationStackEntry>, ctrl_stack: &[CtrlStackEntry], expected_val_types: &[ValType] ) -> Result<()>
fn assert_val_types_with_custom_stacks( stack: &mut Vec<ValidationStackEntry>, ctrl_stack: &[CtrlStackEntry], expected_val_types: &[ValType] ) -> Result<()>
sourcepub(super) fn assert_val_types_on_top(
&mut self,
expected_val_types: &[ValType]
) -> Result<()>
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 theexpected_val_types
Err(_)
otherwise
sourcepub(super) fn assert_val_types(
&mut self,
expected_val_types: &[ValType]
) -> Result<()>
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 foundErr(_)
otherwise
pub fn assert_val_types_of_label_jump_types_on_top( &mut self, label_idx: usize ) -> Result<()>
pub fn assert_push_ctrl( &mut self, label_info: LabelInfo, block_ty: FuncType ) -> Result<()>
pub fn assert_pop_ctrl(&mut self) -> Result<(LabelInfo, FuncType)>
pub fn validate_polymorphic_select(&mut self) -> Result<()>
Trait Implementations§
source§impl Debug for ValidationStack
impl Debug for ValidationStack
source§impl PartialEq for ValidationStack
impl PartialEq for ValidationStack
source§fn eq(&self, other: &ValidationStack) -> bool
fn eq(&self, other: &ValidationStack) -> bool
self
and other
values to be equal, and is used
by ==
.