Class DerivedComparisonGenerator
java.lang.Object
org.ek9lang.compiler.phase7.synthesis.AbstractSyntheticGenerator
org.ek9lang.compiler.phase7.synthesis.DerivedComparisonGenerator
Generates synthetic IR for derived comparison operators: <, <=, >, >=.
These operators delegate to <=> (_cmp) and interpret the Integer result:
- < - returns true if _cmp result < 0
- <= - returns true if _cmp result <= 0
- > - returns true if _cmp result > 0
- >= - returns true if _cmp result >= 0
Generated code pattern:
Boolean operator(T other):
cmpResult = this._cmp(other)
if !cmpResult._isSet() -> return unset
return cmpResult.{_lt|_lte|_gt|_gte}(0)
This approach leverages the existing _cmp implementation which already handles:
- This/other isSet guards
- Super class comparison
- Field-by-field tri-state semantics
-
Field Summary
Fields inherited from class AbstractSyntheticGenerator
stackContext -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongenerate(String operatorName, MethodSymbol operatorSymbol, AggregateSymbol aggregateSymbol) Generate IR for a derived comparison operator.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
-
DerivedComparisonGenerator
DerivedComparisonGenerator(IRGenerationContext stackContext)
-
-
Method Details
-
generate
List<IRInstr> generate(String operatorName, MethodSymbol operatorSymbol, AggregateSymbol aggregateSymbol) Generate IR for a derived comparison operator.- Parameters:
operatorName- The operator symbol (<, <=, >, >=)operatorSymbol- The operator method symbolaggregateSymbol- The aggregate containing the operator- Returns:
- List of IR instructions implementing the operator
-