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, 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).
-
Field Summary
Fields inherited from class AbstractGenerator
constantCopyOnAccessLoader, debugInfoCreator, instructionBuilder, MAX_MESSAGE_LENGTH, stackContext, synthesisedCallMetaData, typeNameOrException -
Constructor Summary
ConstructorsConstructorDescriptionConstructorCallProcessor(IRGenerationContext stackContext, VariableMemoryManagement variableMemoryManagement, ParameterPromotionProcessor parameterPromotionProcessor) -
Method Summary
Modifier and TypeMethodDescriptionprocessChainStart(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().voidprocessConstructorCall(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.
-
Constructor Details
-
ConstructorCallProcessor
public ConstructorCallProcessor(IRGenerationContext stackContext, VariableMemoryManagement variableMemoryManagement, ParameterPromotionProcessor parameterPromotionProcessor)
-
-
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 symbolcallContext- The ANTLR call contextresultVariable- The variable to store the constructor resulttargetObject- The target object ("super", "this", or type name for new objects)instructions- The list to add generated instructions toexpressionProcessor- Function to process argument expressionsuseMemoryManagement- 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 symbolcallContext- The ANTLR call context that starts the chainresultVariable- The temp to hold the new objectinstructions- The list to add generated instructions toexpressionProcessor- Function to process argument expressions- Returns:
- the type of the new object, the receiver of the chain's first step
-