Record Class SetStateValue
java.lang.Object
java.lang.Record
org.ek9lang.compiler.phase5.flow.SetStateValue
- All Implemented Interfaces:
AbstractValue
Represents a variable known to be either SET (has a meaningful value) or UNSET (declared but no value).
Phase 3 of the value-tracking lattice. Tracks the isSet state of variables through
assignments, guard expressions, and literal initializations. Used to detect redundant
? (isSet) checks and impossible isSet checks.
SetStateValue is less precise than ConstantValue and RangeValue:
if a variable is known to hold a constant or be in a range, it is implicitly SET.
SetStateValue is used when we know the set/unset state but not the specific value.
Lattice join rules:
SET join SET = SETUNSET join UNSET = UNSETSET join UNSET = TOP(disagreement)SET join ConstantValue = ConstantValue(more precise, both agree SET)UNSET join ConstantValue = TOP(disagreement)SET join RangeValue = RangeValue(more precise, both agree SET)UNSET join RangeValue = TOP(disagreement)
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final SetStateValueSingleton for a variable known to be SET.static final SetStateValueSingleton for a variable known to be UNSET. -
Constructor Summary
ConstructorsConstructorDescriptionSetStateValue(boolean isSet) Creates an instance of aSetStateValuerecord class. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.evaluateCondition(String operator, AbstractValue operand) Evaluate whether this abstract value satisfies a comparison condition.final inthashCode()Returns a hash code value for this object.booleanisBottom()Check if this value represents an unreachable program point.booleanisKnown()Check if this value represents a known state (not TOP and not BOTTOM).booleanisSet()Returns the value of theisSetrecord component.join(AbstractValue other) Join this value with another at a branch convergence point.toString()Returns a string representation of this record class.Methods inherited from interface AbstractValue
isKnownSet
-
Field Details
-
SET
Singleton for a variable known to be SET. -
UNSET
Singleton for a variable known to be UNSET.
-
-
Constructor Details
-
SetStateValue
public SetStateValue(boolean isSet) Creates an instance of aSetStateValuerecord class.- Parameters:
isSet- the value for theisSetrecord component
-
-
Method Details
-
join
Description copied from interface:AbstractValueJoin this value with another at a branch convergence point. Returns the least upper bound of the two values.Key rules:
- BOTTOM join X = X (unreachable path is ignored)
- X join BOTTOM = X
- TOP join X = TOP
- Constant(a) join Constant(a) = Constant(a) (both agree)
- Constant(a) join Constant(b) = TOP (disagreement)
- Specified by:
joinin interfaceAbstractValue
-
evaluateCondition
Description copied from interface:AbstractValueEvaluate whether this abstract value satisfies a comparison condition.- Specified by:
evaluateConditionin interfaceAbstractValue- Parameters:
operator- the comparison operator (==, <>, <, >, etc.)operand- the right-hand side value to compare against- Returns:
- TRUE if condition is always satisfied, FALSE if never satisfied, UNKNOWN if indeterminate
-
isKnown
public boolean isKnown()Description copied from interface:AbstractValueCheck if this value represents a known state (not TOP and not BOTTOM).- Specified by:
isKnownin interfaceAbstractValue
-
isBottom
public boolean isBottom()Description copied from interface:AbstractValueCheck if this value represents an unreachable program point.- Specified by:
isBottomin interfaceAbstractValue
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with thecomparemethod from their corresponding wrapper classes. -
isSet
public boolean isSet()Returns the value of theisSetrecord component.- Returns:
- the value of the
isSetrecord component
-