Class EnumStringGenerator

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

final class EnumStringGenerator extends AbstractSyntheticGenerator
Generates synthetic IR for the enum _string ($) and _promote (#^) operators.

Enum fields use Java primitives:

  • _ordinal: int (primitive)
  • _name: java.lang.String
  • _isEnumSet: boolean (primitive)

Both operators return the enum's _name field converted to EK9 String:

String _string():
  if !this._isSet() -> return unset
  namePrimitive = this._name (java.lang.String)
  return String._of(namePrimitive)

String _promote():
  if !this._isSet() -> return unset
  namePrimitive = this._name (java.lang.String)
  return String._of(namePrimitive)

Note: Unlike class/record _string which returns "ClassName(field=value)", enum _string returns just the enum value name (e.g., "MONDAY").

  • Constructor Details

  • Method Details

    • generate

      List<IRInstr> generate(String methodName, MethodSymbol operatorSymbol, AggregateSymbol aggregateSymbol)
      Generate the _string or _promote operator for an enumeration.
      Parameters:
      methodName - The internal method name ("_string" or "_promote")
      operatorSymbol - The operator method symbol
      aggregateSymbol - The enumeration aggregate
      Returns:
      List of IR instructions