Class CopyGenerator

java.lang.Object
org.ek9lang.compiler.phase7.synthesis.AbstractSyntheticGenerator
org.ek9lang.compiler.phase7.synthesis.CopyGenerator

final class CopyGenerator extends AbstractSyntheticGenerator
Generates synthetic IR for the _copy (:=:) operator.

The generated code follows this pattern:

Void _copy(T source):
  // For each field:
  fieldValue = LOAD source.field
  STORE this.field, fieldValue

  return

Key semantic requirements:

  • Copies ALL fields from source to this
  • This is a mutating operation (modifies this)
  • Returns Void (no return value)
  • Both SET and UNSET field values are copied
  • Super's _copy is called if super is not Any

Note: This performs a shallow copy of field references. For deep copy semantics, aggregate-typed fields would need their own :=: operator called, but that is a more complex implementation reserved for future enhancement.

  • Constructor Details

  • Method Details

    • generate

      List<IRInstr> generate(MethodSymbol operatorSymbol, AggregateSymbol aggregateSymbol)
      Generate the _copy operator IR for the given aggregate.
      Parameters:
      operatorSymbol - The _copy operator method symbol
      aggregateSymbol - The aggregate containing the operator
      Returns:
      List of IR instructions implementing the operator