java.lang.Object
com.darkcollective.relix.semantic.internal.IrReport

public final class IrReport extends Object
Produces a concise human-readable IR report from a SemanticModel.

The report is plain UTF-8 text (no BOM), at most 80 characters wide per line, and contains these sections:

  1. Header — namespace and key for all codes used.
  2. Symbols — every registered symbol, sorted alphabetically, with its kind code and schema/signature.
  3. Relationships — the schema graph's edges, one line per relationship with its endpoints, any non-default bounds, and an origin tag for non-declared edges. Omitted entirely when the graph is empty, so pre-existing reports are unchanged.
  4. Expression Trees — one indented ASCII tree per named view (QueryRelationSymbol), rendered in alphabetical order.
  5. Root Queries — the ordered query statements from the root file; inline expression queries expand their tree.

Code keys

   kind: SRC=source  INL=inline  SYS=system  QR=view  DB=database
         FN=function  TVF=table-fn  LIT=truth-literal
   type: N=number  S=string  B=boolean  ?=any  [x]=array  {…}=struct
         D=date  T=time  TS=timestamp  DUR=duration
   mat:  [bag]=bag  [set]=dedup-set  [sort]=sorted  (stream=no label)
 

Materialisation tags ([bag], [set], [sort]) are appended to the node label in expression trees for operators that must accumulate all rows before emitting output. Streaming operators carry no tag. See MaterializationMode for the full mapping.

Lines that would exceed 80 characters are truncated with a trailing ….

Usage

   SemanticResult result = analyzer.analyze("script.relix");
   result.model().ifPresent(m -> System.out.print(IrReport.generate(m)));
 
  • Field Details

  • Method Details

    • generate

      public static String generate(SemanticModel model)
      Generates the IR report for model and returns it as a UTF-8 string. No BOM is included.
      Parameters:
      model - the semantic model to report on; must not be null
      Returns:
      the formatted report; never null or empty
    • generateFocused

      public static String generateFocused(SemanticModel model, Set<String> focus)
      Generates a focused IR report restricted to the relations named in focus — used by interactive tooling (the REPL :tree command) where the user names a single query and expects to see only its tree and the relations it actually uses, not every symbol in the script.

      The SYMBOLS and EXPRESSION TREES sections include only relations whose declared name is in focus (matched case-insensitively). Non-relation symbols (functions) are always omitted. The ROOT QUERIES section is unchanged — it already contains only the query the user asked about.

      Parameters:
      model - the semantic model to report on; must not be null
      focus - the set of relation names to include; must not be null
      Returns:
      the formatted report; never null or empty
    • referencedRelations

      public static Set<String> referencedRelations(RelNode root)
      Collects the names of every RelationNode leaf reachable from root. Relation references only ever appear as RelationNode leaves, so a recursive child walk (via nodeChildren(com.darkcollective.relix.ast.RelNode)) finds them all.
      Parameters:
      root - the root node of the tree; must not be null
      Returns:
      the referenced relation names, in first-seen order; never null