pub struct FuncValidator<T> { /* private fields */ }
Expand description

Validation context for a WebAssembly function.

This is a finalized validator which is ready to process a FunctionBody. This is created from the FuncToValidate::into_validator method.

Implementations

Convenience function to validate an entire function’s body.

You may not end up using this in final implementations because you’ll often want to interleave validation with parsing.

Reads the local definitions from the given BinaryReader, often sourced from a FunctionBody.

This function will automatically advance the BinaryReader forward, leaving reading operators up to the caller afterwards.

Defines locals into this validator.

This should be used if the application is already reading local definitions and there’s no need to re-parse the function again.

Validates the next operator in a function.

This functions is expected to be called once-per-operator in a WebAssembly function. Each operator’s offset in the original binary and the operator itself are passed to this function to provide more useful error messages.

Function that must be called after the last opcode has been processed.

This will validate that the function was properly terminated with the end opcode. If this function is not called then the function will not be properly validated.

The offset provided to this function will be used as a position for an error if validation fails.

Returns the underlying module resources that this validator is using.

The index of the function within the module’s function index space that is being validated.

Returns the number of defined local variables in the function.

Returns the type of the local variable at the given index if any.

Get the current height of the operand stack.

This returns the height of the whole operand stack for this function, not just for the current control frame.

Returns the optional value type of the value operand at the given depth from the top of the operand stack.

  • Returns None if the depth is out of bounds.
  • Returns Some(None) if there is a value with unknown type at the given depth.
Note

A depth of 0 will refer to the last operand on the stack.

Returns the number of frames on the control flow stack.

This returns the height of the whole control stack for this function, not just for the current control frame.

Returns a shared reference to the control flow Frame of the control flow stack at the given depth if any.

Returns None if the depth is out of bounds.

Note

A depth of 0 will refer to the last frame on the stack.

Consumes this validator and returns the underlying allocations that were used during the validation process.

The returned value here can be paired with FuncToValidate::into_validator to reuse the allocations already created by this validator.

Trait Implementations

The result type of the visitor.
Visits the Operator op using the given offset. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.