Skip to content

Commit 988a026

Browse files
authored
Merge pull request #1368 from GaloisInc/term-model-fix
Tweak the term model to avoid a panic situation
2 parents 701810c + 1bbcad4 commit 988a026

File tree

9 files changed

+162
-113
lines changed

9 files changed

+162
-113
lines changed

saw-core-aig/src/Verifier/SAW/Simulator/BitBlast.hs

+2-1
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,8 @@ pure3 f x y z = pure (f x y z)
170170
prims :: AIG.IsAIG l g => g s -> Prims.BasePrims (BitBlast (l s))
171171
prims be =
172172
Prims.BasePrims
173-
{ Prims.bpAsBool = AIG.asConstant be
173+
{ Prims.bpIsSymbolicEvaluator = True
174+
, Prims.bpAsBool = AIG.asConstant be
174175
-- Bitvectors
175176
, Prims.bpUnpack = pure1 vFromLV
176177
, Prims.bpPack = pure1 lvFromV

saw-core-sbv/src/Verifier/SAW/Simulator/SBV.hs

+2-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ pure3 f x y z = pure (f x y z)
105105
prims :: Prims.BasePrims SBV
106106
prims =
107107
Prims.BasePrims
108-
{ Prims.bpAsBool = svAsBool
108+
{ Prims.bpIsSymbolicEvaluator = True
109+
, Prims.bpAsBool = svAsBool
109110
, Prims.bpUnpack = svUnpack
110111
, Prims.bpPack = pure1 symFromBits
111112
, Prims.bpBvAt = pure2 svAt

saw-core-what4/src/Verifier/SAW/Simulator/What4.hs

+2-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,8 @@ prims :: forall sym.
161161
Sym sym => sym -> Prims.BasePrims (What4 sym)
162162
prims sym =
163163
Prims.BasePrims
164-
{ Prims.bpAsBool = W.asConstantPred
164+
{ Prims.bpIsSymbolicEvaluator = True
165+
, Prims.bpAsBool = W.asConstantPred
165166
-- Bitvectors
166167
, Prims.bpUnpack = SW.bvUnpackBE sym
167168
, Prims.bpPack = SW.bvPackBE sym

saw-core/src/Verifier/SAW/Simulator.hs

+6-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import Prelude hiding (mapM)
3535
import Control.Applicative ((<$>))
3636
#endif
3737
import Control.Monad (foldM, liftM)
38-
--import Control.Monad.IO.Class
38+
import Control.Monad.Trans.Except
3939
import Control.Monad.Trans.Maybe
4040
import Control.Monad.Fix (MonadFix(mfix))
4141
import Control.Monad.Identity (Identity)
@@ -624,6 +624,11 @@ evalPrim fallback pn = loop [] (primType pn)
624624
Just v -> loop ((ready x',t):env) tp' (f v)
625625
_ -> fallback msg ((ready x',t):env) tp'
626626

627+
loop env tp (Prims.PrimExcept m) =
628+
runExceptT m >>= \case
629+
Right v -> pure v
630+
Left msg -> fallback msg env tp
631+
627632
loop _env _tp (Prims.Prim m) = m
628633
loop _env _tp (Prims.PrimValue v) = pure v
629634

saw-core/src/Verifier/SAW/Simulator/Concrete.hs

+2-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,8 @@ ite b x y = if b then x else y
132132
prims :: Prims.BasePrims Concrete
133133
prims =
134134
Prims.BasePrims
135-
{ Prims.bpAsBool = Just
135+
{ Prims.bpIsSymbolicEvaluator = False
136+
, Prims.bpAsBool = Just
136137
, Prims.bpUnpack = pure1 Prim.unpackBitVector
137138
, Prims.bpPack = pure1 Prim.packBitVector
138139
, Prims.bpBvAt = pure2 Prim.bvAt

0 commit comments

Comments
 (0)