Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tweak the term model to avoid a panic situation #1368

Merged
merged 2 commits into from
Jul 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion saw-core-aig/src/Verifier/SAW/Simulator/BitBlast.hs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,8 @@ pure3 f x y z = pure (f x y z)
prims :: AIG.IsAIG l g => g s -> Prims.BasePrims (BitBlast (l s))
prims be =
Prims.BasePrims
{ Prims.bpAsBool = AIG.asConstant be
{ Prims.bpIsSymbolicEvaluator = True
, Prims.bpAsBool = AIG.asConstant be
-- Bitvectors
, Prims.bpUnpack = pure1 vFromLV
, Prims.bpPack = pure1 lvFromV
Expand Down
3 changes: 2 additions & 1 deletion saw-core-sbv/src/Verifier/SAW/Simulator/SBV.hs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ pure3 f x y z = pure (f x y z)
prims :: Prims.BasePrims SBV
prims =
Prims.BasePrims
{ Prims.bpAsBool = svAsBool
{ Prims.bpIsSymbolicEvaluator = True
, Prims.bpAsBool = svAsBool
, Prims.bpUnpack = svUnpack
, Prims.bpPack = pure1 symFromBits
, Prims.bpBvAt = pure2 svAt
Expand Down
3 changes: 2 additions & 1 deletion saw-core-what4/src/Verifier/SAW/Simulator/What4.hs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,8 @@ prims :: forall sym.
Sym sym => sym -> Prims.BasePrims (What4 sym)
prims sym =
Prims.BasePrims
{ Prims.bpAsBool = W.asConstantPred
{ Prims.bpIsSymbolicEvaluator = True
, Prims.bpAsBool = W.asConstantPred
-- Bitvectors
, Prims.bpUnpack = SW.bvUnpackBE sym
, Prims.bpPack = SW.bvPackBE sym
Expand Down
7 changes: 6 additions & 1 deletion saw-core/src/Verifier/SAW/Simulator.hs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import Prelude hiding (mapM)
import Control.Applicative ((<$>))
#endif
import Control.Monad (foldM, liftM)
--import Control.Monad.IO.Class
import Control.Monad.Trans.Except
import Control.Monad.Trans.Maybe
import Control.Monad.Fix (MonadFix(mfix))
import Control.Monad.Identity (Identity)
Expand Down Expand Up @@ -624,6 +624,11 @@ evalPrim fallback pn = loop [] (primType pn)
Just v -> loop ((ready x',t):env) tp' (f v)
_ -> fallback msg ((ready x',t):env) tp'

loop env tp (Prims.PrimExcept m) =
runExceptT m >>= \case
Right v -> pure v
Left msg -> fallback msg env tp

loop _env _tp (Prims.Prim m) = m
loop _env _tp (Prims.PrimValue v) = pure v

Expand Down
3 changes: 2 additions & 1 deletion saw-core/src/Verifier/SAW/Simulator/Concrete.hs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ ite b x y = if b then x else y
prims :: Prims.BasePrims Concrete
prims =
Prims.BasePrims
{ Prims.bpAsBool = Just
{ Prims.bpIsSymbolicEvaluator = False
, Prims.bpAsBool = Just
, Prims.bpUnpack = pure1 Prim.unpackBitVector
, Prims.bpPack = pure1 Prim.packBitVector
, Prims.bpBvAt = pure2 Prim.bvAt
Expand Down
Loading