Class EnumStringParamGenerator
java.lang.Object
org.ek9lang.compiler.phase7.synthesis.AbstractSyntheticGenerator
org.ek9lang.compiler.phase7.synthesis.EnumStringParamGenerator
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: ==, <>, <, <=, >, >=, <=>
-
Nested Class Summary
Nested classes/interfaces inherited from class AbstractSyntheticGenerator
AbstractSyntheticGenerator.ScopeSetup -
Field Summary
Fields inherited from class AbstractSyntheticGenerator
stackContext -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongenerate(String operatorName, MethodSymbol operatorSymbol, AggregateSymbol aggregateSymbol) Generate a String-param comparison operator for an enumeration.Methods inherited from class AbstractSyntheticGenerator
aggregateHasOperator, createDebugInfo, createSynthesisScope, generateAnyFieldSetGuard, generateBinaryOperatorGuards, generateBooleanBranch, generateBooleanReturnBlock, generateConstructorCall, generateConstructorCall, generateConstructorCall, generateConstructorCallWithArgs, generateFieldLoad, generateFieldLoad, generateFieldSetStatusCheck, generateIsSetGuard, generateIsSetGuard, generateLabelName, generateMethodCall, generateMethodCall, generateMethodCall, generateMethodCall, generateMethodCall, generateMethodCall, generateMethodCall, generateMethodCallNoArg, generateResultReturnBlock, generateResultReturnBlock, generateStringLiteralLoad, generateTempName, generateThisIsSetGuard, generateThisIsSetGuard, generateUnsetReturnBlock, generateUnsetReturnBlockWithLabel, generateUnsetReturnBlockWithLabel, generateVoidMethodCall, getBitsTypeName, getBooleanTypeName, getIntegerTypeName, getReturnBlockHelper, getStringTypeName, getSuperTypeName, getSyntheticFields, getTypeName, getVoidTypeName, initializeScope, initializeScopeNoReturn, isAnyType, isTraitType, superHasOperator
-
Constructor Details
-
EnumStringParamGenerator
EnumStringParamGenerator(IRGenerationContext stackContext)
-
-
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 symbolaggregateSymbol- The enumeration aggregate- Returns:
- List of IR instructions
-