Class EqualsGenerator
java.lang.Object
org.ek9lang.compiler.phase7.synthesis.AbstractSyntheticGenerator
org.ek9lang.compiler.phase7.synthesis.EqualsGenerator
Generates synthetic IR for the _eq (==) operator.
The generated code follows this pattern:
Boolean _eq(T other):
// Guard: check this is set
if !this._isSet() -> return unset
// Guard: check other is set
if !other._isSet() -> return unset
// Super check (if super is not Any)
if super != Any:
result = super._eq(other)
if !result._isSet() -> return unset
if !result._true() -> return false
// Field-by-field comparison
for each field in properties:
result = this.field._eq(other.field)
if !result._isSet() -> return unset
if !result._true() -> return false
return true
Key semantic requirements:
- If this or other is unset, return unset
- If any field comparison returns unset, return unset
- If any field comparison returns false, return false (short-circuit)
- Only if all comparisons return true, return true
- Super's _eq is called if super is not Any
-
Field Summary
Fields inherited from class AbstractSyntheticGenerator
stackContext -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongenerate(MethodSymbol operatorSymbol, AggregateSymbol aggregateSymbol) Generate the _eq operator 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
-
EqualsGenerator
EqualsGenerator(IRGenerationContext stackContext)
-
-
Method Details
-
generate
Generate the _eq operator IR for the given aggregate.- Parameters:
operatorSymbol- The _eq operator method symbolaggregateSymbol- The aggregate containing the operator- Returns:
- List of IR instructions implementing the operator
-