Class CopyGenerator
java.lang.Object
org.ek9lang.compiler.phase7.synthesis.AbstractSyntheticGenerator
org.ek9lang.compiler.phase7.synthesis.CopyGenerator
Generates synthetic IR for the _copy (:=:) operator.
The generated code follows this pattern:
Void _copy(T source): // For each field: fieldValue = LOAD source.field STORE this.field, fieldValue return
Key semantic requirements:
- Copies ALL fields from source to this
- This is a mutating operation (modifies this)
- Returns Void (no return value)
- Both SET and UNSET field values are copied
- Super's _copy is called if super is not Any
Note: This performs a shallow copy of field references. For deep copy semantics, aggregate-typed fields would need their own :=: operator called, but that is a more complex implementation reserved for future enhancement.
-
Field Summary
Fields inherited from class AbstractSyntheticGenerator
stackContext -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongenerate(MethodSymbol operatorSymbol, AggregateSymbol aggregateSymbol) Generate the _copy 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
-
CopyGenerator
CopyGenerator(IRGenerationContext stackContext)
-
-
Method Details
-
generate
Generate the _copy operator IR for the given aggregate.- Parameters:
operatorSymbol- The _copy operator method symbolaggregateSymbol- The aggregate containing the operator- Returns:
- List of IR instructions implementing the operator
-