Class SyntheticOperatorGenerator

java.lang.Object
org.ek9lang.compiler.phase7.synthesis.SyntheticOperatorGenerator

public final class SyntheticOperatorGenerator extends Object
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 Details

    • SyntheticOperatorGenerator

      public SyntheticOperatorGenerator(IRGenerationContext stackContext)
      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 OperationInstr with fully populated IR instructions.

      Parameters:
      operatorSymbol - The synthetic operator method symbol
      aggregateSymbol - The aggregate (class/record) containing the operator
      Returns:
      The populated OperationInstr with generated IR body
    • generateMethod

      public OperationInstr generateMethod(MethodSymbol methodSymbol, AggregateSymbol aggregateSymbol)
      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 symbol
      aggregateSymbol - The aggregate containing the method
      Returns:
      The populated OperationInstr with generated IR body