Table of Contents

Class IntrinsicVBTypes

Namespace
RDCore.SDK.Model.Types
Assembly
RDCore.SDK.dll

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

type VBType

The declared type of the variable.

Returns

string

The literal or constant, or null when none writes the default value of the type.

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

typeName string

The name.

Returns

bool

TryResolve(string, out VBType?)

Resolves an intrinsic type by its reserved name (case-insensitive).

public static bool TryResolve(string typeName, out VBType? type)

Parameters

typeName string
type VBType

Returns

bool

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

typeName string

The name.

is64Bit bool

Whether the environment is 64-bit.

type VBType

The type.

Returns

bool

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

typeHint string
type VBType

Returns

bool

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

valueType Type

The VBTypedValue implementation to resolve the type of.

type VBType

The intrinsic type whose values are of that implementation.

Returns

bool

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.