2024-08-08 13:28:25 -07:00
|
|
|
|
{-# OPTIONS --guardedness #-}
|
2024-03-11 13:07:42 -07:00
|
|
|
|
module Main where
|
|
|
|
|
|
2025-01-05 19:38:55 -08:00
|
|
|
|
open import Language hiding (_++_)
|
2024-03-11 13:07:42 -07:00
|
|
|
|
open import Data.Vec using (Vec; _∷_; [])
|
|
|
|
|
open import IO
|
|
|
|
|
open import Level using (0ℓ)
|
2025-01-05 19:38:55 -08:00
|
|
|
|
open import Data.String using (_++_)
|
|
|
|
|
import Analysis.Constant as ConstantAnalysis
|
|
|
|
|
import Analysis.Sign as SignAnalysis
|
2024-03-11 13:07:42 -07:00
|
|
|
|
|
2024-04-13 14:13:44 -07:00
|
|
|
|
testCode : Stmt
|
2024-03-11 13:07:42 -07:00
|
|
|
|
testCode =
|
2024-04-13 14:13:44 -07:00
|
|
|
|
⟨ "zero" ← (# 0) ⟩ then
|
|
|
|
|
⟨ "pos" ← ((` "zero") Expr.+ (# 1)) ⟩ then
|
|
|
|
|
⟨ "neg" ← ((` "zero") Expr.- (# 1)) ⟩ then
|
|
|
|
|
⟨ "unknown" ← ((` "pos") Expr.+ (` "neg")) ⟩
|
2024-03-11 13:07:42 -07:00
|
|
|
|
|
2024-05-08 23:30:23 -07:00
|
|
|
|
testCodeCond₁ : Stmt
|
|
|
|
|
testCodeCond₁ =
|
|
|
|
|
⟨ "var" ← (# 1) ⟩ then
|
|
|
|
|
if (` "var") then (
|
|
|
|
|
⟨ "var" ← ((` "var") Expr.+ (# 1)) ⟩
|
|
|
|
|
) else (
|
|
|
|
|
⟨ "var" ← ((` "var") Expr.- (# 1)) ⟩ then
|
|
|
|
|
⟨ "var" ← (# 1) ⟩
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
testCodeCond₂ : Stmt
|
|
|
|
|
testCodeCond₂ =
|
|
|
|
|
⟨ "var" ← (# 1) ⟩ then
|
|
|
|
|
if (` "var") then (
|
|
|
|
|
⟨ "x" ← (# 1) ⟩
|
|
|
|
|
) else (
|
|
|
|
|
⟨ noop ⟩
|
|
|
|
|
)
|
|
|
|
|
|
2024-03-11 13:07:42 -07:00
|
|
|
|
testProgram : Program
|
|
|
|
|
testProgram = record
|
2024-04-13 14:13:44 -07:00
|
|
|
|
{ rootStmt = testCode
|
2024-03-11 13:07:42 -07:00
|
|
|
|
}
|
|
|
|
|
|
2025-01-05 19:38:55 -08:00
|
|
|
|
open SignAnalysis.WithProg testProgram using (analyze-correct) renaming (output to output-Sign)
|
|
|
|
|
open ConstantAnalysis.WithProg testProgram using (analyze-correct) renaming (output to output-Const)
|
2024-03-11 13:07:42 -07:00
|
|
|
|
|
2025-01-05 19:38:55 -08:00
|
|
|
|
main = run {0ℓ} (putStrLn (output-Const ++ "\n" ++ output-Sign))
|