Class OperationPlan
What an operation does, decided from the types of its operands alone - before, and apart from, any value it is evaluated on (IR lowering §3.2).
public sealed record OperationPlan : IEquatable<OperationPlan>
- Inheritance
-
OperationPlan
- Implements
- Inherited Members
Remarks
A plan is the value-independent half of an operation: its effective type, and what follows from it - the type each operand is let-coerced to, and whether the operation is a type mismatch. The other half, evaluating the plan on values, is the runtime's.
The same planner answers for two kinds of types. Given the value types of the operands - what the interpreter has, a Variant operand being the type of
what it holds - a plan is final. Given declared types, an operand declared Variant or Object says nothing about the value it will hold,
and the plan is IsDeferred: it is made again, at run time, from the value types. The tables of the specification are keyed by value types, so for
any other operand the value type is the declared type, and the two plans agree.
Constructors
OperationPlan(string, IReadOnlyList<VBType>, VBType?, bool)
What an operation does, decided from the types of its operands alone - before, and apart from, any value it is evaluated on (IR lowering §3.2).
public OperationPlan(string Operator, IReadOnlyList<VBType> Operands, VBType? EffectiveType, bool IsDeferred = false)
Parameters
OperatorstringThe operator: one of the
Tokensoperators.OperandsIReadOnlyList<VBType>The types the plan was made for, one for each operand, in order.
EffectiveTypeVBTypeThe effective type of the operation, or null when there is none: a type mismatch, or a plan that is deferred.
IsDeferredboolWhether the plan depends on the value an operand declared
VariantorObjectholds, and is made at run time.
Remarks
A plan is the value-independent half of an operation: its effective type, and what follows from it - the type each operand is let-coerced to, and whether the operation is a type mismatch. The other half, evaluating the plan on values, is the runtime's.
The same planner answers for two kinds of types. Given the value types of the operands - what the interpreter has, a Variant operand being the type of
what it holds - a plan is final. Given declared types, an operand declared Variant or Object says nothing about the value it will hold,
and the plan is IsDeferred: it is made again, at run time, from the value types. The tables of the specification are keyed by value types, so for
any other operand the value type is the declared type, and the two plans agree.
Properties
EffectiveType
The effective type of the operation, or null when there is none: a type mismatch, or a plan that is deferred.
public VBType? EffectiveType { get; init; }
Property Value
IsDeferred
Whether the plan depends on the value an operand declared Variant or Object holds, and is made at run time.
public bool IsDeferred { get; init; }
Property Value
IsTypeMismatch
Whether the operation has no effective type for these operands: run-time error 13, Type mismatch.
public bool IsTypeMismatch { get; }
Property Value
OperandDestination
What a non-Null operand is let-coerced to before the operation is evaluated: the effective type, except that a Date operation is evaluated in
Double (MS-VBAL §5.6.9.3). null when nothing is coerced - a Null effective type, whose result is
Null whatever the other operand is, a plan with no effective type, and Is, which compares two object references as they are
(§5.6.9.7). Worked out once, with the plan: it is asked for every time the plan is evaluated.
public VBType? OperandDestination { get; }
Property Value
Operands
The types the plan was made for, one for each operand, in order.
public IReadOnlyList<VBType> Operands { get; init; }
Property Value
Operator
The operator: one of the Tokens operators.
public string Operator { get; init; }
Property Value
Methods
Equals(OperationPlan?)
Whether two plans agree: the same operator, the same operand types, the same outcome. A record of an array compares the arrays by reference, which is not what makes two plans the same.
public bool Equals(OperationPlan? other)
Parameters
otherOperationPlan
Returns
GetHashCode()
Serves as the default hash function.
public override int GetHashCode()
Returns
- int
A hash code for the current object.