Class EnumPrimitiveOperatorGenerator

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

final class EnumPrimitiveOperatorGenerator extends AbstractSyntheticGenerator
THE generator for the enumeration operators that are "primitive field in, at most one call, out" (_eq, _cmp, _isSet, _string/_promote, _hashcode and _json); each operator is one row, a EnumPrimitiveOperatorGenerator.Shape.

Enum fields are Java primitives (_ordinal int, _name java.lang.String, _isEnumSet boolean), so every one of these operators has the same skeleton:

  [guard: this (and other) must be set -> return unset]
  for each receiver (this, then other when binary):
    prim = LOAD_FIELD receiver.field
    ek9  = Ek9Type._of(prim)
  [result = ek9(this)._call(ek9(other))]
  STORE rtn; RETAIN rtn; BRANCH returnResult
  [return-unset block]
  return-result block

The ORDER of every generateLabelName and generateTempName call is what numbers labels and temporaries in the IR, so the skeleton keeps the order the six original classes used: labels first (unset, then result), then temporaries in body order. Enumeration operators with real bodies (first/last, increment/decrement, constructor, iterator, and the String-parameter comparisons) are not rows here.