Class PossibleExpressionConstruct
java.lang.Object
org.ek9lang.compiler.common.RuleSupport
org.ek9lang.compiler.common.TypedSymbolAccess
org.ek9lang.compiler.phase5.PossibleExpressionConstruct
- Direct Known Subclasses:
ForStatementOrError, SwitchStatementOrError, TryStatementOrError, WhileStatementOrError
Used as a base for a range of constructs that can be expressions.
-
Field Summary
Fields inherited from class RuleSupport
errorListener, symbolsAndScopes -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedPossibleExpressionConstruct(SymbolsAndScopes symbolsAndScopes, ErrorListener errorListener) -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanisVariableInitialisedInScopes(CodeFlowAnalyzer analyzer, ISymbol variable, List<IScope> scopes) protected voidprocessPossibleGuardInitialisation(CodeFlowAnalyzer analyzer, ISymbol guardVariable, org.antlr.v4.runtime.ParserRuleContext ctx) Now when there is a preflow control, it may mean that a variable is initialised.protected voidpullUpAcceptableCriteriaToHigherScope(CodeFlowAnalyzer analyzer, List<IScope> allAppropriateBlocks, IScope outerScope) protected voidreturningVariableValidOrError(EK9Parser.ReturningParamContext ctx, IScope constructScope, boolean bodyGuaranteedToRun) Validates the returning variable of an expression-form construct.Methods inherited from class TypedSymbolAccess
getRecordedAndTypedSymbol, isProcessingScopePure, recordATypedSymbol
-
Constructor Details
-
PossibleExpressionConstruct
protected PossibleExpressionConstruct(SymbolsAndScopes symbolsAndScopes, ErrorListener errorListener)
-
-
Method Details
-
isVariableInitialisedInScopes
protected boolean isVariableInitialisedInScopes(CodeFlowAnalyzer analyzer, ISymbol variable, List<IScope> scopes) -
getGuardExpressionVariable
-
getGuardExpressionVariable
-
processPossibleGuardInitialisation
protected void processPossibleGuardInitialisation(CodeFlowAnalyzer analyzer, ISymbol guardVariable, org.antlr.v4.runtime.ParserRuleContext ctx) Now when there is a preflow control, it may mean that a variable is initialised. -
pullUpAcceptableCriteriaToHigherScope
protected void pullUpAcceptableCriteriaToHigherScope(CodeFlowAnalyzer analyzer, List<IScope> allAppropriateBlocks, IScope outerScope) -
returningVariableValidOrError
protected void returningVariableValidOrError(EK9Parser.ReturningParamContext ctx, IScope constructScope, boolean bodyGuaranteedToRun) Validates the returning variable of an expression-form construct.When the body is NOT guaranteed to run - a body-skipping guard (
<-/?=/:=?, seePreFlowCanSkipBody) can bypass it, or a loop can iterate zero times - a return declared with no initial value (<- rtn as T?) could be left unset on the skip path, so it MUST carry a declaration initialiser. Enforced uniformly across switch/while/do/for/try (before this it fired only for?=on some constructs and relied on a per-construct backstop, which let switch/for/for-range leak a raw Javanullinto the LHS at runtime).
-