001package gudusoft.gsqlparser.analyzer.v2;
002
003import gudusoft.gsqlparser.ir.bound.BoundProgram;
004import gudusoft.gsqlparser.ir.logical.LogicalProgram;
005
006/**
007 * Complete IR program containing results from all three IR phases.
008 * <p>
009 * Phase A only populates the BoundProgram. Join-analysis slice 174 (S13)
010 * adds an optional {@link LogicalProgram} slot (populated only when the
011 * Logical Phase 2 is enabled and a builder is supplied; null otherwise).
012 * FlowBundle will be added in a later phase.
013 */
014public class IRProgram {
015
016    private final BoundProgram boundProgram;
017    private final LogicalProgram logicalProgram;
018
019    // Phase C addition (null until implemented):
020    // private final FlowBundle flowBundle;
021
022    public IRProgram(BoundProgram boundProgram) {
023        this(boundProgram, null);
024    }
025
026    /**
027     * Full constructor (slice 174). {@code logicalProgram} is null when the
028     * Logical Phase 2 did not run.
029     */
030    public IRProgram(BoundProgram boundProgram, LogicalProgram logicalProgram) {
031        this.boundProgram = boundProgram;
032        this.logicalProgram = logicalProgram;
033    }
034
035    public BoundProgram getBoundProgram() { return boundProgram; }
036
037    /** The Logical IR program, or {@code null} when Phase 2 did not run. */
038    public LogicalProgram getLogicalProgram() { return logicalProgram; }
039
040    @Override
041    public String toString() {
042        return "IRProgram{bound=" + boundProgram
043                + (logicalProgram != null ? ", logical=" + logicalProgram : "") + "}";
044    }
045}