Class SyntheticOperatorGenerator
java.lang.Object
org.ek9lang.compiler.phase7.synthesis.SyntheticOperatorGenerator
Main coordinator for synthetic operator generation.
This class dispatches synthetic operator/method generation to the appropriate specialized generator based on the operator type. All synthetic generation happens at IR level, producing complete instruction sequences that backends can translate directly.
Supported Operators
For records and classes:
- _eq - Field-by-field equality comparison
- _neq - Delegates to _eq and negates
- _hashcode - Combined hash of all fields
- _string - String representation of all fields
- _copy - Copy all fields from source
For enumerations:
- _lt, _lte, _gt, _gte - Ordinal comparisons
- _cmp - Three-way comparison
- _inc, _dec - Navigate enum values
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionSyntheticOperatorGenerator(IRGenerationContext stackContext) Create a new synthetic operator generator. -
Method Summary
Modifier and TypeMethodDescriptiongenerateMethod(MethodSymbol methodSymbol, AggregateSymbol aggregateSymbol) Generate IR for a synthetic regular method (non-operator).generateOperator(MethodSymbol operatorSymbol, AggregateSymbol aggregateSymbol) Generate IR for a synthetic operator.
-
Constructor Details
-
SyntheticOperatorGenerator
Create a new synthetic operator generator.- Parameters:
stackContext- The IR generation context for accessing state
-
-
Method Details
-
generateOperator
public OperationInstr generateOperator(MethodSymbol operatorSymbol, AggregateSymbol aggregateSymbol) Generate IR for a synthetic operator.Dispatches to the appropriate specialized generator based on the operator name. Returns a complete
OperationInstrwith fully populated IR instructions.- Parameters:
operatorSymbol- The synthetic operator method symbolaggregateSymbol- The aggregate (class/record) containing the operator- Returns:
- The populated OperationInstr with generated IR body
-
generateMethod
Generate IR for a synthetic regular method (non-operator).Handles methods like _isSet that are auto-generated based on aggregate properties.
- Parameters:
methodSymbol- The synthetic method symbolaggregateSymbol- The aggregate containing the method- Returns:
- The populated OperationInstr with generated IR body
-