Class EnumStringParamGenerator

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

final class EnumStringParamGenerator extends AbstractSyntheticGenerator
Generates synthetic IR for enum operators that accept a String parameter.

EK9 enumerations support all 7 comparison operators with a String parameter. The implementation converts the String to an enum via the String constructor, then delegates to the corresponding same-type operator:

Boolean _eq(String param):
  temp = new EnumType(param)   // String constructor: lookup enum by name
  if !temp._isSet() -> return unset  // String didn't match any enum value
  return this._eq(temp)        // Delegate to same-type operator

Integer _cmp(String param):
  temp = new EnumType(param)
  if !temp._isSet() -> return unset
  return this._cmp(temp)

This handles all 7 String-param comparison operators: ==, <>, <, <=, >, >=, <=>

  • Constructor Details

  • Method Details

    • generate

      List<IRInstr> generate(String operatorName, MethodSymbol operatorSymbol, AggregateSymbol aggregateSymbol)
      Generate a String-param comparison operator for an enumeration.
      Parameters:
      operatorName - The operator symbol (==, <>, etc.)
      operatorSymbol - The operator method symbol
      aggregateSymbol - The enumeration aggregate
      Returns:
      List of IR instructions