import Spa.Analysis.Sign
import Spa.Analysis.Constant

namespace Spa

def testCode : Stmt :=
  .andThen (.basic (.assign "zero" (.num 0)))
    (.andThen (.basic (.assign "pos" (.add (.var "zero") (.num 1))))
      (.andThen (.basic (.assign "neg" (.sub (.var "zero") (.num 1))))
        (.basic (.assign "unknown" (.add (.var "pos") (.var "neg"))))))

def testCodeCond₁ : Stmt :=
  .andThen (.basic (.assign "var" (.num 1)))
    (.ifElse (.var "var")
      (.basic (.assign "var" (.add (.var "var") (.num 1))))
      (.andThen (.basic (.assign "var" (.sub (.var "var") (.num 1))))
        (.basic (.assign "var" (.num 1)))))

def testCodeCond₂ : Stmt :=
  .andThen (.basic (.assign "var" (.num 1)))
    (.ifElse (.var "var")
      (.basic (.assign "x" (.num 1)))
      (.basic .noop))

def testProgram : Program := ⟨testCode⟩

end Spa

def main : IO Unit :=
  IO.println (Spa.ConstAnalysis.output Spa.testProgram ++ "\n" ++
              Spa.SignAnalysis.output Spa.testProgram)
