Class Scenario2AggregateWrapperGenerator

java.lang.Object
org.ek9lang.compiler.phase7.Scenario2AggregateWrapperGenerator

final class Scenario2AggregateWrapperGenerator extends Object
Generates IR for Scenario 2 aggregate wrapper constructors, delegation, and function-accepting methods.

Handles:

  • Constructor operations - create delegate instance and store in field
  • Wrapping constructor - accepts existing delegate for return-type wrapping
  • Standard delegation - load delegate, call method, handle return type wrapping/casting
  • Function-accepting methods - inline implementations for whenPresent/whenOk/whenError
  • Constructor Details

  • Method Details

    • isCallbackInvocationMethod

      boolean isCallbackInvocationMethod(MethodSymbol method, Scenario2WrapperHelper helper)
      Detect callback-invocation methods: methods whose contract is "invoke the supplied function on the contained value".

      Structural signature: at least one parameter is a parameterised function type (Acceptor/Consumer/Predicate/...) and the method's return type is void. The void return is the discriminator that separates callback methods (Optional.whenPresent, Result.whenOk, Result.whenError — all void) from configuration methods that take a function as state (PriorityQueue.withComparator returns a new PriorityQueue and must go through standard delegation).

    • generateConstructorOperation

      void generateConstructorOperation(IRConstruct construct, MethodSymbol method, String baseTypeName)
      Generate constructor that creates the delegate instance.
    • generateWrappingConstructor

      void generateWrappingConstructor(IRConstruct construct, AggregateSymbol aggregateSymbol, String baseTypeName)
      Generate wrapping constructor that takes the base type as parameter.
    • generateDelegationOperation

      void generateDelegationOperation(IRConstruct construct, MethodSymbol method, String baseTypeName)
      Generate a delegation operation for a single method.
    • generateFunctionAcceptingMethod

      void generateFunctionAcceptingMethod(IRConstruct construct, MethodSymbol method, String baseTypeName)
      Generate inline implementation for methods that accept function wrapper types.