Class CompilerPhase

java.lang.Object
org.ek9lang.compiler.CompilerPhase
All Implemented Interfaces:
BiFunction<Workspace, CompilerFlags, CompilationPhaseResult>, CompilationStep
Direct Known Subclasses:
CodeGenerationAggregates, CodeGenerationApplications, CodeGenerationConstants, CodeGenerationPreparation, CodeOptimisation, IRAnalysis, IRGenerator, IROptimisation, ModuleDuplicateSymbolChecks, NonInferredTypeDefinition, Packaging, PackagingPostProcessing, PluginLinkage, PluginResolution, PostSymbolResolutionChecks, PreIntermediateRepresentationChecks, ReferenceChecks, SymbolDefinition, SymbolicAnalysis, SymbolResolution, TypeHierarchyChecks

public abstract class CompilerPhase extends Object implements CompilationStep
Marks the specific activity of a compiler phase. The phase and the compiler flags reach the compilable program through the driver (Ek9Compiler), which records each phase as entered before running it; components read them from the program during compilation.
  • Field Details

    • listener

      protected final Consumer<CompilationEvent> listener
    • reporter

      protected final CompilerReporter reporter
    • compilableProgramAccess

      protected final SharedThreadContext<CompilableProgram> compilableProgramAccess
    • modelFrozen

      protected final boolean modelFrozen
      Is the symbol model already complete and read-only by the time this phase runs?

      A plain final field, fixed when the phase is constructed, because the answer is a static property of where the phase sits in the pipeline - see CompilationPhase.isModelFrozen(). There is deliberately no setter and no flag to maintain: nothing can set it late, clear it early, or forget to. A post-freeze phase reads a model nobody writes to, so it needs neither the lock nor any other synchronisation, and all of its threads may read concurrently.

  • Constructor Details

  • Method Details

    • doApply

      protected abstract boolean doApply(Workspace workspace, CompilerFlags compilerFlags)
      Do the compilation phase.
    • phase

      public CompilationPhase phase()
      Description copied from interface: CompilationStep
      The phase this step runs.
      Specified by:
      phase in interface CompilationStep
    • apply

      public CompilationPhaseResult apply(Workspace workspace, CompilerFlags compilerFlags)
      Specified by:
      apply in interface BiFunction<Workspace, CompilerFlags, CompilationPhaseResult>
    • timedStage

      protected void timedStage(String stage, Runnable work)
      Run one stage of this phase and, when verbose (-v), report it as one line: <PHASE>_STAGE.<stage> duration 12.345 ms cpu ... busyCores ... alloc ... gc ... - see ResourceSnapshot. PRE_IR_CHECKS reports as PRE_IR_STAGE, the name the scale tooling and its baselines already use. The stage name contains a '.' and lower-case letters, so a parser keyed on the all-caps phase-name line never mistakes a stage for a phase.

      Permanent and free when not verbose, so a timing run never needs a patched compiler (it replaced the reversible tools/scale/patch_phase5_timing.py, retired 2026-10-01). Formatted with Locale.ROOT so a comma-decimal locale cannot break the parsers.

    • getParsedModuleForSource

      protected ParsedModule getParsedModuleForSource(CompilableSource source)