Class ConstrainedDelegation
java.lang.Object
org.ek9lang.compiler.phase7.ConstrainedDelegation
THE delegation bodies of a constrained type (DFN-3): every method and operator cloned from the base forwards to
the base value held in
_delegate, re-wrapping a base result as the constrained type, and a mutation
re-validates the delegate afterwards; #^ (and _base()) hand back a COPY of the delegate.-
Constructor Summary
ConstructorsConstructorDescriptionConstrainedDelegation(IRGenerationContext stackContext, ConstrainedTypeInstrs instrs, ConstraintLowering lowering) -
Method Summary
Modifier and TypeMethodDescription(package private) voidprocessDelegationMethod(OperationInstr operation) Generate delegation method/operator body.(package private) voidprocessPromote(OperationInstr operation, String scopeName) Promote (#^) - and the synthesised_base(), scoped asscopeName- returns a fresh COPY of the delegate, never the delegate field reference.
-
Constructor Details
-
ConstrainedDelegation
ConstrainedDelegation(IRGenerationContext stackContext, ConstrainedTypeInstrs instrs, ConstraintLowering lowering)
-
-
Method Details
-
processDelegationMethod
Generate delegation method/operator body. -
processPromote
Promote (#^) - and the synthesised_base(), scoped asscopeName- returns a fresh COPY of the delegate, never the delegate field reference.The constrained type is a wrapper whose
delegatefield is its private, constraint-checked state. Returning that reference directly would alias it: a later in-place mutation of the promoted base value (base types like Integer are mutable) would silently corrupt the constrained value and bypass its constraint invariant. So we construct an independent base instance (new Base(delegate)) and return that. SeeConstrainedTypeInstrs.copyBaseValue(List, String, DebugInfo).
-