Table of Contents

Class LexicalScope

Namespace
RDCore.SDK.Model.Symbols
Assembly
RDCore.SDK.dll

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

uri Uri

The 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.

kind LexicalScopeKind

Which tier of the resolution tree this scope is.

parent LexicalScope

The enclosing scope, or null for the global scope.

declarations IEnumerable<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.

directives ModuleDirectives?

The declaring module's ModuleDirectivesnull for 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

ModuleDirectives?

Kind

Which tier of the resolution tree this scope is.

public LexicalScopeKind Kind { get; }

Property Value

LexicalScopeKind

Parent

The enclosing scope, or null for the global scope.

public LexicalScope? Parent { get; }

Property Value

LexicalScope

Uri

The Uri of the symbol this scope belongs to.

public Uri Uri { get; }

Property Value

Uri

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

name string

Returns

IEnumerable<Symbol>

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

ModuleDirectives?

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()

Returns

IEnumerable<LexicalScope>