Table of Contents

Interface ISessionSymbols

Namespace
RDCore.SDK.Runtime.Abstract.Execution
Assembly
RDCore.SDK.dll

The symbol table of an execution session: defines and resolves symbols by scope.

public interface ISessionSymbols

Properties

Defaults

What the storage of a declared variable starts as, or null while nothing can reduce the constant expressions of an array's bounds yet - a session whose symbols are only being defined. Set by whatever composes the execution pipeline, as Lifecycle is.

IVariableDefaults? Defaults { get; set; }

Property Value

IVariableDefaults

Remarks

While it is null, a variable starts as the default value of its declared type, which for a fixed-size array is one with no dimensions: Symbols.Abstract.SymbolProperties.ArrayBounds are applied by whatever sets this.

Resolver

The read face over this table — resolves a name visible from a scope by walking the scope tree the currently-defined symbols form (tracks later TryDefine(Symbol, ScopeKind) calls), and reads the live run-time binding a defined symbol was allocated, if any.

ISymbolResolver Resolver { get; }

Property Value

ISymbolResolver

Methods

CreateFrame(SyntaxNodeId, StaticSymbol, ModuleDirectives)

Creates a new, empty ICallStackFrame for an activation of procedure, wired to this session's value storage. The caller Push(Symbol, VBTypedValue)es each parameter and Dim local it declares, then pushes the frame onto CallStack to make them resolvable.

ICallStackFrame CreateFrame(SyntaxNodeId nodeId, StaticSymbol procedure, ModuleDirectives directives = default)

Parameters

nodeId SyntaxNodeId

The Identity of the call-site node this activation is for.

procedure StaticSymbol

The StaticSymbol identifying the procedure being activated.

directives ModuleDirectives

The ModuleDirectives of the module declaring the procedure: what the code of the activation is executed under.

Returns

ICallStackFrame

CreateInstance(VBRuntimeObjectId, VBClassModuleSymbol)

Creates a new IObjectInstance for a freshly-created object of classModule, allocating storage for every instance field the class declares (RD-VBAL §2.3.1.2's instance heap tier) and registering it for later lookup by objectId. This only allocates the instance's field storage — the object's reference-counted lifetime is tracked separately, by Objects.

IObjectInstance CreateInstance(VBRuntimeObjectId objectId, VBClassModuleSymbol classModule)

Parameters

objectId VBRuntimeObjectId

The object's identity, minted by CreateObject().

classModule VBClassModuleSymbol

The class module being instantiated.

Returns

IObjectInstance

DestroyInstance(VBRuntimeObjectId)

Frees every field objectId's instance allocated and forgets it. Called once the object's reference count reaches zero and TryRemoveObject(VBRuntimeObjectId) succeeds.

bool DestroyInstance(VBRuntimeObjectId objectId)

Parameters

objectId VBRuntimeObjectId

Returns

bool

false if no instance is registered for objectId.

MembersOf(Uri)

The members the session has defined for a module, in no particular order: every procedure, property accessor, event, variable and constant declared by the module whose Uri is moduleUri.

IReadOnlyList<VBTypeMemberSymbol> MembersOf(Uri moduleUri)

Parameters

moduleUri Uri

The Uri of the module symbol.

Returns

IReadOnlyList<VBTypeMemberSymbol>

Remarks

Names are not enough to find a declaration: the Get, Let and Set accessors of a property share one.

ScopeOf(Uri)

The lexical scope a symbol's code is found in (RD-VBAL §2.3.1.2), over everything the session has defined: what the static pass resolves the names of a procedure body against.

LexicalScope? ScopeOf(Uri uri)

Parameters

uri Uri

The Uri of the procedure or module.

Returns

LexicalScope

The scope, or null when the session has defined no symbol at that address.

TryComposeClassModule(string, ImmutableArray<string>, ImmutableArray<SourceRange>)

Composes the class module moduleName from the members the session now has defined for it: its VBClassModuleSymbol.Members, its default interface, and the interfaces it implements (MS-VBAL §5.2.4.2), resolved over every class module the session has.

bool TryComposeClassModule(string moduleName, ImmutableArray<string> implementedInterfaceNames, ImmutableArray<SourceRange> implementedInterfaceRanges = default)

Parameters

moduleName string

The name of the class module, which has been defined with its members.

implementedInterfaceNames ImmutableArray<string>

The names of the interfaces its Implements directives name, as written.

implementedInterfaceRanges ImmutableArray<SourceRange>

Where each directive is written, one for each name, or empty when that is not known.

Returns

bool

false if the session has no class module of that name.

Remarks

A module symbol is composed from a project without being read, and its members are defined one at a time, each under its own identity: nothing links the symbol of a class to what it declares, which is what an object of the class needs to find the members it is called on, the events it raises and handles, and the interfaces it implements. This is the step that does, and it is one for the whole session rather than for the module: an interface defined after the class that implements it, or defined again since, leaves the class holding it as it was.

TryDefine(Symbol, ScopeKind)

Defines symbol in the given scope. A program-lifetime declaration — a standard module's or the global scope's field or variable — is allocated storage immediately, reachable afterwards through Resolver's GetValue.

bool TryDefine(Symbol symbol, ScopeKind scope)

Parameters

symbol Symbol
scope ScopeKind

Returns

bool

true if the symbol was added; false if it was already defined in that scope.

TryGetInstance(VBRuntimeObjectId, out IObjectInstance?)

Gets the IObjectInstance registered for objectId, if any — e.g. to resolve a member-access expression's target once objectId is known from evaluating the object reference it was accessed through.

bool TryGetInstance(VBRuntimeObjectId objectId, out IObjectInstance? instance)

Parameters

objectId VBRuntimeObjectId
instance IObjectInstance

Returns

bool

TryRedefine(Symbol, ScopeKind)

Replaces the definition of a symbol that is already defined in scope with symbol, and keeps the value its storage holds when that value is still the declaration's own.

bool TryRedefine(Symbol symbol, ScopeKind scope)

Parameters

symbol Symbol

The newest definition, which takes the place of the one with the same identity.

scope ScopeKind

The scope it was defined in.

Returns

bool

false if no symbol with that identity was defined in that scope.

Remarks

What a live session needs when a module is read again but a variable in it was not touched: a module-level variable, or a Static local, is the same declaration before and after, so what it held is still what it holds. Redefining it with TryUndefine(Symbol, ScopeKind) and TryDefine(Symbol, ScopeKind) instead would hand back its type's default every time anything else in the module changed.

The value is kept only when the declared type is identical. A variable redeclared as another type is not the same variable, and its storage — sized for the old type — is freed and allocated again, as it would be by TryUndefine(Symbol, ScopeKind) followed by TryDefine(Symbol, ScopeKind). A symbol that holds no storage is simply replaced.

TryResolveConditionalConstant(string, Symbol, out Symbol?)

Resolves name visible from scope as a conditional compilation constant (ResolveConditionalConstant(string, ScopeKind, Uri)) — the context of a #If directive's expression, and the only one such a constant is accessible to (MS-VBAL §3.4.1).

bool TryResolveConditionalConstant(string name, Symbol scope, out Symbol? symbol)

Parameters

name string
scope Symbol
symbol Symbol

Returns

bool

true if the name bound to exactly one constant.

TryResolveType(string, Symbol, out Symbol?)

Resolves name visible from scope in the type binding context (ResolveType(string, ScopeKind, Uri)) — the context of an As clause or the operand of New.

bool TryResolveType(string name, Symbol scope, out Symbol? symbol)

Parameters

name string
scope Symbol
symbol Symbol

Returns

bool

true if the name bound to exactly one symbol.

TryResolveValue(string, Symbol, out Symbol?)

Resolves name visible from scope in the default binding context (ResolveValue(string, ScopeKind, Uri)) — the context of a simple name expression.

bool TryResolveValue(string name, Symbol scope, out Symbol? symbol)

Parameters

name string
scope Symbol
symbol Symbol

Returns

bool

true if the name bound to exactly one symbol.

TryUndefine(Symbol, ScopeKind)

Removes symbol from scope, freeing whatever storage its definition allocated.

bool TryUndefine(Symbol symbol, ScopeKind scope)

Parameters

symbol Symbol

The symbol to remove.

scope ScopeKind

The scope it was defined in.

Returns

bool

false if no such symbol was defined in that scope.

Remarks

What makes a definition replaceable, which a live session needs: a module the user edits is defined again, and the second definition is the one that is true. Undefining a symbol whose storage held a value discards that value — it is a redefinition, not a rename.