Class AbstractDfnGenerator
java.lang.Object
org.ek9lang.compiler.phase7.AbstractDfnGenerator
- Direct Known Subclasses:
AggregateDfnGenerator, ApplicationDfnGenerator, ConstrainedTypeDfnGenerator, DynamicFunctionDfnGenerator, EnumerationDfnGenerator, FunctionDfnGenerator, ProgramDfnGenerator, TextBaseDfnGenerator, TextDfnGenerator
Acts as a base for the main construct definitions.
As there are lots of common processing aspects across constructs and, they are
only really very focussed on IR generation (and not reusable elsewhere) hence defined in this base.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final GeneratorSetprotected final NotImplicitSuperprotected final OperationDfnGeneratorprotected final IRGenerationContextprotected final SynthesisedCallMetaDataTHE shared source of call metadata for every synthesised call site - use this rather than constructing one per generator (fifteen of them had, before this was hoisted), and never hand-write aCallMetaDataDetailstuple. -
Constructor Summary
ConstructorsConstructorDescriptionAbstractDfnGenerator(IRGenerationContext stackContext) Primary constructor using stack context - the single source of truth. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidcreateEmptyInitOperation(IRConstruct construct, IScope scope, String methodName) THE empty init operation (_c_initor_i_init): nothing to do but return, as for a program, an application, a dynamic function's instance init (its captures are constructor arguments) and the abstract text base.protected voidcreateInitOperation(IRConstruct construct, IScope aggregateSymbol, ISymbol superType) Create _c_init operation for class/static initialization.protected voidcreateInstanceInitOperation(IRConstruct construct, IScope symbol, EK9Parser.AggregatePartsContext ctx) Create _i_init operation for instance initialization.protected ParsedModuleGet the parsed module from stack context - the single source of truth.protected OperationInstrnewSyntheticInitOperation(IScope scope, String methodName) protected voidprocessAsMethodOrOperator(OperationInstr operation, EK9Parser.OperationDetailsContext ctx) protected voidprocessAsMethodOrOperator(OperationInstr operation, EK9Parser.OperationDetailsContext ctx, List<IRInstr> beforeInstanceInit) processAsMethodOrOperator(OperationInstr, EK9Parser.OperationDetailsContext), withbeforeInstanceInit- an explicit capture constructor's capture stores (CaptureStores) - just after the constructor's construction call, before its_i_init.Process all properties for instance initialization - THE sharedPropertyInitialisers.protected voidprocessSyntheticConstructor(OperationInstr operation) Process a synthetic constructor (default constructor created by earlier phases).protected voidprocessSyntheticConstructor(OperationInstr operation, List<IRInstr> beforeInstanceInit) processSyntheticConstructor(OperationInstr), withbeforeInstanceInit- a dynamic function's or a dynamic class's capture stores (CaptureStores) - between the super call and_i_init.protected voidprocessSyntheticConstructor(OperationInstr operation, IScopedSymbol superType) A synthetic constructor whose super the caller names.
-
Field Details
-
notImplicitSuper
-
operationDfnGenerator
-
stackContext
-
synthesisedCallMetaData
THE shared source of call metadata for every synthesised call site - use this rather than constructing one per generator (fifteen of them had, before this was hoisted), and never hand-write aCallMetaDataDetailstuple. See its javadoc for the two honest sources. -
generators
-
-
Constructor Details
-
AbstractDfnGenerator
AbstractDfnGenerator(IRGenerationContext stackContext) Primary constructor using stack context - the single source of truth. Creates the complete generator tree once for efficient reuse via static factory.
-
-
Method Details
-
getParsedModule
Get the parsed module from stack context - the single source of truth. -
processAsMethodOrOperator
protected void processAsMethodOrOperator(OperationInstr operation, EK9Parser.OperationDetailsContext ctx) -
processAsMethodOrOperator
protected void processAsMethodOrOperator(OperationInstr operation, EK9Parser.OperationDetailsContext ctx, List<IRInstr> beforeInstanceInit) processAsMethodOrOperator(OperationInstr, EK9Parser.OperationDetailsContext), withbeforeInstanceInit- an explicit capture constructor's capture stores (CaptureStores) - just after the constructor's construction call, before its_i_init. -
newSyntheticInitOperation
-
createInitOperation
protected void createInitOperation(IRConstruct construct, IScope aggregateSymbol, ISymbol superType) Create _c_init operation for class/static initialization. This runs once per class loading. -
createInstanceInitOperation
protected void createInstanceInitOperation(IRConstruct construct, IScope symbol, EK9Parser.AggregatePartsContext ctx) Create _i_init operation for instance initialization. This handles property REFERENCE declarations and immediate initializations. -
createEmptyInitOperation
THE empty init operation (_c_initor_i_init): nothing to do but return, as for a program, an application, a dynamic function's instance init (its captures are constructor arguments) and the abstract text base. Use this, never a fifth hand-built copy. -
processPropertiesForInstanceInit
Process all properties for instance initialization - THE sharedPropertyInitialisers. -
processSyntheticConstructor
Process a synthetic constructor (default constructor created by earlier phases). Implements proper constructor inheritance chain: 1. Call super constructor (if not implicit base class) 2. Call own class's _i_init method 3. Return thisThe super is THE decision
ConstructionStepsmakes - for an aggregate the one the phase-5 call graph models, for a function construct its super function - never a caller's (IR tidy DFN-7). -
processSyntheticConstructor
protected void processSyntheticConstructor(OperationInstr operation, List<IRInstr> beforeInstanceInit) processSyntheticConstructor(OperationInstr), withbeforeInstanceInit- a dynamic function's or a dynamic class's capture stores (CaptureStores) - between the super call and_i_init. -
processSyntheticConstructor
A synthetic constructor whose super the caller names. OnlyConstrainedTypeDfnGeneratorstill calls this (IR lane D's file, left for that lane); every other construct takes the derived form above (DFN-7).
-