Skip to content

Commit 422374c

Browse files
committed
Move Pointer' type family to SAWScript.Crucible.Common.Setup.Value
This is purely a refactor. This will become useful in a subsequent commit in order to avoid import cycles.
1 parent a046293 commit 422374c

File tree

8 files changed

+37
-13
lines changed

8 files changed

+37
-13
lines changed

src/SAWScript/Crucible/Common/Override.hs

+4-6
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Stability : provisional
2020

2121
module SAWScript.Crucible.Common.Override
2222
( Pointer
23-
, Pointer'
23+
, MS.Pointer'
2424
, OverrideState
2525
, OverrideState'(..)
2626
, osAsserts
@@ -68,7 +68,6 @@ import qualified Control.Monad.Fail as Fail
6868
import Control.Monad.Trans.Except
6969
import Control.Monad.Trans.Class
7070
import Control.Monad.IO.Class
71-
import Data.Kind (Type)
7271
import qualified Data.Map as Map
7372
import Data.Map (Map)
7473
import Data.Set (Set)
@@ -96,6 +95,7 @@ import qualified What4.ProgramLoc as W4
9695
import SAWScript.Exceptions
9796
import SAWScript.Crucible.Common (Sym)
9897
import SAWScript.Crucible.Common.MethodSpec as MS
98+
import SAWScript.Crucible.Common.Setup.Value as MS
9999

100100
-- TODO, not sure this is the best place for this definition
101101
type MetadataMap =
@@ -106,13 +106,11 @@ type MetadataMap =
106106

107107
type LabeledPred sym = W4.LabeledPred (W4.Pred sym) Crucible.SimError
108108

109-
type family Pointer' ext sym :: Type
110-
111-
type Pointer ext = Pointer' ext Sym
109+
type Pointer ext = MS.Pointer' ext Sym
112110

113111
data OverrideState' sym ext = OverrideState
114112
{ -- | Substitution for memory allocations
115-
_setupValueSub :: Map AllocIndex (Pointer' ext sym)
113+
_setupValueSub :: Map AllocIndex (MS.Pointer' ext sym)
116114

117115
-- | Substitution for SAW Core external constants
118116
, _termSub :: Map VarIndex Term

src/SAWScript/Crucible/Common/Setup/Value.hs

+7
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ module SAWScript.Crucible.Common.Setup.Value
5959

6060
, MethodId
6161
, Codebase
62+
63+
, Pointer'
6264
) where
6365

6466
import Data.Constraint (Constraint)
@@ -200,3 +202,8 @@ type family MethodId ext :: Type
200202
--
201203
-- Examples: An 'LLVMModule', a Java 'Codebase'
202204
type family Codebase ext :: Type
205+
206+
--------------------------------------------------------------------------------
207+
-- *** Pointers
208+
209+
type family Pointer' ext sym :: Type

src/SAWScript/Crucible/JVM/Override.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ import qualified SAWScript.Crucible.Common.Override as Ov (getSymInterface)
109109
import qualified SAWScript.Crucible.Common.MethodSpec as MS
110110
import SAWScript.Crucible.JVM.MethodSpecIR
111111
import SAWScript.Crucible.JVM.ResolveSetupValue
112+
import SAWScript.Crucible.JVM.Setup.Value ()
112113
import SAWScript.Options
113114
import SAWScript.Panic
114115
import SAWScript.Utils (handleException)
@@ -121,7 +122,6 @@ type SetupValue = MS.SetupValue CJ.JVM
121122
type CrucibleMethodSpecIR = MS.CrucibleMethodSpecIR CJ.JVM
122123
type StateSpec = MS.StateSpec CJ.JVM
123124
type SetupCondition = MS.SetupCondition CJ.JVM
124-
type instance Pointer' CJ.JVM Sym = JVMRefVal
125125

126126
-- TODO: Improve?
127127
ppJVMVal :: JVMVal -> PP.Doc ann

src/SAWScript/Crucible/JVM/ResolveSetupValue.hs

+1-2
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ import SAWScript.Crucible.Common.MethodSpec (AllocIndex(..))
6868

6969
import SAWScript.Panic
7070
import SAWScript.Crucible.JVM.MethodSpecIR
71+
import SAWScript.Crucible.JVM.Setup.Value (JVMRefVal)
7172
import qualified SAWScript.Crucible.Common.MethodSpec as MS
7273
import SAWScript.Crucible.Common.ResolveSetupValue (resolveBoolTerm)
7374

@@ -82,8 +83,6 @@ instance Show JVMVal where
8283
show (IVal _) = "IVal"
8384
show (LVal _) = "LVal"
8485

85-
type JVMRefVal = Crucible.RegValue Sym CJ.JVMRefType
86-
8786
type SetupValue = MS.SetupValue CJ.JVM
8887

8988
data JVMTypeOfError

src/SAWScript/Crucible/JVM/Setup/Value.hs

+12-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ module, plus additional functionality) instead.
2828
{-# LANGUAGE StandaloneDeriving #-}
2929
{-# LANGUAGE TemplateHaskell #-}
3030
{-# LANGUAGE TypeFamilies #-}
31+
{-# LANGUAGE UndecidableInstances #-}
3132
{-# LANGUAGE ViewPatterns #-}
3233

3334
module SAWScript.Crucible.JVM.Setup.Value
@@ -47,6 +48,8 @@ module SAWScript.Crucible.JVM.Setup.Value
4748
, jccJVMContext
4849
, jccBackend
4950
, jccHandleAllocator
51+
52+
, JVMRefVal
5053
) where
5154

5255
import Control.Lens
@@ -55,6 +58,7 @@ import qualified Prettyprinter as PPL
5558
import qualified Lang.Crucible.FunctionHandle as Crucible (HandleAllocator)
5659

5760
-- crucible-jvm
61+
import qualified Lang.Crucible.Simulator as CS
5862
import qualified Lang.Crucible.JVM as CJ
5963
import qualified Lang.JVM.Codebase as CB
6064

@@ -65,7 +69,7 @@ import qualified Language.JVM.Parser as J
6569
import Verifier.SAW.TypedTerm (TypedTerm)
6670

6771
import SAWScript.Crucible.Common
68-
import qualified SAWScript.Crucible.Common.MethodSpec as MS
72+
import qualified SAWScript.Crucible.Common.Setup.Value as MS
6973

7074
--------------------------------------------------------------------------------
7175
-- ** Language features
@@ -148,3 +152,10 @@ data JVMCrucibleContext =
148152
makeLenses ''JVMCrucibleContext
149153

150154
type instance MS.CrucibleContext CJ.JVM = JVMCrucibleContext
155+
156+
--------------------------------------------------------------------------------
157+
-- *** Pointers
158+
159+
type instance MS.Pointer' CJ.JVM Sym = JVMRefVal
160+
161+
type JVMRefVal = CS.RegValue Sym CJ.JVMRefType

src/SAWScript/Crucible/LLVM/Override.hs

+1-2
Original file line numberDiff line numberDiff line change
@@ -134,14 +134,13 @@ import SAWScript.Crucible.Common.Override hiding (getSymInterface)
134134
import qualified SAWScript.Crucible.Common.Override as Ov (getSymInterface)
135135
import SAWScript.Crucible.LLVM.MethodSpecIR
136136
import SAWScript.Crucible.LLVM.ResolveSetupValue
137+
import SAWScript.Crucible.LLVM.Setup.Value ()
137138
import SAWScript.Options
138139
import SAWScript.Panic
139140
import SAWScript.Utils (bullets, handleException)
140141

141142
type LabeledPred sym = W4.LabeledPred (W4.Pred sym) Crucible.SimError
142143

143-
type instance Pointer' (LLVM arch) Sym = LLVMPtr (Crucible.ArchWidth arch)
144-
145144
-- | An override packaged together with its preconditions, labeled with some
146145
-- human-readable info about each condition.
147146
data OverrideWithPreconditions arch =

src/SAWScript/Crucible/LLVM/ResolveSetupValue.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,11 @@ import SAWScript.Crucible.Common (Sym, sawCoreState, HasSymInterface(.
8484
import SAWScript.Crucible.Common.MethodSpec (AllocIndex(..), SetupValue(..), ppTypedTermType)
8585

8686
import SAWScript.Crucible.LLVM.MethodSpecIR
87+
import SAWScript.Crucible.LLVM.Setup.Value (LLVMPtr)
8788
import qualified SAWScript.Proof as SP
8889

8990

9091
type LLVMVal = Crucible.LLVMVal Sym
91-
type LLVMPtr wptr = Crucible.LLVMPtr Sym wptr
9292

9393

9494

src/SAWScript/Crucible/LLVM/Setup/Value.hs

+10
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ module, plus additional functionality) instead.
3030
{-# LANGUAGE StandaloneDeriving #-}
3131
{-# LANGUAGE TemplateHaskell #-}
3232
{-# LANGUAGE TypeFamilies #-}
33+
{-# LANGUAGE UndecidableInstances #-}
3334
{-# LANGUAGE ViewPatterns #-}
3435

3536
module SAWScript.Crucible.LLVM.Setup.Value
@@ -75,6 +76,8 @@ module SAWScript.Crucible.LLVM.Setup.Value
7576
, emptyResolvedState
7677
, rsAllocs
7778
, rsGlobals
79+
-- * @LLVMPtr@
80+
, LLVMPtr
7881
) where
7982

8083
import Control.Lens
@@ -338,3 +341,10 @@ emptyResolvedState :: LLVMResolvedState
338341
emptyResolvedState = ResolvedState Map.empty Map.empty
339342

340343
makeLenses ''LLVMResolvedState
344+
345+
--------------------------------------------------------------------------------
346+
-- *** Pointers
347+
348+
type instance Setup.Pointer' (LLVM arch) Sym = LLVMPtr (CL.ArchWidth arch)
349+
350+
type LLVMPtr wptr = CL.LLVMPtr Sym wptr

0 commit comments

Comments
 (0)