Kwasm.validation
package kwasm.validation
Classes
Name | Description |
---|---|
sealed class ValidationContext
|
Represents the context accrued throughout the validation process. ValidationContext objects contain the current AstNode being validated, as well as additional context as specified in the WebAssembly Spec. From the docs: Validity of an individual definition is specified relative to a context, which collects relevant information about the surrounding module and the definitions in scope:
In other words, a context contains a sequence of suitable types for each index space, describing each defined entry in that space. Locals, labels and return type are only used for validating instructions in function bodies, and are left empty elsewhere. The label stack is the only part of the context that changes as validation of an instruction sequence proceeds. |
data class ValidationException
|
Exception thrown during the validation process when an invalid WasmProgram is being analyzed. |
interface ValidationVisitor
|
Base visitor interface used during validation. T is the class of AstNode this ValidationVisitor is capable of validating, Context is the required ValidationContext type needed to perform validation. |
interface ModuleValidationVisitor
|
Describes a ValidationVisitor intended for validating module-level AstNodes. (e.g. kwasm.ast.Table, kwasm.ast.Memory, or kwasm.ast.WasmFunction). |
interface FunctionBodyValidationVisitor
|
Describes a ValidationVisitor intended for validating parts of the body of a kwasm.ast.WasmFunction or an kwasm.ast.Expression. |
Subpackages
Name | Description |
---|---|
package kwasm.validation.instruction
|
|
package kwasm.validation.module
|
|
package kwasm.validation.type
|
Methods
ValidationContext
fun ValidationContext(module: WasmModule): Module
Parameters
Name | Description |
---|---|
module: WasmModule
|
ReturnValue
Name | Description |
---|---|
Module
|
validate
fun validate(condition: Boolean, parseContext: ParseContext?, message: String)
Validates a given condition, and throws a ValidationException if the condition is false
.
Parameters
Name | Description |
---|---|
condition: Boolean
|
|
parseContext: ParseContext?
|
|
message: String
|
ReturnValue
Name | Description |
---|---|
Unit
|
validate
inline fun validate(condition: Boolean, parseContext: ParseContext?, crossinline block: ()->String)
Validates a given condition, and throws a ValidationException if the condition is false
.
Parameters
Name | Description |
---|---|
condition: Boolean
|
|
parseContext: ParseContext?
|
|
crossinline block: ()->String
|
ReturnValue
Name | Description |
---|---|
Unit
|
validateNotNull
fun <T> validateNotNull(value: T?, parseContext: ParseContext?, message: String): T
Validates that the given value is non-null and returns a non-nullable reference to it.
Parameters
Name | Description |
---|---|
value: T?
|
|
parseContext: ParseContext?
|
|
message: String
|
ReturnValue
Name | Description |
---|---|
T
|
validateNotNull
inline fun <T> validateNotNull(value: T?, parseContext: ParseContext?, crossinline block: ()->String): T
Validates that the given value is non-null and returns a non-nullable reference to it.
Parameters
Name | Description |
---|---|
value: T?
|
|
parseContext: ParseContext?
|
|
crossinline block: ()->String
|
ReturnValue
Name | Description |
---|---|
T
|
upcastThrown
inline fun <T> upcastThrown(context: ParseContext?, crossinline block: ()->T): T
Upcasts any Throwables thrown by the block to ValidationExceptions.
Parameters
Name | Description |
---|---|
context: ParseContext?
|
|
crossinline block: ()->T
|
ReturnValue
Name | Description |
---|---|
T
|
Given a WasmModule, creates a new ValidationContext.