Class EnumHashCodeGenerator

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

final class EnumHashCodeGenerator extends AbstractSyntheticGenerator
Generates synthetic IR for the enum _hashcode (#?) operator.

Enum fields use Java primitives:

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

Returns the hashcode of the _ordinal field by converting the primitive int to an EK9 Integer and calling _hashcode():

Integer _hashcode():
  if !this._isSet() -> return unset
  ordinalPrimitive = this._ordinal (int)
  ordinalInteger = Integer._of(ordinalPrimitive)
  return ordinalInteger._hashcode()