Class ExpressionStaticSemanticsEvaluator
Recursively determines the declared type of a real, arbitrarily-nested expression tree.
public static class ExpressionStaticSemanticsEvaluator
- Inheritance
-
ExpressionStaticSemanticsEvaluator
- Inherited Members
Remarks
Every individual IStaticSemantics rule (SimpleNameExpressionStaticSemantics,
MemberAccessExpressionStaticSemantics, operators, ...) only knows how to combine
already-resolved operand types for the one node it handles — nothing recurses into an expression's
own children first to produce them. This is that missing piece: given any ExpressionNode,
it dispatches by the node's own C# type (and, for operator nodes, by Token) to the matching
rule, evaluating children first and short-circuiting on the first error, so a nested expression like
Foo.Bar.Baz or x + 1 resolves end to end instead of only ever being unit-tested with
hand-fed operand types.
Methods
Evaluate(StaticEvaluationContext, ExpressionNode)
Determines the declared type of expression, recursively evaluating its
children first wherever a rule needs their declared types as operands.
public static StaticSemanticsEvaluationResult Evaluate(StaticEvaluationContext context, ExpressionNode expression)
Parameters
contextStaticEvaluationContextThe compile-time context this expression is evaluated against.
expressionExpressionNodeThe expression to evaluate — may be arbitrarily nested.
Returns
- StaticSemanticsEvaluationResult
The result of the first rule (own or a child's) that fails, or the final resolved type when the whole tree evaluates successfully. A node kind with no rule yet (or an operator token with no mapped rule, e.g.
Mod) defers to VBUnknownType rather than erroring — the same "not modeled yet, not wrong" convention every existing rule already uses for its own gaps.