Class ConstructSafeAccessMarker<C extends org.antlr.v4.runtime.ParserRuleContext>
java.lang.Object
org.ek9lang.compiler.phase5.ConstructSafeAccessMarker<C>
- Type Parameters:
C- the construct's parse context.
- All Implemented Interfaces:
Consumer<C>
final class ConstructSafeAccessMarker<C extends org.antlr.v4.runtime.ParserRuleContext>
extends Object
implements Consumer<C>
THE marker of what a construct's pre-flow and control expression prove safe for Optional / Result / Iterator
access (E08030) - one class for
if, switch, try, while, for and the ternary
(it was six near-identical subclasses). The construct is described by four accessors, built by
ConstructSafeAccessMarkers (forIfBlock, forWhile, ...); each says where that construct keeps
its pre-flow and its control expression, in which scope a proof is safe, and where its condition ends
(conditionEndOf).
The pre-flow's subject is safe in the construct ONLY when the pre-flow is a guard that skips the construct when
the subject is unset (<-, :=? - PreFlowCanSkipBody). A plain := checks nothing:
if o := empty() then gate ran its body with an empty o and o.get() threw. Before marking, a
pre-flow that re-points a subject the scope AROUND the construct has already proven safe is E08040 - judged here,
because the construct's own marking would hide it. Each top-level and conjunct of the control that is an
is-set check proves its subject safe in the scope, whatever the other conjuncts are (SafeAccessConjuncts).
The pre-flow is processed first, then the control expression.
-
Constructor Summary
ConstructorsConstructorDescriptionConstructSafeAccessMarker(SymbolsAndScopes symbolsAndScopes, ErrorListener errorListener, Function<C, EK9Parser.PreFlowStatementContext> preFlowOf, Function<C, EK9Parser.ExpressionContext> controlOf, Function<C, IScope> safeScopeOf, Function<C, org.antlr.v4.runtime.ParserRuleContext> conditionEndOf, ContainerChangedBetween containerChangedBetween) -
Method Summary
Modifier and TypeMethodDescriptionvoid(package private) org.antlr.v4.runtime.ParserRuleContextconditionEndOf(C construct) THE last part of what the construct evaluates before its body first runs - its guard and its control, as the construct has them - or null when it evaluates nothing first.
-
Constructor Details
-
ConstructSafeAccessMarker
ConstructSafeAccessMarker(SymbolsAndScopes symbolsAndScopes, ErrorListener errorListener, Function<C, EK9Parser.PreFlowStatementContext> preFlowOf, Function<C, EK9Parser.ExpressionContext> controlOf, Function<C, IScope> safeScopeOf, Function<C, org.antlr.v4.runtime.ParserRuleContext> conditionEndOf, ContainerChangedBetween containerChangedBetween)
-
-
Method Details
-
accept
-
conditionEndOf
THE last part of what the construct evaluates before its body first runs - its guard and its control, as the construct has them - or null when it evaluates nothing first. A proof made from that condition is judged by looking ahead over it (ContainerChangedBetween), so the walk of the condition need not withdraw it again (SafeAccessWithdrawal.holdOwnProofs(IScope, ParseTree)).
-