Skip to content

Commit

Permalink
Update FunctionBindings from a type alias to a newtype
Browse files Browse the repository at this point in the history
  • Loading branch information
kquick committed Feb 22, 2021
1 parent dac11ed commit 049000a
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion crucible-llvm/src/Lang/Crucible/LLVM.hs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ registerModuleFn llvm_ctx (decl, AnyCFG cfg) = do
let h = cfgHandle cfg
s = UseCFG cfg (postdomInfo cfg)
binds <- use (stateContext . functionBindings)
when (isJust $ lookupHandleMap h binds) $
when (isJust $ lookupHandleMap h $ fnBindings binds) $
showWarning ("LLVM function handle registered twice: " ++ show (handleName h))
bindFnHandle h s
let mvar = llvmMemVar llvm_ctx
Expand Down
4 changes: 2 additions & 2 deletions crucible/src/Lang/Crucible/Simulator/ExecutionTree.hs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ module Lang.Crucible.Simulator.ExecutionTree
-- ** Function bindings
, Override(..)
, FnState(..)
, FunctionBindings
, FunctionBindings(..)

-- ** Extensions
, ExtensionImpl(..)
Expand Down Expand Up @@ -970,7 +970,7 @@ data FnState p sym ext (args :: Ctx CrucibleType) (ret :: CrucibleType)
| forall blocks . UseCFG !(CFG ext blocks args ret) !(CFGPostdom blocks)

-- | A map from function handles to their semantics.
type FunctionBindings p sym ext = FnHandleMap (FnState p sym ext)
newtype FunctionBindings p sym ext = FnBindings { fnBindings :: FnHandleMap (FnState p sym ext) }

-- | The type of functions that interpret extension statements. These
-- have access to the main simulator state, and can make fairly arbitrary
Expand Down
2 changes: 1 addition & 1 deletion crucible/src/Lang/Crucible/Simulator/Operations.hs
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ resolveCall bindings c0 args loc callStack =
resolveCall bindings (HandleFnVal h) (packVarargs addlTypes args) loc callStack

HandleFnVal h -> do
case lookupHandleMap h bindings of
case lookupHandleMap h (fnBindings bindings) of
Nothing -> Ex.throw (UnresolvableFunction loc callStack h)
Just (UseOverride o) -> do
let f = OverrideFrame { _override = overrideName o
Expand Down
6 changes: 3 additions & 3 deletions crucible/src/Lang/Crucible/Simulator/OverrideSim.hs
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ bindFnHandle ::
FnState p sym ext args ret ->
OverrideSim p sym ext rtp a r ()
bindFnHandle h s =
stateContext . functionBindings %= insertHandleMap h s
stateContext . functionBindings %= FnBindings . insertHandleMap h s . fnBindings

------------------------------------------------------------------------
-- Mutable variables
Expand Down Expand Up @@ -573,12 +573,12 @@ data FnBinding p sym ext where
insertFnBinding :: FunctionBindings p sym ext
-> FnBinding p sym ext
-> FunctionBindings p sym ext
insertFnBinding m (FnBinding h s) = insertHandleMap h s m
insertFnBinding m (FnBinding h s) = FnBindings $ insertHandleMap h s $ fnBindings m

-- | Build a map of function bindings from a list of
-- handle/binding pairs.
fnBindingsFromList :: [FnBinding p sym ext] -> FunctionBindings p sym ext
fnBindingsFromList = foldl' insertFnBinding emptyHandleMap
fnBindingsFromList = foldl' insertFnBinding $ FnBindings emptyHandleMap

registerFnBinding :: FnBinding p sym ext
-> OverrideSim p sym ext rtp a r ()
Expand Down

0 comments on commit 049000a

Please sign in to comment.