ControlInstruction

ControlInstruction

sealed class ControlInstruction

Base class for all control Instruction implementations.

From the docs:

Structured control instructions can bind an optional symbolic label identifier. The same label identifier may optionally be repeated after the corresponding end and else pseudo instructions, to indicate the matching delimiters.


blockinstr(I) ::=
‘block’ I′:label(I) rt:resulttype (in:instr(I′))* ‘end’ id?
=> block rt in* end (if id? = ϵ ∨ id? = label)
‘loop’ I′:label(I) rt:resulttype (in:instr(I′))* ‘end’ id?
=> loop rt in* end (if id? = ϵ ∨ id? = label)
‘if’ I′:label(I) rt:resulttype (in^1:instr(I′))* (‘else’ id?^1 (in^2:instr(I')))? ‘end’ id?^2
=> if rt in^1 else in2 end (if id?^1 = ϵ ∨ id?^1 = label, id?^2 = ϵ ∨ id?^2 = label)

All other control instruction are represented verbatim.


plaininstr(I)  ::= ‘unreachable’                                   => unreachable
‘nop’                                           => nop
‘br’ l:labelidx(I)                              => br l
‘br_if’ l:labelidx(I)                           => br_if l
‘br_table' l:vec(labelidx(I)) l^N:labelidx(I)  => br_table l∗ l^N
‘return’                                        => return
‘call’ x:funcidx(I)                             => call x
‘call_indirect’ x,I′:typeuse(I)                 => call_indirect x (if I′={})

Note The side condition stating that the identifier context I′ must be empty in the rule for call_indirect enforces that no identifier can be bound in any param declaration appearing in the type annotation.

Extensions

validate

fun Instruction.validate(context: FunctionBody): FunctionBody

Validates the Instruction.

Receiver

Name Description
Instruction

Parameters

Name Description
context: FunctionBody

ReturnValue

Name Description
FunctionBody