Class MustExecutePosition
- All Implemented Interfaces:
Predicate<org.antlr.v4.runtime.tree.ParseTree>
The walk climbs from the node to the body it belongs to - a function, method, operator, service operation or
dynamic function body, or a property initialiser - and every step must be a position that is always evaluated:
a statement in a body, an initialiser, an argument, an operand, the first condition of an if, the subject
of a switch, the condition and collection of a loop, a try body, a finally block, the
source of a stream, its sink, a tee's side target and every stage operand written as an expression (all
evaluated once, before any item is pulled).
Everything conditional answers false: if/else bodies and later conditions, case and
default bodies, loop bodies (a do body too, deliberately, for now), catch blocks, the right
operand of and/or/xor and of every coalescing operator, the arms of a ternary, the right of
:=?, a condition after a guard, the per-item work of stream stages, and assertions.
🔑 It is a whitelist. Any position it does not recognise answers false, so a construct added to the grammar later can only make an analysis miss something, never report something that cannot happen. A code path that always throws before a call is not considered: the call still counts as executed.
Two scopes, one whitelist: new MustExecutePosition() asks "every time its BODY runs" (FE77), and
MustExecutePosition.Scope.STATEMENT asks "every time the evaluation that OWNS it runs" - the walk then ends, true, at the
nearest owner: a blockStatement, or, for code in no statement at all, the initialiser of a returning
variable (returningParam) or of a property (aggregateProperty), or a text's string
(textBodyDeclaration). Two other differences: an assert statement's condition runs every time
that statement does, and so does a do/while's condition (FE77 keeps both out). The statement form
is what decides which closeable temporaries a statement or an initialiser owns
(phase5/StatementOwnedCloseableCalls).
A third scope, MustExecutePosition.Scope.EVALUATION, is the statement scope with one more kind of owner: an
evaluation that runs only CONDITIONALLY, every time it runs (Steve, 2026-10-06: "an unnamed closeable is closed as
soon as the evaluation that made it finishes"). Where the statement walk meets a conditional position and answers
false, this walk answers true when that position is one of the conditionally evaluated operands IR generation wraps
in its own owned region (isConditionalEvaluation(ParseTree, ParseTree)): the right of and/or/xor and of
every coalescing operator, a ternary arm, a later else if condition, a condition after a guard, the right of
:=?, a switch case expression. Every other conditional position still answers false.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumHow far the walk climbs: to the enclosing BODY (MustExecutePosition.Scope.BODY, FE77), to the evaluation that owns the code in its statement form (MustExecutePosition.Scope.STATEMENT), or to the nearest conditionally evaluated operand too (MustExecutePosition.Scope.EVALUATION). -
Constructor Summary
ConstructorsConstructorDescriptionDoes the code run every time its enclosing BODY runs.Does the code run every time its enclosing body, statement or evaluation (MustExecutePosition.Scope) runs. -
Method Summary
-
Constructor Details
-
MustExecutePosition
public MustExecutePosition()Does the code run every time its enclosing BODY runs. -
MustExecutePosition
Does the code run every time its enclosing body, statement or evaluation (MustExecutePosition.Scope) runs.
-
-
Method Details
-
test
-