Class EnumCompareGenerator

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

final class EnumCompareGenerator extends AbstractSyntheticGenerator
Generates synthetic IR for the enum _cmp (<=>) operator.

Enum fields use Java primitives:

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

The comparison loads the primitive int ordinals and converts them to EK9 Integer objects to use the _cmp() method:

Integer _cmp(EnumType other):
  if !this._isSet() -> return unset
  if !other._isSet() -> return unset
  thisOrd = Integer._of(this._ordinal)  // Convert int to EK9 Integer
  otherOrd = Integer._of(other._ordinal)
  return thisOrd._cmp(otherOrd)