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 an Integer bitmask 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
The generated code follows this pattern:
Integer _fieldSetStatus():
result = 0
// For each field at index i (mask = 2^i):
if field[i]._isSet():
result = result._or(mask)
return result
Callers can check if field N is set using:
status._and(MASK_N)._gt(0)
where MASK_N = 2^N (compile-time constant)
This approach enables:
- Efficient field status checking with a single method call
- Optimization opportunity: IR optimizer can cache results
- Compact representation: one Integer for up to 32 fields
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:
-
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
createDebugInfo, generateBooleanReturnBlock, generateConstructorCall, generateFieldLoad, generateIsSetGuard, generateLabelName, generateMethodCall, generateTempName, generateThisIsSetGuard, generateUnsetReturnBlock, getBooleanTypeName, getIntegerTypeName, getStringTypeName, getSuperTypeName, getSyntheticFields, getTypeName, getVoidTypeName, 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
-