Class EnumEqualsGenerator

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

final class EnumEqualsGenerator extends AbstractSyntheticGenerator
Generates synthetic IR for the enum _eq (==) operator.

Enum fields use Java primitives:

  • _ordinal: int (primitive)
  • _isEnumSet: boolean (primitive)

Unlike the class/record EqualsGenerator which compares field-by-field, enums compare their _ordinal values for equality by converting primitive ordinals to EK9 Integer and using _eq:

Boolean _eq(EnumType other):
  if !this._isSet() -> return unset
  if !other._isSet() -> return unset
  thisOrd = Integer._of(this._ordinal)
  otherOrd = Integer._of(other._ordinal)
  return thisOrd._eq(otherOrd)