Class LexicalScope
One lexical scope of a composed workspace — a compile-time region a name lookup starts from and then walks outward, through the Parent chain, until the name binds or the global scope is reached (MS-VBAL §5.2 Name Binding, RD-VBAL §2.3.1.2).
public sealed class LexicalScope
- Inheritance
-
LexicalScope
- Inherited Members
Remarks
A lexical scope is not a ScopeKind — that says which allocation heap a symbol lives
in — nor a run-time call-stack frame, which holds one activation's values. The tree has four
tiers: the global scope, the project scope (a standard module's non-Private members,
visible to every sibling module), one scope per module, and one per procedure / property /
function / event body. Ordering referenced libraries by their .rdproj priority within the
global scope is not modelled yet.
Constructors
LexicalScope(Uri, LexicalScopeKind, LexicalScope?, IEnumerable<Symbol>, ModuleDirectives?)
Creates a scope belonging to the symbol at uri that directly declares
declarations.
public LexicalScope(Uri uri, LexicalScopeKind kind, LexicalScope? parent, IEnumerable<Symbol> declarations, ModuleDirectives? directives = null)
Parameters
uriUriThe Uri of the symbol this scope belongs to — a module, a procedure, the workspace root for the project scope, or the well-known GlobalUri for the global scope.
kindLexicalScopeKindWhich tier of the resolution tree this scope is.
parentLexicalScopeThe enclosing scope, or
nullfor the global scope.declarationsIEnumerable<Symbol>The symbols declared directly in this scope. A name declared more than once here (a field and a procedure that collide, two
Dims of one name) keeps every declaration — reporting the ambiguous name is the caller's concern.directivesModuleDirectives?The declaring module's ModuleDirectives —
nullfor every tier except the module scope itself, which carries its Directives.
Properties
Directives
The declaring module's directives, for the module scope itself; null elsewhere.
public ModuleDirectives? Directives { get; }
Property Value
Kind
Which tier of the resolution tree this scope is.
public LexicalScopeKind Kind { get; }
Property Value
Parent
The enclosing scope, or null for the global scope.
public LexicalScope? Parent { get; }
Property Value
Uri
The Uri of the symbol this scope belongs to.
public Uri Uri { get; }
Property Value
Methods
DeclaredAs(string)
The symbols this scope declares directly under name, matched
case-insensitively (MS-VBAL §3.3.5 — identifiers are not case-sensitive).
Empty when the name is not declared here; more than one element means the name is ambiguous
within this scope.
public IEnumerable<Symbol> DeclaredAs(string name)
Parameters
namestring
Returns
EnclosingModuleDirectives()
The ModuleDirectives of the module enclosing this scope — itself, if this
is the module scope, otherwise the nearest ancestor that carries them. null
when no enclosing module scope exists (the global or project scope, reached directly).
public ModuleDirectives? EnclosingModuleDirectives()
Returns
SelfAndAncestors()
This scope, then each enclosing scope out to the global scope — the order a name lookup visits them (RD-VBAL §2.3.1.2).
public IEnumerable<LexicalScope> SelfAndAncestors()