Class ConstructorCallProcessor

java.lang.Object
org.ek9lang.compiler.phase7.generator.AbstractGenerator
org.ek9lang.compiler.phase7.generator.ConstructorCallProcessor

public final class ConstructorCallProcessor extends AbstractGenerator
THE constructor call: every source call that constructs an object is lowered here, and nowhere else.

That covers a standalone construction (ExprInstrGenerator, CallInstrGenerator, the throw statement, application registrations) AND a construction that STARTS an object-access chain (String(move).upperCase(), ObjectAccessInstrGenerator through processChainStart(CallSymbol, EK9Parser.CallContext, String, List, Function)). The decisions a constructor call needs are made here once: the argument evaluation and its ARC, the #^ promotion of each argument into its parameter slot (ParameterPromotionProcessor), the text-factory redirect (TextFactoryDispatch) and phase 5's statement-ownership decision. Never build a constructor CallDetails for a source call anywhere else: the chain start once did, without the promotion step, so String(Move.Rock).upperCase() compiled clean and failed at class load with a VerifyError (D29 in EK9_OPEN_COMPILER_DEFECTS.md).

  • Constructor Details

  • Method Details

    • processConstructorCall

      public void processConstructorCall(CallSymbol callSymbol, EK9Parser.CallContext callContext, String resultVariable, String targetObject, List<IRInstr> instructions, Function<ExprProcessingDetails, List<IRInstr>> expressionProcessor, boolean useMemoryManagement)
      Process a constructor call and generate appropriate IR instructions. This method consolidates all the common logic between expression and statement contexts.
      Parameters:
      callSymbol - The resolved call symbol
      callContext - The ANTLR call context
      resultVariable - The variable to store the constructor result
      targetObject - The target object ("super", "this", or type name for new objects)
      instructions - The list to add generated instructions to
      expressionProcessor - Function to process argument expressions
      useMemoryManagement - Whether to apply memory management to arguments
    • processChainStart

      public ISymbol processChainStart(CallSymbol callSymbol, EK9Parser.CallContext callContext, String resultVariable, List<IRInstr> instructions, Function<ExprProcessingDetails, List<IRInstr>> expressionProcessor)
      THE constructor call that STARTS an object-access chain - String(move).upperCase(), Holder(3).amount(), SomeText("en").message(). It is exactly the standalone constructor call (the same promotion, text-factory redirect, ownership and argument ARC); only each argument's evaluation carries its own debug info, as the chain's other steps do. The caller registers the result like any other chain step.
      Parameters:
      callSymbol - The resolved constructor call symbol
      callContext - The ANTLR call context that starts the chain
      resultVariable - The temp to hold the new object
      instructions - The list to add generated instructions to
      expressionProcessor - Function to process argument expressions
      Returns:
      the type of the new object, the receiver of the chain's first step