Struct wasm::validation::validation_stack::ValidationStack
source · pub(super) struct ValidationStack {
stack: Vec<ValidationStackEntry>,
}
Fields§
§stack: Vec<ValidationStackEntry>
Implementations§
source§impl ValidationStack
impl ValidationStack
pub(super) fn len(&self) -> usize
pub(super) fn push_valtype(&mut self, valtype: ValType)
pub(super) fn push_label(&mut self, label_info: LabelInfo)
sourcepub(super) fn drop_val(&mut self) -> Result<()>
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.
sourcepub(super) fn make_unspecified(&mut self)
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.
sourcefn pop(&mut self) -> Result<ValidationStackEntry>
fn pop(&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.
sourcepub(super) fn assert_pop_val_type(&mut self, expected_ty: ValType) -> Result<()>
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
- Returns
Ok(())
if the top-mostValidationStackEntry
is aValType
identical toexpected_ty
. - Returns
Err(_)
otherwise.
sourcepub(super) fn assert_val_types_on_top(
&self,
expected_val_types: &[ValType]
) -> Result<()>
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 theexpected_val_types
Err(_)
otherwise
sourcepub(super) fn assert_val_types(
&self,
expected_val_types: &[ValType]
) -> Result<()>
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 foundErr(_)
otherwise
sourcefn find_topmost_label_idx(&self) -> Option<usize>
fn find_topmost_label_idx(&self) -> Option<usize>
A helper to find the index of the top-most label in ValidationStack::stack
sourcefn pop_label_and_above(&mut self) -> Option<LabelInfo>
fn pop_label_and_above(&mut self) -> Option<LabelInfo>
sourcepub(super) fn has_remaining_label(&self) -> bool
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
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 ==
.