InstructionSequenceValidator
class InstructionSequenceValidator
Constructors
<init>
constructor(requiredEndStack: List<ValueType>?, strictEndStackMatchRequired: Boolean)
Validator of sequences of Instruction nodes.
From
the docs:Typing of instruction sequences is defined recursively.
Empty Instruction Sequence: ϵ
- The empty instruction sequence is valid with type
[t*] => [t*]
, for any sequence of value typest*
.
Non-empty Instruction Sequence: instr* instrN
- The instruction sequence
instr*
must be valid with type[t*^1] => [t*2]
, for some sequences of value typest*^1
andt*^2
. - The instruction
instrN
must be valid with type[t*] => [t*^3]
, for some sequences of value typest*
andt*^3
. - There must be a sequence of value types
t*^0
, such thatt*^2 = t*^0 t*
. - Then the combined instruction sequence is valid with type
[t*^1] => [t*^0 t*^3]
.
Parameters
Name | Description |
---|---|
requiredEndStack: List<ValueType>?
|
|
strictEndStackMatchRequired: Boolean
|
Methods
visit
fun visit(node: AstNodeList<Instruction>, context: FunctionBody): FunctionBody
Validates the given node, and if necessary: its children (recursively, using other ValidationVisitor instances).
Parameters
Name | Description |
---|---|
node: AstNodeList<Instruction>
|
|
context: FunctionBody
|
ReturnValue
Name | Description |
---|---|
FunctionBody
|
Validator of sequences of Instruction nodes.
From
the docs:Typing of instruction sequences is defined recursively.
Empty Instruction Sequence:
ϵ
[t*] => [t*]
, for any sequence of value typest*
.Non-empty Instruction Sequence:
instr* instrN
instr*
must be valid with type[t*^1] => [t*2]
, for some sequences of value typest*^1
andt*^2
.instrN
must be valid with type[t*] => [t*^3]
, for some sequences of value typest*
andt*^3
.t*^0
, such thatt*^2 = t*^0 t*
.[t*^1] => [t*^0 t*^3]
.