Table of Contents

Class OperationPlanner

Namespace
RDCore.SDK.Semantics.Plans
Assembly
RDCore.SDK.dll

Makes the OperationPlan of an operation from the types of its operands: the one table of the effective types of the operators, consulted when an operation is bound from declared types and when it is evaluated on values (IR lowering §3.2).

public static class OperationPlanner
Inheritance
OperationPlanner
Inherited Members

Remarks

A plan depends on nothing but the operator and the operand types, so each is made once and kept: the interpreter asks for the plan of every operation it evaluates, and an operation evaluated a million times is planned once. The plans last asked for are also kept by the identity of the operator and the types (RDCore.SDK.Semantics.Plans.RecentPlans<TPlan>), which is what an operation evaluated in a loop asks with every time.

Every operator of MS-VBAL §5.6.9 is planned here: the arithmetic operators and unary +, &, the relational operators, Like and Is, and the logical operators. What else evaluates as an operator - a let-assignment, a pair of parentheses - is a conversion, which has no table of effective types, and asking for its plan is a mistake (NotSupportedException).

A plan is made from the types of the operands, and two rules of the specification depend on more than that, so they are the evaluation's: a comparison of two operands declared Variant, one holding a number and the other a String, ranks the number below the String whatever their types make of it (§5.6.9.5); and a logical operation of Null and a number is Null or a number, depending on the number (§5.6.9.8).

The static semantics of the arithmetic, logical and concatenation operators consult this table. Those of the relational operators do not, and are not to: a comparison's declared type is Boolean, or Variant (§5.6.9.5), which says nothing of the effective type its operands are compared in. What the static semantics accept, this table does not reject for the same declared types - but where the specification itself makes a comparison of an Error and anything else statically valid and a type mismatch whenever it runs.

Methods

ForDeclared(string, VBType)

The plan of a unary operation on an operand of this declared type: IsDeferred when it is declared Variant or Object, and the plan of the value otherwise.

public static OperationPlan ForDeclared(string @operator, VBType operand)

Parameters

operator string

The operator: one of the Tokens unary operators.

operand VBType

The declared type of the operand.

Returns

OperationPlan

ForDeclared(string, VBType, VBType)

The plan of a binary operation on operands of these declared types: IsDeferred when either is declared Variant or Object, or is late-bound (VBUnknownType), whose value type is not known until the operation is evaluated, and the plan of the values otherwise.

public static OperationPlan ForDeclared(string @operator, VBType left, VBType right)

Parameters

operator string

The operator: one of the Tokens binary operators.

left VBType

The declared type of the left operand.

right VBType

The declared type of the right operand.

Returns

OperationPlan

Remarks

A fixed-length string holds a String, which is the value type it is planned as.

ForValue(string, VBType)

The plan of a unary operation on a value of this type: final, whatever the type is.

public static OperationPlan ForValue(string @operator, VBType operand)

Parameters

operator string

The operator: one of the Tokens unary operators.

operand VBType

The value type of the operand.

Returns

OperationPlan

Exceptions

NotSupportedException

The operator has no table of effective types: it is a conversion.

ForValues(string, VBType, VBType)

The plan of a binary operation on values of these types: final, whatever the types are.

public static OperationPlan ForValues(string @operator, VBType left, VBType right)

Parameters

operator string

The operator: one of the Tokens binary operators.

left VBType

The value type of the left operand: the type of what a Variant operand holds.

right VBType

The value type of the right operand.

Returns

OperationPlan

Exceptions

NotSupportedException

The operator has no table of effective types: it is a conversion.