Class OperationPlanner
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
operatorstringThe operator: one of the
Tokensunary operators.operandVBTypeThe declared type of the operand.
Returns
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
operatorstringThe operator: one of the
Tokensbinary operators.leftVBTypeThe declared type of the left operand.
rightVBTypeThe declared type of the right operand.
Returns
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
operatorstringThe operator: one of the
Tokensunary operators.operandVBTypeThe value type of the operand.
Returns
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
operatorstringThe operator: one of the
Tokensbinary operators.leftVBTypeThe value type of the left operand: the type of what a Variant operand holds.
rightVBTypeThe value type of the right operand.
Returns
Exceptions
- NotSupportedException
The operator has no table of effective types: it is a conversion.