Class ScopeTreeSymbolResolver
The compile-time ISymbolResolver: binds an identifier by walking a ScopeTree from the scope a lookup originates in — the first tier that declares the name binds it (MS-VBAL §5.6.10, RD-VBAL §2.3.1.2). A name declared more than once in a single module or procedure scope resolves as Duplicate(IEnumerable<Symbol>); more than once at the project or global tier resolves as Ambiguous(IEnumerable<Symbol>).
public sealed class ScopeTreeSymbolResolver : ISymbolResolver
- Inheritance
-
ScopeTreeSymbolResolver
- Implements
- Inherited Members
- Extension Methods
Remarks
ResolveValue(string, ScopeKind, Uri) and ResolveType(string, ScopeKind, Uri) walk the same tree under the two binding contexts MS-VBAL §5.6.4 distinguishes, each with its own candidates: a user-defined type or a class module is only ever bound by ResolveType(string, ScopeKind, Uri) (or, for a class module and the project, as the qualifier of a qualified type name, by ResolveQualifier(string, ScopeKind, Uri)), and a local, parameter, constant, variable or procedure only ever by ResolveValue(string, ScopeKind, Uri). A class module that has a predeclared instance (VBPredeclaredInstanceSymbol) is also a name in the default binding context — as that instance, a variable of the class's type.
A name-resolution service only — the value-binding members throw, matching the intent of a
design-time resolver that holds no run-time bindings. Ordering referenced projects and libraries
by their .rdproj priority within the global scope, and reporting an ambiguous name as a
coded compile-time error rather than an unbound result, are later work.
Constructors
ScopeTreeSymbolResolver(ScopeTree)
The compile-time ISymbolResolver: binds an identifier by walking a ScopeTree from the scope a lookup originates in — the first tier that declares the name binds it (MS-VBAL §5.6.10, RD-VBAL §2.3.1.2). A name declared more than once in a single module or procedure scope resolves as Duplicate(IEnumerable<Symbol>); more than once at the project or global tier resolves as Ambiguous(IEnumerable<Symbol>).
public ScopeTreeSymbolResolver(ScopeTree scopeTree)
Parameters
scopeTreeScopeTreeThe tree to resolve against.
Remarks
ResolveValue(string, ScopeKind, Uri) and ResolveType(string, ScopeKind, Uri) walk the same tree under the two binding contexts MS-VBAL §5.6.4 distinguishes, each with its own candidates: a user-defined type or a class module is only ever bound by ResolveType(string, ScopeKind, Uri) (or, for a class module and the project, as the qualifier of a qualified type name, by ResolveQualifier(string, ScopeKind, Uri)), and a local, parameter, constant, variable or procedure only ever by ResolveValue(string, ScopeKind, Uri). A class module that has a predeclared instance (VBPredeclaredInstanceSymbol) is also a name in the default binding context — as that instance, a variable of the class's type.
A name-resolution service only — the value-binding members throw, matching the intent of a
design-time resolver that holds no run-time bindings. Ordering referenced projects and libraries
by their .rdproj priority within the global scope, and reporting an ambiguous name as a
coded compile-time error rather than an unbound result, are later work.
Methods
GetValue(Symbol)
Gets the IBindingHandle currently associated with the specified Symbol.
public IBindingHandle GetValue(Symbol symbol)
Parameters
Returns
ResolveConditionalConstant(string, ScopeKind, Uri)
Resolves name as a conditional compilation constant. The tiers are §3.4.1's own
shadowing rule: the enclosing module's own #Const declarations, then the project-level ones,
which the global scope carries. scope is not consulted.
public SymbolResolutionResult ResolveConditionalConstant(string name, ScopeKind scope, Uri handle)
Parameters
Returns
ResolveMember(Symbol, string, Uri)
Resolves name as a member of owner, a project or a procedural module
(MS-VBAL §5.6.12), as seen from the scope the symbol at handle belongs to.
public SymbolResolutionResult ResolveMember(Symbol owner, string name, Uri handle)
Parameters
Returns
Remarks
A module's members are what its own scope declares, less any that are Private to a lookup that does not
originate inside the module. A project's are, in the specification's order: a project, when the owner is the
enclosing project; a procedural module of the project; then the project tier's one accessible member of that
name — which is a tier of exactly the members "exactly one of the procedural modules" may have, so two modules
declaring the name collide there as an ambiguous name, as they do unqualified. The project tier is shared by
every module of the tree, a library's included, so which project a candidate is in is read off its
Library.
ResolveQualifier(string, ScopeKind, Uri)
Resolves name as the qualifier of a qualified type name (the A in A.B), as
seen from the scope the symbol at handle belongs to. A qualifier is a namespace, and neither
a user-defined type nor an Enum type can contain a type: the enclosing module's own types and the types of
the project's other modules are not tiers here, and what is left is the enclosing project itself, or a
procedural or class module in it. scope is not consulted.
public SymbolResolutionResult ResolveQualifier(string name, ScopeKind scope, Uri handle)
Parameters
Returns
ResolveType(string, ScopeKind, Uri)
Resolves name in the type binding context, as seen from the scope the symbol
at handle belongs to. The tiers, in order of precedence
(MS-VBAL §5.6.4): a user-defined type or Enum declared at the level of the
enclosing module; then the enclosing project itself, or a procedural or class module in it; then
an accessible user-defined type or Enum declared in another module of the project. The procedure
scope is never consulted — no local is a type. scope is not consulted.
public SymbolResolutionResult ResolveType(string name, ScopeKind scope, Uri handle)
Parameters
Returns
ResolveValue(string, ScopeKind, Uri)
Resolves name in the default binding context, as seen from the scope the
symbol at handle belongs to. The tiers, in order of precedence
(MS-VBAL §5.6.10): the enclosing procedure; the enclosing module; the enclosing
project itself, or a procedural module in it; an accessible member of another procedural module of
the project; then whatever else the global scope declares, which includes a class module's
predeclared instance. Neither a user-defined type nor a class module is a candidate in any tier.
scope is not consulted.
public SymbolResolutionResult ResolveValue(string name, ScopeKind scope, Uri handle)
Parameters
Returns
TryAllocate(Symbol, VBTypedValue, out MemoryAddress)
Reserves storage sized for value and binds it to symbol —
a Static local's own first-call allocation (MS-VBAL §5.4.3.1: module
extent, so it must persist past its own frame popping) chiefly. This is a storage-only
operation: it never affects name resolution, so it is never how a symbol's name itself becomes
resolvable — that rides on its own declaring symbol instead (a procedure's own
Locals/Parameters), the same way calling this twice for an already-allocated
symbol is safe (a fresh allocation, the previous one freed first) but never necessary.
public bool TryAllocate(Symbol symbol, VBTypedValue value, out MemoryAddress address)
Parameters
symbolSymbolThe symbol to reserve storage for.
valueVBTypedValueThe value to seed the new storage with.
addressMemoryAddressThe reserved address, on success.
Returns
- bool
falseif the underlying memory space is exhausted.
TryGetAddress(Symbol, out MemoryAddress)
Gets the MemoryAddress currently reserved for symbol, if any —
what a ByRef argument binds to (MS-VBAL §5.3.1.11: "a reference parameter
binding... referring to the variable referenced by the argument's expression").
public bool TryGetAddress(Symbol symbol, out MemoryAddress address)
Parameters
symbolSymbolThe Symbol whose address to look up.
addressMemoryAddressThe reserved address, if
symbolis currently allocated.
Returns
TryRead(MemoryAddress, out IBindingHandle?)
Gets the IBindingHandle at the specified address in the runtime memory map.
public bool TryRead(MemoryAddress address, out IBindingHandle? value)
Parameters
addressMemoryAddressThe memory address to read.
valueIBindingHandleThe retrieved binding, if successful.