Class IsSetGenerator
java.lang.Object
org.ek9lang.compiler.phase7.synthesis.AbstractSyntheticGenerator
org.ek9lang.compiler.phase7.synthesis.IsSetGenerator
Generates synthetic IR for the _isSet (?) operator using AND (flattened-aggregate) semantics.
An aggregate is "set" if and only if EVERY field is set - as if the whole inheritance chain were
flattened onto one object and every field checked. This is the boolean twin of the copy-left $
operator: obj is set <=> ?obj is true <=> all fields set.
The generated code follows this pattern:
Boolean _isSet(): // Check super first (if not Any and has ? operator): if NOT super._isSet() -> return false // an inherited field is unset -> we are unset // For each own field: // if NOT this.field._isSet() -> return false // a single unset field -> we are unset // Fell through: super (if any) set AND every own field set -> return true
Key semantic requirements:
- Returns true only if ALL fields are set (short-circuit to false on the first unset field)
- Returns false if super._isSet() returns false (honours the super's false)
- Returns true if class has NO fields (stateless object is vacuously set)
- A partially-initialised object - any own OR inherited field unset - is UNSET
- STOPS at Any: Any._isSet() is always false; the superHasOperator("?") gate excludes it so it is never folded into the AND (which would force every derived object unset)
- No parameter checking needed (no "other" parameter)
-
Nested Class Summary
Nested classes/interfaces inherited from class AbstractSyntheticGenerator
AbstractSyntheticGenerator.ScopeSetup -
Field Summary
Fields inherited from class AbstractSyntheticGenerator
stackContext -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongenerate(MethodSymbol methodSymbol, AggregateSymbol aggregateSymbol) Generate the _isSet operator IR for the given aggregate.Methods inherited from class AbstractSyntheticGenerator
aggregateHasOperator, constructorCall, createDebugInfo, createSynthesisScope, generateAnyFieldSetGuard, generateBinaryOperatorGuards, generateBooleanBranch, generateFieldLoad, generateFieldLoad, generateFieldSetStatusCheck, generateIsSetGuard, generateIsSetGuard, generateLabelName, generateResultReturnBlock, generateResultReturnBlock, generateStringLiteralLoad, generateTempName, generateThisIsSetGuard, generateThisIsSetGuard, generateUnsetReturnBlockWithLabel, generateUnsetReturnBlockWithLabel, getBitsTypeName, getBooleanTypeName, getIntegerTypeName, getReturnBlockHelper, getStringTypeName, getSuperTypeName, getSyntheticFields, getTypeName, getVoidTypeName, initializeScope, initializeScopeNoReturn, isAnyType, isTraitType, methodCall, superHasOperator
-
Constructor Details
-
IsSetGenerator
IsSetGenerator(IRGenerationContext stackContext)
-
-
Method Details
-
generate
Generate the _isSet operator IR for the given aggregate.- Parameters:
methodSymbol- The _isSet method symbolaggregateSymbol- The aggregate containing the method- Returns:
- List of IR instructions implementing the method
-