ExpressionValidator

ExpressionValidator

class ExpressionValidator

Validator of Expression nodes.

From the docs:

Expressions expr are classified by result types of the form [t?].


instr* end

  • The instruction sequence instr* must be valid with type [] => [t?], for some optional value type t?.
  • Then the expression is valid with result type [t?].

Constant Expressions

  • In a constant expression instr* end all instructions in instr* must be constant.
  • A constant instruction instr must be:

    • either of the form t.const c,
    • or of the form global.get x, in which case C.globals\[x] must be a global type of the form const t.

Constructors

<init>

constructor(expectedResult: ValueType?, isConstant: Boolean)

Validator of Expression nodes.

From the docs:

Expressions expr are classified by result types of the form [t?].


instr* end

  • The instruction sequence instr* must be valid with type [] => [t?], for some optional value type t?.
  • Then the expression is valid with result type [t?].

Constant Expressions

  • In a constant expression instr* end all instructions in instr* must be constant.
  • A constant instruction instr must be:

    • either of the form t.const c,
    • or of the form global.get x, in which case C.globals\[x] must be a global type of the form const t.

Parameters

Name Description
expectedResult: ValueType?
isConstant: Boolean

Methods

visit

fun visit(node: Expression, context: FunctionBody): FunctionBody

Validates the given node, and if necessary: its children (recursively, using other ValidationVisitor instances).

Parameters

Name Description
node: Expression
context: FunctionBody

ReturnValue

Name Description
FunctionBody