Class IntrinsicVBTypes
The MS-VBAL 3.3.2 reserved data-type names and 3.3.1 type-declaration characters, each mapped to
its singleton VBType. This is the intrinsic-only fallback every component shares
when binding a declared type from a bare name without a project or library resolver: the
language server's AST symbol provider and the environment host's rdcore/host/symbols/define
handler resolve intrinsics identically from here, so a type that is VBUnknownType on one
side is VBUnknownType on the other.
public static class IntrinsicVBTypes
- Inheritance
-
IntrinsicVBTypes
- Inherited Members
Remarks
LongPtr is deliberately absent: its width depends on the host bitness
(IRuntimeEnvironmentProfile.Is64Bit), so a resolver that knows the profile must bind it.
Methods
DefaultLiteralOf(VBType)
The literal or constant that writes the value a variable of type is initialized to (MS-VBAL §2.3), as code
says it: 0 for a number, an enum or a LongPtr, vbNullString for a String, False, the date literal of midnight
for a Date, Empty for a Variant, and Nothing for an object.
public static string? DefaultLiteralOf(VBType type)
Parameters
typeVBTypeThe declared type of the variable.
Returns
Remarks
A fix writes it where a value has to be stated that the code leaves to the default: the value of a Const, or the assignment that makes a
variable's first value explicit. A type whose default no literal writes has none: a fixed-length string (filled with U+0000 characters,
MS-VBAL §3.1), a user-defined type, an array.
IsIntrinsic(string)
Whether typeName is the name of an intrinsic type, whatever the bitness of the environment: LongPtr is one in every environment.
public static bool IsIntrinsic(string typeName)
Parameters
typeNamestringThe name.
Returns
TryResolve(string, out VBType?)
Resolves an intrinsic type by its reserved name (case-insensitive).
public static bool TryResolve(string typeName, out VBType? type)
Parameters
Returns
TryResolve(string, bool, out VBType?)
Resolves an intrinsic type by its reserved name (case-insensitive), LongPtr among them, as an environment of the given bitness has it.
public static bool TryResolve(string typeName, bool is64Bit, out VBType? type)
Parameters
Returns
Remarks
MS-VBAL §2.2: "an implementation-defined LongPtr type alias is also defined", a Long on a 32-bit implementation and a LongLong on a 64-bit one -
which is why it is a name only an environment can resolve.
TryResolveTypeHint(string, out VBType?)
Resolves the intrinsic type named by an MS-VBAL 3.3.1 type-declaration character
(%, &, ^, !, #, @, $).
public static bool TryResolveTypeHint(string typeHint, out VBType? type)
Parameters
Returns
TryResolveValueType(Type, out VBType?)
Resolves the intrinsic type whose run-time values are of the given VBTypedValue implementation - the reverse of CreateValue(IBindingHandle).
public static bool TryResolveValueType(Type valueType, out VBType? type)
Parameters
valueTypeTypeThe VBTypedValue implementation to resolve the type of.
typeVBTypeThe intrinsic type whose values are of that implementation.
Returns
Remarks
This is how a declaration written in C# states an intrinsic VBA type: naming the value a member produces or a parameter accepts names the type, without restating it. The standard library's interfaces are declared that way.
The mapping covers exactly the intrinsics a declaration can name, which is the same set
TryResolve(string, out VBType?) resolves by name. The values that have no declarable type (a
VBEmptyValue, a VBMissingValue, a VBErrorValue) are
subtypes a Variant holds rather than types anything is declared as, and resolve here no
more than Dim x As Empty compiles. LongPtr is absent for the same reason it is
absent by name: its width depends on the host bitness.