kwasm.validation.instruction.control

Kwasm.validation.instruction.control

package kwasm.validation.instruction.control

Classes

Name Description
object BlockValidator

Validator of kwasm.ast.instruction.BlockInstruction nodes.

For specific validation requirements, see the docs for the validate extension functions on ControlInstruction.Block, ControlInstruction.Loop, and ControlInstruction.If.

object ControlInstructionValidator

Validator of ControlInstruction nodes.

See: PlainValidator and BlockValidator for more information.

object PlainValidator

Validator of "plain" (non-kwasm.ast.instruction.BlockInstruction) ControlInstruction nodes.

From the docs:


nop
  • The instruction is valid with type [] => [].

unreachable

  • The instruction is valid with type [t*1] => [t*2], for any sequences of value types t*1 and t*2.

For the other types, see the validate extension functions on ControlInstruction.Break, ControlInstruction.BreakIf, ControlInstruction.BreakTable, ControlInstruction.Return, ControlInstruction.Call, and ControlInstruction.CallIndirect.

Methods

validateBlock

fun Block.validateBlock(context: FunctionBody): FunctionBody

From the docs:


block [t?] instr* end

  • Let C′ be the same context as C, but with the result type [t?] prepended to the labels vector.
  • Under context C′, the instruction sequence instr* must be valid with type [] => [t?].
  • Then the compound instruction is valid with type [] => [t?].

Receiver

Name Description
Block

Parameters

Name Description
context: FunctionBody

ReturnValue

Name Description
FunctionBody

validateLoop

fun Loop.validateLoop(context: FunctionBody): FunctionBody

From the docs:


block [t?] instr* end

  • Let C′ be the same context as C, but with the result type [t?] prepended to the labels vector.
  • Under context C′, the instruction sequence instr* must be valid with type [] => [t?].
  • Then the compound instruction is valid with type [] => [t?].

Receiver

Name Description
Loop

Parameters

Name Description
context: FunctionBody

ReturnValue

Name Description
FunctionBody

validateIf

fun If.validateIf(context: FunctionBody): FunctionBody

From the docs:


if [t?] instr*^1 else instr*^2 end

  • Let C′ be the same context as C, but with the result type [t?] prepended to the labels vector.
  • Under context C′, the instruction sequence instr*^1 must be valid with type [] => [t?].
  • Under context C′, the instruction sequence instr*^2 must be valid with type [] => t?`.
  • Then the compound instruction is valid with type \[i32] => t?`.

Receiver

Name Description
If

Parameters

Name Description
context: FunctionBody

ReturnValue

Name Description
FunctionBody