Skip to content

Commit

Permalink
Remove non-functional saw-script function jvm_global.
Browse files Browse the repository at this point in the history
Support for static fields is planned using a different mechanism.
(See #908.)
  • Loading branch information
Brian Huffman committed Dec 3, 2020
1 parent 14bab8f commit 191a0e9
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 25 deletions.
2 changes: 1 addition & 1 deletion src/SAWScript/Crucible/JVM/MethodSpecIR.hs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ import qualified SAWScript.Crucible.Common.Setup.Type as Setup
-- ** Language features

type instance MS.HasSetupNull CJ.JVM = 'True
type instance MS.HasSetupGlobal CJ.JVM = 'True
type instance MS.HasSetupGlobal CJ.JVM = 'False
type instance MS.HasSetupStruct CJ.JVM = 'False
type instance MS.HasSetupArray CJ.JVM = 'False
type instance MS.HasSetupElem CJ.JVM = 'False
Expand Down
16 changes: 3 additions & 13 deletions src/SAWScript/Crucible/JVM/Override.hs
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ matchPointsTos opts sc cc spec prepost = go False []
MS.SetupVar i -> Set.singleton i
MS.SetupTerm _ -> Set.empty
MS.SetupNull () -> Set.empty
MS.SetupGlobal () _ -> Set.empty
MS.SetupGlobal empty _ -> absurd empty
MS.SetupStruct empty _ _ -> absurd empty
MS.SetupArray empty _ -> absurd empty
MS.SetupElem empty _ _ -> absurd empty
Expand Down Expand Up @@ -580,13 +580,7 @@ matchArg opts sc cc cs prepost actual@(RVal ref) expectedTy setupval =
p <- liftIO (CJ.refIsNull sym ref)
addAssert p (Crucible.SimError (cs ^. MS.csLoc) (Crucible.AssertFailureSimError ("null-equality " ++ stateCond prepost) ""))

MS.SetupGlobal () name ->
do let mem = () -- FIXME cc^.ccLLVMEmptyMem
sym <- Ov.getSymInterface
ref' <- liftIO $ doResolveGlobal sym mem name

p <- liftIO (CJ.refIsEqual sym ref ref')
addAssert p (Crucible.SimError (cs ^. MS.csLoc) (Crucible.AssertFailureSimError ("global-equality " ++ stateCond prepost) ""))
MS.SetupGlobal empty _ -> absurd empty

_ -> failure (cs ^. MS.csLoc) =<<
mkStructuralMismatch opts cc sc cs actual setupval expectedTy
Expand Down Expand Up @@ -937,7 +931,7 @@ instantiateSetupValue sc s v =
MS.SetupVar _ -> return v
MS.SetupTerm tt -> MS.SetupTerm <$> doTerm tt
MS.SetupNull () -> return v
MS.SetupGlobal () _ -> return v
MS.SetupGlobal empty _ -> absurd empty
MS.SetupStruct empty _ _ -> absurd empty
MS.SetupArray empty _ -> absurd empty
MS.SetupElem empty _ _ -> absurd empty
Expand Down Expand Up @@ -1026,7 +1020,3 @@ decodeJVMVal ty v =
asRVal :: W4.ProgramLoc -> JVMVal -> OverrideMatcher CJ.JVM w JVMRefVal
asRVal _ (RVal ptr) = return ptr
asRVal loc _ = failure loc BadPointerCast

doResolveGlobal :: Sym -> () -> String -> IO JVMRefVal
doResolveGlobal _sym _mem _name = fail "doResolveGlobal: FIXME"
-- FIXME: replace () with whatever type we need to look up global/static references
6 changes: 2 additions & 4 deletions src/SAWScript/Crucible/JVM/ResolveSetupValue.hs
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,7 @@ typeOfSetupValue _cc env _nameEnv val =
-- can be used at, and b) it prevents us from doing any
-- type-safe field accesses.
return (J.ClassType (J.mkClassName "java/lang/Object"))
MS.SetupGlobal () name ->
fail ("typeOfSetupValue: unimplemented jvm_global: " ++ name)
MS.SetupGlobal empty _ -> absurd empty
MS.SetupStruct empty _ _ -> absurd empty
MS.SetupArray empty _ -> absurd empty
MS.SetupElem empty _ _ -> absurd empty
Expand All @@ -142,8 +141,7 @@ resolveSetupVal cc env _tyenv _nameEnv val =
MS.SetupTerm tm -> resolveTypedTerm cc tm
MS.SetupNull () ->
return (RVal (W4.maybePartExpr sym Nothing))
MS.SetupGlobal () name ->
fail $ "resolveSetupVal: unimplemented jvm_global: " ++ name
MS.SetupGlobal empty _ -> absurd empty
MS.SetupStruct empty _ _ -> absurd empty
MS.SetupArray empty _ -> absurd empty
MS.SetupElem empty _ _ -> absurd empty
Expand Down
7 changes: 0 additions & 7 deletions src/SAWScript/Interpreter.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2527,13 +2527,6 @@ primitives = Map.fromList
Experimental
[ "A JVMValue representing a null pointer value." ]

, prim "jvm_global"
"String -> JVMValue"
(pureVal (CMS.SetupGlobal () :: String -> CMS.SetupValue CJ.JVM))
Experimental
[ "Return a JVMValue representing a pointer to the named global."
, "The String may be either the name of a global value or a function name." ]

, prim "jvm_term"
"Term -> JVMValue"
(pureVal (CMS.SetupTerm :: TypedTerm -> CMS.SetupValue CJ.JVM))
Expand Down

0 comments on commit 191a0e9

Please sign in to comment.