Class ConstructorStateExtractor
java.lang.Object
org.ek9lang.compiler.phase5.flow.ConstructorStateExtractor
Extracts collection/container state information from constructor calls and literal expressions.
Detects constructor calls on built-in collection and container types (List, Dict, Optional) and literal expressions ([...], {...}) to determine their initial SET/UNSET and EMPTY/NON-EMPTY state at construction time.
Detection rules:
[1, 2, 3](list literal) → SET and NON-EMPTY{"key": 1}(dict literal) → SET and NON-EMPTYList() of String→ SET and EMPTYDict() of (String, Integer)→ SET and EMPTYOptional("hello")→ SET and NON-EMPTY - a literal argument, or one the flow analysis knows is set; any other argument is unknown (an Optional of an unset value is unset, D-2)Optional() of String→ UNSET and EMPTY
-
Constructor Summary
ConstructorsConstructorDescriptionConstructorStateExtractor(SymbolsAndScopes symbolsAndScopes, Ek9Types ek9Types, Predicate<EK9Parser.ExpressionContext> knownSet) Create the extractor. -
Method Summary
Modifier and TypeMethodDescriptionExtract a CollectionStateValue from an assignment expression if it is a collection/container constructor or literal.Extract a CollectionStateValue from an expression if it is a collection/container constructor or literal.booleanIs this assignment's right-hand side a construction of a type with no fields, counting inherited ones, whose '?' is the synthesised one (AlwaysSetWhenPresent, Q-COMPONENT-?)? Such a value is set whenever it is present, so it is provably SET (F3, Steve 2026-10-07) - the counterpart ofisUnsetLiteralTypeConstruction(EK9Parser.AssignmentExpressionContext).booleanIs this assignment's right-hand side a constructor that always makes a present but UNSET value - the no-argument constructor of a literal type (Integer(),String(),Date(), ...), whose symbol carriesCONSTRUCTS_UNSETfrom its@Ek9Constructor(constructsUnset = true)(pinned for all 19 by ek9-langUnsetFactsTestand runtimeFuzzliteralTypeNoArgUnset).
-
Constructor Details
-
ConstructorStateExtractor
public ConstructorStateExtractor(SymbolsAndScopes symbolsAndScopes, Ek9Types ek9Types, Predicate<EK9Parser.ExpressionContext> knownSet) Create the extractor.- Parameters:
knownSet- whether the flow analysis knows an expression (an Optional's argument) is set at this point
-
-
Method Details
-
extractFromAssignment
Extract a CollectionStateValue from an assignment expression if it is a collection/container constructor or literal.- Parameters:
assignExpr- the assignment expression to examine- Returns:
- a CollectionStateValue if a known constructor pattern is detected, null otherwise
-
extractFromExpression
Extract a CollectionStateValue from an expression if it is a collection/container constructor or literal.- Parameters:
expr- the expression to examine- Returns:
- a CollectionStateValue if a known pattern is detected, null otherwise
-
isUnsetLiteralTypeConstruction
Is this assignment's right-hand side a constructor that always makes a present but UNSET value - the no-argument constructor of a literal type (Integer(),String(),Date(), ...), whose symbol carriesCONSTRUCTS_UNSETfrom its@Ek9Constructor(constructsUnset = true)(pinned for all 19 by ek9-langUnsetFactsTestand runtimeFuzzliteralTypeNoArgUnset). A user type's constructor never counts here: its?is its own to define (E07235) - the one user-type fact that IS provable, a field-less type set by being present, isisAlwaysSetConstruction(EK9Parser.AssignmentExpressionContext). Read by the guard-gate check (D7), and recorded by the value tracker as UNSET wherever a variable is declared or assigned from one.- Parameters:
assignExpr- the assignment expression to examine- Returns:
- true when the value is provably unset
-
isAlwaysSetConstruction
Is this assignment's right-hand side a construction of a type with no fields, counting inherited ones, whose '?' is the synthesised one (AlwaysSetWhenPresent, Q-COMPONENT-?)? Such a value is set whenever it is present, so it is provably SET (F3, Steve 2026-10-07) - the counterpart ofisUnsetLiteralTypeConstruction(EK9Parser.AssignmentExpressionContext). Any constructor of the type counts; a call that is not a constructor (a function returning the type, which may return a sub-type with its own '?') never does.- Parameters:
assignExpr- the assignment expression to examine- Returns:
- true when the value is provably set
-