Package org.ek9lang.compiler.phase7.synthesis


package org.ek9lang.compiler.phase7.synthesis
Synthetic operator and method generation for EK9.

This package contains the infrastructure for generating IR instructions for synthetic operators and methods. These are operators/methods declared with the 'default' keyword in EK9 source code, where the compiler generates the implementation automatically based on the aggregate's fields.

Architecture

Synthetic generation happens at IR level (Phase 7), not at the backend level. This ensures:

  • Single implementation serves both JVM and LLVM backends
  • Testable via @IR directives
  • IR optimization (Phase 12) benefits both backends
  • Backends remain "pretty dumb" - just translate IR instructions

Key Classes

Supported Operators

For records and classes with 'default operator':

  • _eq (==) - Field-by-field equality
  • _neq (<>) - Negation of _eq
  • _hashcode (#?) - Combined hash of all fields
  • _string ($) - String representation
  • _copy (:=:) - Copy all fields

For enumerations (implicitly generated):

  • _lt, _lte, _gt, _gte - Ordinal comparisons
  • _cmp (<=>) - Three-way comparison
  • _inc, _dec (++, --) - Navigation through enum values