Class IsSetGenerator
java.lang.Object
org.ek9lang.compiler.phase7.synthesis.AbstractSyntheticGenerator
org.ek9lang.compiler.phase7.synthesis.IsSetGenerator
Generates synthetic IR for the _isSet (?) operator.
The generated code follows this pattern:
Boolean _isSet(): // Check super first (if not Any and has ? operator) if super._isSet() -> return true // Valid via parent // For each field in own properties: // result = this.field._isSet() // if result._true() -> return true // Found set field return false // No fields set = truly empty object
Key semantic requirements:
- Returns true if ANY field is set (short-circuit on first set)
- Returns true if super._isSet() returns true
- Returns false only when ALL fields are unset (truly empty)
- No parameter checking needed (no "other" parameter)
This "ANY field set" semantic enables:
- Partial objects with optional fields to be valid
- Builder patterns where objects become valid incrementally
- Reduced boilerplate (no need to override ? for optional fields)
-
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, createDebugInfo, createSynthesisScope, generateAnyFieldSetGuard, generateBinaryOperatorGuards, generateBooleanBranch, generateBooleanReturnBlock, generateConstructorCall, generateConstructorCall, generateConstructorCall, generateConstructorCallWithArgs, generateFieldLoad, generateFieldLoad, generateFieldSetStatusCheck, generateIsSetGuard, generateIsSetGuard, generateLabelName, generateMethodCall, generateMethodCall, generateMethodCall, generateMethodCall, generateMethodCall, generateResultReturnBlock, generateResultReturnBlock, generateStringLiteralLoad, generateTempName, generateThisIsSetGuard, generateThisIsSetGuard, generateUnsetReturnBlock, generateUnsetReturnBlockWithLabel, generateUnsetReturnBlockWithLabel, getBitsTypeName, getBooleanTypeName, getIntegerTypeName, getReturnBlockHelper, getStringTypeName, getSuperTypeName, getSyntheticFields, getTypeName, getVoidTypeName, initializeScope, isAnyType, 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
-