Class AbstractDfnGenerator

java.lang.Object
org.ek9lang.compiler.phase7.AbstractDfnGenerator
Direct Known Subclasses:
AggregateDfnGenerator, ApplicationDfnGenerator, ConstrainedTypeDfnGenerator, DynamicFunctionDfnGenerator, EnumerationDfnGenerator, FunctionDfnGenerator, ProgramDfnGenerator, TextBaseDfnGenerator, TextDfnGenerator

abstract class AbstractDfnGenerator extends Object
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 Details

    • notImplicitSuper

      protected final NotImplicitSuper notImplicitSuper
    • operationDfnGenerator

      protected final OperationDfnGenerator operationDfnGenerator
    • stackContext

      protected final IRGenerationContext stackContext
    • synthesisedCallMetaData

      protected final SynthesisedCallMetaData 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 a CallMetaDataDetails tuple. See its javadoc for the two honest sources.
    • generators

      protected final GeneratorSet 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

      protected ParsedModule 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), with beforeInstanceInit - an explicit capture constructor's capture stores (CaptureStores) - just after the constructor's construction call, before its _i_init.
    • newSyntheticInitOperation

      protected OperationInstr newSyntheticInitOperation(IScope scope, String methodName)
    • 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

      protected void createEmptyInitOperation(IRConstruct construct, IScope scope, String methodName)
      THE empty init operation (_c_init or _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

      protected List<IRInstr> processPropertiesForInstanceInit(EK9Parser.AggregatePartsContext ctx)
      Process all properties for instance initialization - THE shared PropertyInitialisers.
    • processSyntheticConstructor

      protected void processSyntheticConstructor(OperationInstr operation)
      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 this

      The super is THE decision ConstructionSteps makes - 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), with beforeInstanceInit - a dynamic function's or a dynamic class's capture stores (CaptureStores) - between the super call and _i_init.
    • processSyntheticConstructor

      protected void processSyntheticConstructor(OperationInstr operation, IScopedSymbol superType)
      A synthetic constructor whose super the caller names. Only ConstrainedTypeDfnGenerator still calls this (IR lane D's file, left for that lane); every other construct takes the derived form above (DFN-7).