Class FieldSetStatusGenerator
java.lang.Object
org.ek9lang.compiler.phase7.synthesis.AbstractSyntheticGenerator
org.ek9lang.compiler.phase7.synthesis.FieldSetStatusGenerator
Generates synthetic IR for the _fieldSetStatus() method.
This method returns a Bits value where each bit represents whether a field is set (1) or not set (0). The bit position corresponds to the field's declaration order:
- Bit 0 = field 0 status
- Bit 1 = field 1 status
- Bit N = field N status
Using Bits instead of Integer removes the 32-field limit and provides a cleaner API for checking field status.
The generated code follows this pattern:
Bits _fieldSetStatus(): result = Bits() // Empty Bits (set but with 0 bits) // For each field: isSet = field._isSet() result._addAss(isSet) // Append bit: result += isSet return result
Callers can use:
status._eq(other)- compare if two objects have identical set fieldsstatus._empty()- check if no fields are setstatus._xor(other)- find fields set differently
This approach enables:
- Unlimited field count (no 32-field limit)
- Efficient field status comparison with single method call
- IR optimizer can cache results across expressions
Note: EK9 guarantees fields are always initialized (to unset values), so null checks are not needed. The _isSet() call handles the tri-state semantics (absent/unset/set) at the type level.
- See Also:
-
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 _fieldSetStatus method 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
-
FieldSetStatusGenerator
FieldSetStatusGenerator(IRGenerationContext stackContext)
-
-
Method Details
-
generate
Generate the _fieldSetStatus method IR for the given aggregate.- Parameters:
methodSymbol- The _fieldSetStatus method symbolaggregateSymbol- The aggregate containing the method- Returns:
- List of IR instructions implementing the method
-