Struct StaticEvaluationContext
The compile-time context an IStaticSemantics rule evaluates an expression against:
the name-resolution service, the LexicalScope a SimpleName or
MemberAccess expression resolves from (RD-VBAL §2.3.1.2), and the innermost
enclosing With block's target type, if any.
public readonly record struct StaticEvaluationContext : IEquatable<StaticEvaluationContext>
- Implements
- Inherited Members
Remarks
Resolver and Scope are deliberately just those two: a rule that needs a
module-level fact — Option Explicit, Option Compare, whatever MS-VBAL directive comes
next — reads it off EnclosingModuleDirectives() through Scope,
rather than this record growing a parameter for it. EnclosingWithTargetType is a
different kind of fact — it isn't lexical (derivable from Scope alone), it's
statement-tree-positional: only a caller that has walked the enclosing statement tree (see
StatementStaticSemanticsEvaluator) knows it, which is why it's threaded through here rather
than derived.
Constructors
StaticEvaluationContext(ISymbolResolver, LexicalScope, VBType?, IExpressionFactSink?)
The compile-time context an IStaticSemantics rule evaluates an expression against:
the name-resolution service, the LexicalScope a SimpleName or
MemberAccess expression resolves from (RD-VBAL §2.3.1.2), and the innermost
enclosing With block's target type, if any.
public StaticEvaluationContext(ISymbolResolver Resolver, LexicalScope Scope, VBType? EnclosingWithTargetType = null, IExpressionFactSink? Facts = null)
Parameters
ResolverISymbolResolverResolves identifier names to symbols and reads their bound values.
ScopeLexicalScopeThe scope the expression being evaluated is lexically found in.
EnclosingWithTargetTypeVBTypeThe declared type of the innermost enclosing
Withblock's target expression (MS-VBAL §5.6.15), ornullwhen the expression being evaluated is not inside anyWithblock. A with-relative access (.Member/!Member) resolves against this; per §5.6.15, one is invalid when this isnull.FactsIExpressionFactSinkWhere the facts of the expressions evaluated are recorded (ExpressionFact), or
nullwhen the caller has no use for anything but the declared type.
Remarks
Resolver and Scope are deliberately just those two: a rule that needs a
module-level fact — Option Explicit, Option Compare, whatever MS-VBAL directive comes
next — reads it off EnclosingModuleDirectives() through Scope,
rather than this record growing a parameter for it. EnclosingWithTargetType is a
different kind of fact — it isn't lexical (derivable from Scope alone), it's
statement-tree-positional: only a caller that has walked the enclosing statement tree (see
StatementStaticSemanticsEvaluator) knows it, which is why it's threaded through here rather
than derived.
Properties
EnclosingWithTargetType
The declared type of the innermost enclosing With block's target expression
(MS-VBAL §5.6.15), or null when the expression being evaluated is not
inside any With block. A with-relative access (.Member/!Member) resolves
against this; per §5.6.15, one is invalid when this is null.
public VBType? EnclosingWithTargetType { get; init; }
Property Value
Facts
Where the facts of the expressions evaluated are recorded (ExpressionFact), or null when the caller
has no use for anything but the declared type.
public IExpressionFactSink? Facts { get; init; }
Property Value
Resolver
Resolves identifier names to symbols and reads their bound values.
public ISymbolResolver Resolver { get; init; }
Property Value
Scope
The scope the expression being evaluated is lexically found in.
public LexicalScope Scope { get; init; }