@@ -810,6 +810,8 @@ data JVMSetupError
810
810
| JVMArrayMultiple SetupValue
811
811
| JVMArgTypeMismatch Int J. Type J. Type -- argument position, expected, found
812
812
| JVMArgNumberWrong Int Int -- number expected, number found
813
+ | JVMReturnUnexpected J. Type -- found
814
+ | JVMReturnTypeMismatch J. Type J. Type -- expected, found
813
815
814
816
instance X. Exception JVMSetupError
815
817
@@ -885,6 +887,17 @@ instance Show JVMSetupError where
885
887
, " Expected: " ++ show expected
886
888
, " Given: " ++ show found
887
889
]
890
+ JVMReturnUnexpected found ->
891
+ unlines
892
+ [ " jvm_return: Unexpected return value for void method"
893
+ , " Given type: " ++ show found
894
+ ]
895
+ JVMReturnTypeMismatch expected found ->
896
+ unlines
897
+ [ " jvm_return: Return type mismatch"
898
+ , " Expected type: " ++ show expected
899
+ , " Given type: " ++ show found
900
+ ]
888
901
889
902
-- | Returns Cryptol type of actual type if it is an array or
890
903
-- primitive type.
@@ -1101,7 +1114,21 @@ jvm_execute_func bic opts args =
1101
1114
Setup. crucible_execute_func bic opts args
1102
1115
1103
1116
jvm_return :: BuiltinContext -> Options -> SetupValue -> JVMSetupM ()
1104
- jvm_return bic opts retVal = JVMSetupM $ Setup. crucible_return bic opts retVal
1117
+ jvm_return bic opts retVal =
1118
+ JVMSetupM $
1119
+ do st <- get
1120
+ let cc = st ^. Setup. csCrucibleContext
1121
+ let mspec = st ^. Setup. csMethodSpec
1122
+ let env = MS. csAllocations mspec
1123
+ let nameEnv = MS. csTypeNames mspec
1124
+ valTy <- typeOfSetupValue cc env nameEnv retVal
1125
+ case mspec ^. MS. csRet of
1126
+ Nothing ->
1127
+ X. throwM (JVMReturnUnexpected valTy)
1128
+ Just retTy ->
1129
+ unless (registerCompatible retTy valTy) $
1130
+ X. throwM (JVMReturnTypeMismatch retTy valTy)
1131
+ Setup. crucible_return bic opts retVal
1105
1132
1106
1133
--------------------------------------------------------------------------------
1107
1134
0 commit comments