Class ConversionPlanner
Makes the ConversionPlan of a let-coercion from the type of the value and the type it is let-coerced to: the one table of the rules of MS-VBAL §5.5.1.2, consulted when a conversion is bound from declared types and when it is evaluated on a value (IR lowering §3.2).
public static class ConversionPlanner
- Inheritance
-
ConversionPlanner
- Inherited Members
Remarks
A plan depends on nothing but the two types, so each is made once and kept, and the plans last asked for are also kept by the identity of the types (RDCore.SDK.Semantics.Plans.RecentPlans<TPlan>): a variable assigned in a loop is let-coerced from the same type every time.
An object, Null, Empty and an Error are let-coerced by rules of their own, whatever the destination is - but for a Variant
or a fixed-size array, which hold Null, Empty and an Error as they are, or have no rule for them. Anything else is let-coerced by
the rule of its destination. Whether that rule takes the value is the conversion's to say: the plan names the rule, and the rule decides.
The static semantics have a table of their own (§5.5.1.1), keyed by declared types, which says which let-coercions are valid at all, and
are not to consult this one: they are stricter where the specification makes them so - an implicit let-coercion from a LongLong to anything but a
LongLong or a Variant is invalid, though the same value let-coerced at run time from a Variant is not. What they accept, this table does not reject for
the same declared types - but where the specification itself makes a Byte() let-coerced to a number, a Boolean or a date statically valid
(§5.5.1.1 lists no such row) and a type mismatch whenever it runs (§5.5.1.2.6).
Methods
ForDeclared(VBType, VBType)
The plan of the let-coercion of a source of this declared type: IsDeferred when it is declared Variant or is
late-bound (VBUnknownType), whose value type is not known until the conversion is evaluated, and the plan of its value otherwise.
public static ConversionPlan ForDeclared(VBType source, VBType destination)
Parameters
sourceVBTypeThe declared type of the source.
destinationVBTypeThe declared type the value is let-coerced to.
Returns
Remarks
A fixed-length string holds a String, an Enum a Long, a LongPtr what it is an alias of, and a class an object: those are the
value types the plan is made for.
ForValue(VBType, VBType)
The plan of the let-coercion of a value of this type: final, whatever the types are.
public static ConversionPlan ForValue(VBType source, VBType destination)
Parameters
sourceVBTypeThe value type of the source: the type of what a Variant holds, and for an array, an array of its elements - a
Byte()is let-coerced by rules an array of anything else is not.destinationVBTypeThe declared type the value is let-coerced to.