Table of Contents

Class StdLibSymbolProvider

Namespace
RDCore.SDK.Runtime.StdLib
Assembly
RDCore.SDK.dll

The symbols of the standard library and of the objects the language environment provides globally — everything a name in VBA source can resolve to without the workspace declaring it.

public sealed class StdLibSymbolProvider : ISymbolProvider
Inheritance
StdLibSymbolProvider
Implements
Inherited Members

Remarks

Without these, every standard-library name is unbound, and an unbound name in a module with no Option Explicit is a declaration (MS-VBAL §5.6.10) — so Debug.Print x would quietly declare a local called Debug. Resolution is what stops that, which is why this exists before anything here is callable.

The standard library itself is read off the declarations that define it, by StdLibSymbolReader, and is provided unconditionally: every VBA project has it whether or not a .rdproj mentions it (RD-VBAL §6.1), so there is nothing to opt into and nothing to reference.

Debug is synthesized here instead, because nothing declares it: it is not in MS-VBAL's standard library at all (§6.1 has no Debug), it is provided by the host's own development environment, and it has exactly two members.

Constructors

StdLibSymbolProvider(Uri, bool)

Creates the provider.

public StdLibSymbolProvider(Uri workspaceRoot, bool is64Bit = true)

Parameters

workspaceRoot Uri

The workspace the symbols are addressed under. Library symbols are not of the workspace, but every Symbol is addressed relative to one, so they share its root and hang off the global scope rather than off a module.

is64Bit bool

The pointer width of the environment these symbols are for — LongPtr is a different type in each, so Conversion.CLngPtr's return type depends on it. Defaults to true, matching SdkEnvironmentOptions.Is64Bit's own default.

Fields

AssertMemberName

Debug.Assert: enters break mode when its expression is False.

public const string AssertMemberName = "Assert"

Field Value

string

DebugObjectName

The name of the object the development environment exposes for diagnostic output.

public const string DebugObjectName = "Debug"

Field Value

string

GlobalModuleName

The name of the synthetic module every global the language environment provides hangs off.

public const string GlobalModuleName = "_Global"

Field Value

string

Remarks

A leading underscore is not a legal VBA identifier, so no source can name this module and no workspace module can collide with it — which is the whole reason for the spelling. It is a standard module, so its members are promoted to the project scope and resolve unqualified, the way a standard library's members do.

It also gives a global object's class somewhere to be parented that is not the global scope itself. That matters: a predeclared instance is named after its class, so a class parented to the global scope has the very same Uri as its own instance, and the name then resolves to neither of them.

LibraryName

The name of the project the standard library is.

public const string LibraryName = "VBA"

Field Value

string

Remarks

It is what a project-qualified reference to the library names — VBA.Strings.LenB, VBA.LenB (MS-VBAL §5.6.12). It is the same in every dialect: VB6 loads the very same VBA library, and what it calls VB is the runtime library of its ActiveX controls, which is not this one. Where a dialect has more or fewer members than another, the members are what say so, not the name of the library.

PrintMemberName

Debug.Print: writes an output list to the environment's own output (MS-VBAL §5.4.5.8's rules, against no file).

public const string PrintMemberName = "Print"

Field Value

string

Methods

IsDebugObject(Symbol)

Whether symbol is the Debug object this provider synthesizes: the default instance of its Debug class, a member of the library's GlobalModuleName module - not a variable or a class of the workspace that happens to be named Debug.

public static bool IsDebugObject(Symbol symbol)

Parameters

symbol Symbol

The symbol a name resolved to.

Returns

bool

Remarks

Debug is somewhere between an object and a keyword: it is only ever written as the Debug.Print and Debug.Assert statements, and MS-VBA reads any other use of the name - a value, the target of an assignment or a With block - as a syntax error.

IsLibraryMember(Symbol)

Whether symbol is a member the standard library declares: a procedure of one of its modules, or a member of one of its classes.

public static bool IsLibraryMember(Symbol symbol)

Parameters

symbol Symbol

The member.

Returns

bool

true for a member of the standard library's; false for the workspace's, or a referenced library's.

Remarks

It carries the key the library's reader stamps on what it reads (ExternalTarget), and no other library claims it as its own: a referenced library's members carry a key of their own kind, and the name of their library (Library). A member of a class is not stamped with the library's name, as the class is: it is carried by the class, and never provided on its own.

ProvideSymbols()

Yields the symbols this provider's source defines. May be lazy.

public IEnumerable<Symbol> ProvideSymbols()

Returns

IEnumerable<Symbol>

SymbolsUnder(Uri, bool)

The symbols of the library under a workspace, read once for each workspace and pointer width: what a composition of the workspace binds names among, every time one is composed (a completion list, a signature, a rename).

public static IReadOnlyList<Symbol> SymbolsUnder(Uri workspaceRoot, bool is64Bit = true)

Parameters

workspaceRoot Uri

The workspace the symbols are addressed under.

is64Bit bool

The pointer width of the environment the symbols are for.

Returns

IReadOnlyList<Symbol>

Remarks

The library is the platform's, and does not change while it runs; its symbols are immutable records, so the same ones serve every composition. Reading them is not free - every member of every module of the library, described - and a composition reads them twice, once for each of its passes.