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)). 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, List<IRInstr> instructions)
      Process a constructor call that creates a new object and generate appropriate IR instructions - the owner is the (resolved) type of the constructor itself. Statement and expression contexts both come here (EXPR-3).
      Parameters:
      callSymbol - The resolved call symbol
      callContext - The ANTLR call context
      resultVariable - The variable to store the constructor result
      instructions - The list to add generated instructions to
    • processDelegatingConstructorCall

      public void processDelegatingConstructorCall(CallSymbol callSymbol, EK9Parser.CallContext callContext, String resultVariable, String thisOrSuper, List<IRInstr> instructions)
      Process a delegating constructor call - this(...) or super(...) - whose target object is the receiver being constructed.
      Parameters:
      callSymbol - The resolved call symbol
      callContext - The ANTLR call context
      resultVariable - The variable to store the constructor result
      thisOrSuper - IRConstants.THIS or IRConstants.SUPER
      instructions - The list to add generated instructions to
    • processChainStart

      public ISymbol processChainStart(CallSymbol callSymbol, EK9Parser.CallContext callContext, String resultVariable, List<IRInstr> instructions)
      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
      Returns:
      the type of the new object, the receiver of the chain's first step