Skip to content

Commit

Permalink
Merge pull request #175 from GaloisInc/part-llvm-val
Browse files Browse the repository at this point in the history
Export more PartLLVMVal functionality.
  • Loading branch information
andreistefanescu committed Mar 8, 2019
2 parents 5ddec64 + 7ba2733 commit 4dac1b6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
2 changes: 2 additions & 0 deletions crucible-llvm/src/Lang/Crucible/LLVM/MemModel.hs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ module Lang.Crucible.LLVM.MemModel
, constToLLVMVal
, constToLLVMValP
, ptrMessage
, Partial.PartLLVMVal
, pattern Partial.PartLLVMVal
, Partial.assertSafe

-- * Storage types
Expand Down
14 changes: 10 additions & 4 deletions crucible-llvm/src/Lang/Crucible/LLVM/MemModel/Partial.hs
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,14 @@ data MemoryLoadError sym =
| Other -- TODO: eliminate this constructor, replace with more specific messages
deriving (Generic)

ppMemoryLoadError :: IsSymInterface sym => sym -> MemoryLoadError sym -> Doc
ppMemoryLoadError sym =
instance IsSymInterface sym => Pretty (MemoryLoadError sym) where
pretty = ppMemoryLoadError

instance IsSymInterface sym => Show (MemoryLoadError sym) where
show = show . ppMemoryLoadError

ppMemoryLoadError :: IsSymInterface sym => MemoryLoadError sym -> Doc
ppMemoryLoadError =
\case
TypeMismatch ty1 ty2 ->
"Type mismatch: "
Expand All @@ -123,7 +129,7 @@ ppMemoryLoadError sym =
vcat [ "Operation failed due to previous errors: "
, text (unpack txt)
]
<$$> indent 2 (vcat (map (ppMemoryLoadError sym) errs))
<$$> indent 2 (vcat (map ppMemoryLoadError errs))
ApplyViewFail vw ->
"Failure when applying value view" <+> text (show vw)
Invalid ty ->
Expand Down Expand Up @@ -184,7 +190,7 @@ assertSafe :: (IsSymInterface sym)
assertSafe sym (NoErr v) = Safety.assertSafe (Proxy :: Proxy (LLVM arch)) sym v
assertSafe sym (Err e) = do
let msg = unlines [ "Error during memory load: "
, show (ppMemoryLoadError sym e)
, show (ppMemoryLoadError e)
]
addFailedAssertion sym $ AssertFailureSimError msg

Expand Down

0 comments on commit 4dac1b6

Please sign in to comment.