Class CompilationContext

java.lang.Object
ca.mcscert.jpipe.compiler.model.CompilationContext

public final class CompilationContext extends Object
Mutable context threaded through every step of a compilation pipeline.

Carries the source file path (for error reporting) and a Diagnostic bag that steps may append to without aborting the pipeline immediately. Use hasFatalErrors() to decide whether to stop early, and diagnostics() to inspect the full list at the end.

  • Field Details

    • STAT_COMMANDS_TOTAL

      public static final String STAT_COMMANDS_TOTAL
      Total number of commands in the action list.
      See Also:
    • STAT_COMMANDS_MACROS

      public static final String STAT_COMMANDS_MACROS
      Number of macro commands in the action list.
      See Also:
    • STAT_COMMANDS_DEFERRALS

      public static final String STAT_COMMANDS_DEFERRALS
      Total number of execution-engine deferral rounds.
      See Also:
  • Constructor Details

    • CompilationContext

      public CompilationContext(String sourcePath)
  • Method Details

    • sourcePath

      public String sourcePath()
      Path to the input file being compiled.
    • report

      public void report(Diagnostic diagnostic)
      Append a pre-built diagnostic.
    • error

      public void error(String message)
      Convenience: append a non-fatal ERROR diagnostic.
    • error

      public void error(int line, int column, String message)
      Convenience: append a non-fatal ERROR diagnostic with source location.
    • fatal

      public void fatal(String message)
      Convenience: append a FATAL diagnostic.
    • fatal

      public void fatal(int line, int column, String message)
      Convenience: append a FATAL diagnostic with source location.
    • hasErrors

      public boolean hasErrors()
      True if any ERROR or FATAL diagnostic has been reported.
    • hasFatalErrors

      public boolean hasFatalErrors()
      True if any FATAL diagnostic has been reported.
    • diagnostics

      public List<Diagnostic> diagnostics()
      Unmodifiable view of all diagnostics in report order.
    • recordStat

      public void recordStat(String key, long value)
      Record a named numeric statistic produced during compilation.
    • stats

      public Map<String,Long> stats()
      Unmodifiable view of all recorded statistics in insertion order.
    • recordActions

      public void recordActions(List<ExecutedAction> actions)
      Record the ordered list of actions that occurred during interpretation.
    • executedActions

      public List<ExecutedAction> executedActions()
      Ordered list of actions that occurred during interpretation.
    • markDiagnosticsRendered

      public void markDiagnosticsRendered()
      Signal that a pipeline step has already rendered the diagnostics (e.g. DiagnosticReport), so ChainCompiler should not print them a second time.
    • diagnosticsRendered

      public boolean diagnosticsRendered()
      True when a step has already rendered the diagnostics.