Class ConstructorCallProcessor
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).
-
Field Summary
Fields inherited from class AbstractGenerator
stackContext, symbolTypeOrException, typeNameOrException, variableNameForIR -
Constructor Summary
ConstructorsConstructorDescriptionConstructorCallProcessor(IRGenerationContext stackContext, CallArguments callArguments, ParameterPromotionProcessor parameterPromotionProcessor, Function<ExprProcessingDetails, List<IRInstr>> expressionProcessor) -
Method Summary
Modifier and TypeMethodDescriptionprocessChainStart(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().voidprocessConstructorCall(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.voidprocessDelegatingConstructorCall(CallSymbol callSymbol, EK9Parser.CallContext callContext, String resultVariable, String thisOrSuper, List<IRInstr> instructions) Process a delegating constructor call -this(...)orsuper(...)- whose target object is the receiver being constructed.
-
Constructor Details
-
ConstructorCallProcessor
public ConstructorCallProcessor(IRGenerationContext stackContext, CallArguments callArguments, ParameterPromotionProcessor parameterPromotionProcessor, Function<ExprProcessingDetails, List<IRInstr>> expressionProcessor)
-
-
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 symbolcallContext- The ANTLR call contextresultVariable- The variable to store the constructor resultinstructions- 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(...)orsuper(...)- whose target object is the receiver being constructed.- Parameters:
callSymbol- The resolved call symbolcallContext- The ANTLR call contextresultVariable- The variable to store the constructor resultthisOrSuper-IRConstants.THISorIRConstants.SUPERinstructions- 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 symbolcallContext- The ANTLR call context that starts the chainresultVariable- The temp to hold the new objectinstructions- The list to add generated instructions to- Returns:
- the type of the new object, the receiver of the chain's first step
-