Skip to content

Commit

Permalink
Refactor: Move checkCompatibleTys, readMaybeType, firstPointsToReferent
Browse files Browse the repository at this point in the history
These will need to be accessible from
`SAWScript.Crucible.MIR.ResolveSetupValue` in a subsequent patch.
  • Loading branch information
RyanGlScott committed Nov 22, 2023
1 parent 0a6be48 commit 6234628
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
13 changes: 0 additions & 13 deletions src/SAWScript/Crucible/MIR/Override.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ module SAWScript.Crucible.MIR.Override
, learnCond
, matchArg
, decodeMIRVal
, firstPointsToReferent
) where

import qualified Control.Exception as X
Expand Down Expand Up @@ -150,18 +149,6 @@ enforceDisjointness cc loc ss =
, (_, Some q) <- ps
]

-- | @mir_points_to@ always creates a 'MirPointsTo' value with exactly one
-- referent on the right-hand side. As a result, this function should never
-- fail.
firstPointsToReferent ::
MonadFail m => [MS.SetupValue MIR] -> m (MS.SetupValue MIR)
firstPointsToReferent referents =
case referents of
[referent] -> pure referent
_ -> fail $
"Unexpected mir_points_to statement with " ++ show (length referents) ++
" referent(s)"

instantiateExtResolveSAWPred ::
SharedContext ->
MIRCrucibleContext ->
Expand Down
13 changes: 13 additions & 0 deletions src/SAWScript/Crucible/MIR/ResolveSetupValue.hs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ module SAWScript.Crucible.MIR.ResolveSetupValue
, equalValsPred
, checkCompatibleTys
, readMaybeType
, firstPointsToReferent
, mirAdtToTy
, findDefId
, findDefIdEither
Expand Down Expand Up @@ -952,6 +953,18 @@ readPartExprMaybe _sym (W4.PE p v)
| Just True <- W4.asConstantPred p = Just v
| otherwise = Nothing

-- | @mir_points_to@ always creates a 'MirPointsTo' value with exactly one
-- referent on the right-hand side. As a result, this function should never
-- fail.
firstPointsToReferent ::
MonadFail m => [MS.SetupValue MIR] -> m (MS.SetupValue MIR)
firstPointsToReferent referents =
case referents of
[referent] -> pure referent
_ -> fail $
"Unexpected mir_points_to statement with " ++ show (length referents) ++
" referent(s)"

-- | Construct an 'Mir.TyAdt' from an 'Mir.Adt'.
mirAdtToTy :: Mir.Adt -> Mir.Ty
mirAdtToTy adt =
Expand Down

0 comments on commit 6234628

Please sign in to comment.