Class ToStringGenerator
java.lang.Object
org.ek9lang.compiler.phase7.synthesis.AbstractSyntheticGenerator
org.ek9lang.compiler.phase7.synthesis.ToStringGenerator
Generates synthetic IR for the _string ($) operator.
The generated code follows this pattern:
String _string():
result = "ClassName("
needsSeparator = false
// For each field:
if field._isSet():
if needsSeparator:
result = result + ", "
result = result + "fieldName="
result = result + field.$()
needsSeparator = true
else:
if needsSeparator:
result = result + ", "
result = result + "fieldName=?"
needsSeparator = true
result = result + ")"
return result
Key semantic requirements:
- Returns String (always set)
- Format: "ClassName(field1=value1, field2=value2)"
- SET fields show their string value via $
- UNSET fields show "?" as placeholder
- Uses simple class name (not fully qualified)
-
Field Summary
Fields inherited from class AbstractSyntheticGenerator
stackContext -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongenerate(MethodSymbol operatorSymbol, AggregateSymbol aggregateSymbol) Generate the _string operator IR for the given aggregate.Methods inherited from class AbstractSyntheticGenerator
createDebugInfo, generateBooleanReturnBlock, generateConstructorCall, generateFieldLoad, generateIsSetGuard, generateLabelName, generateMethodCall, generateTempName, generateThisIsSetGuard, generateUnsetReturnBlock, getBooleanTypeName, getIntegerTypeName, getStringTypeName, getSuperTypeName, getSyntheticFields, getTypeName, getVoidTypeName, isAnyType, superHasOperator
-
Constructor Details
-
ToStringGenerator
ToStringGenerator(IRGenerationContext stackContext)
-
-
Method Details
-
generate
Generate the _string operator IR for the given aggregate.- Parameters:
operatorSymbol- The _string operator symbolaggregateSymbol- The aggregate containing the operator- Returns:
- List of IR instructions implementing the operator
-