Class EnumStringGenerator
java.lang.Object
org.ek9lang.compiler.phase7.synthesis.AbstractSyntheticGenerator
org.ek9lang.compiler.phase7.synthesis.EnumStringGenerator
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").
-
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 methodName, MethodSymbol operatorSymbol, AggregateSymbol aggregateSymbol) Generate the _string or _promote 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
-
EnumStringGenerator
EnumStringGenerator(IRGenerationContext stackContext)
-
-
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 symbolaggregateSymbol- The enumeration aggregate- Returns:
- List of IR instructions
-