Table of Contents

Class StatementStaticSemanticsEvaluator

Namespace
RDCore.SDK.Semantics.Static
Assembly
RDCore.SDK.dll

Recursively walks a real, arbitrarily-nested statement tree, evaluating every expression it contains via ExpressionStaticSemanticsEvaluator, threading the innermost enclosing With block's target type (MS-VBAL §5.6.15) through its body, checking Let/Set assignment coercion validity between an assignment's Target and Value, and checking that every label a jump statement names is defined (MS-VBAL §5.4.2.12–§5.4.2.16, §5.4.4.1, §5.4.4.2).

public static class StatementStaticSemanticsEvaluator
Inheritance
StatementStaticSemanticsEvaluator
Inherited Members

Remarks

This is the statement-tree analogue of ExpressionStaticSemanticsEvaluator: nothing previously walked a StatementBlock's nested blocks (If/Do/For/ Select Case/With, ...) at all, so a With block's target type never had anywhere to flow from — ExpressionStaticSemanticsEvaluator could only ever defer a with-relative access, and an assignment's own coercion validity was never checked at all. Unlike an expression tree, a statement tree's individual statements are largely independent of one another, so this collects every error found across the whole tree rather than short-circuiting on the first one the way the expression evaluator does.

The operand of a jump statement names a label, not a value, and a label is not a symbol, so it is never handed to the expression evaluator. On Error GoTo 0, On Error GoTo -1 and Resume 0 are not jumps at all: their operand is a sentinel, not a label reference.

A Set assignment whose target is the default instance variable of a predeclared class (VBPredeclaredInstanceSymbol) is invalid (MS-VBAL §5.2.4.1.2) and reported as InvalidUseOfObject.

Methods

Analyze(SemanticId, StatementBlock, StaticSemanticsOptions, MemberKind?, StaticEvaluationContext?)

Analyzes the body of a procedure, and describes what the static pass found out about it.

public static ProcedureSemanticModel Analyze(SemanticId procedure, StatementBlock block, StaticSemanticsOptions options = default, MemberKind? kind = null, StaticEvaluationContext? context = null)

Parameters

procedure SemanticId

The identity of the procedure.

block StatementBlock

The statement block to walk - the procedure's body.

options StaticSemanticsOptions

The conditional-compilation branches that are excluded, and the language the body is written in.

kind MemberKind?

The kind of the procedure, when it is known.

context StaticEvaluationContext?

The compile-time context the body's expressions are evaluated in, or null when there is no workspace to resolve names in: only the structure of the body is checked then (CheckStructure(StatementBlock, StaticSemanticsOptions, MemberKind?)).

Returns

ProcedureSemanticModel

The model of the procedure.

CheckStructure(StatementBlock, StaticSemanticsOptions, MemberKind?)

Walks every statement in block and checks what needs no name resolution: where an Exit statement is written, that every label a jump names is defined and none is defined twice, and the statements the language has. The types of expressions, which need the symbols of a workspace, are not evaluated.

public static ImmutableArray<VBCompileErrorInfo> CheckStructure(StatementBlock block, StaticSemanticsOptions options = default, MemberKind? procedure = null)

Parameters

block StatementBlock

The statement block to walk - a procedure body.

options StaticSemanticsOptions

The conditional-compilation branches that are excluded, and the language the body is written in.

procedure MemberKind?

The kind of the procedure block is the body of, when it is known.

Returns

ImmutableArray<VBCompileErrorInfo>

Every compile error found, in traversal order, followed by those that are told once the whole body has been walked.

Evaluate(StaticEvaluationContext, StatementBlock, StaticSemanticsOptions, MemberKind?)

Walks every statement in block like Evaluate(StaticEvaluationContext, StatementBlock, MemberKind?), for the build and the language options state.

public static ImmutableArray<VBCompileErrorInfo> Evaluate(StaticEvaluationContext context, StatementBlock block, StaticSemanticsOptions options, MemberKind? procedure = null)

Parameters

context StaticEvaluationContext

The compile-time context to start walking from.

block StatementBlock

The statement block to walk - a procedure body.

options StaticSemanticsOptions

The conditional-compilation branches that are excluded, and the language the body is written in.

procedure MemberKind?

The kind of the procedure block is the body of, when it is known.

Returns

ImmutableArray<VBCompileErrorInfo>

Every compile error found, in traversal order, followed by those that are told once the whole body has been walked.

Evaluate(StaticEvaluationContext, StatementBlock, MemberKind?)

Walks every statement in block, recursing into nested blocks and collecting every compile error found anywhere in the tree.

public static ImmutableArray<VBCompileErrorInfo> Evaluate(StaticEvaluationContext context, StatementBlock block, MemberKind? procedure = null)

Parameters

context StaticEvaluationContext

The compile-time context to start walking from. EnclosingWithTargetType should be null unless block is itself already inside a With block relative to some outer context the caller is threading through.

block StatementBlock

The statement block to walk — a procedure body. A label is scoped to its procedure, not to the block it appears in, so label references are checked against the labels defined anywhere within this block: passing a nested block on its own would report every jump out of it as undefined.

procedure MemberKind?

The kind of the procedure block is the body of, which decides whether an Exit Sub, Exit Function or Exit Property statement in it is where it may be (ExitStatementStaticSemantics). null when it is not known: the kind of procedure is not checked then, and the Exit For and Exit Do statements still are.

Returns

ImmutableArray<VBCompileErrorInfo>

Every compile error found, in traversal order, followed by a LabelNotDefined error for each label reference that no line label or line number in block defines. Empty when the whole tree is valid.