Skip to content

Commit

Permalink
Update cryptol submodule and adapt to changes.
Browse files Browse the repository at this point in the history
The following included cryptol PRs required changes to saw-script:
- GaloisInc/cryptol#1077 "nopat-refactor"
- GaloisInc/cryptol#1075 "persist-solver"
  • Loading branch information
Brian Huffman committed Mar 3, 2021
1 parent 9004724 commit bae01f6
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 6 deletions.
7 changes: 5 additions & 2 deletions saw-remote-api/src/SAWServer/CryptolExpression.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import Data.Traversable (for)
import Cryptol.Eval (EvalOpts(..))
import Cryptol.ModuleSystem (ModuleRes, ModuleInput(..))
import Cryptol.ModuleSystem.Base (genInferInput, getPrimMap, noPat, rename)
import Cryptol.ModuleSystem.Env (ModuleEnv)
import Cryptol.ModuleSystem.Env (ModuleEnv, meSolverConfig)
import Cryptol.ModuleSystem.Interface (noIfaceParams)
import Cryptol.ModuleSystem.Monad (ModuleM, interactive, runModuleM, setNameSeeds, setSupply, typeCheckWarnings, typeCheckingFailed)
import qualified Cryptol.ModuleSystem.Renamer as MR
Expand All @@ -33,6 +33,7 @@ import qualified Cryptol.Parser as CP
import Cryptol.Parser.Position (emptyRange, getLoc)
import Cryptol.TypeCheck (tcExpr)
import Cryptol.TypeCheck.Monad (InferOutput(..), inpVars, inpTSyns)
import Cryptol.TypeCheck.Solver.SMT (withSolver)
import Cryptol.Utils.Ident (interactiveName)
import Cryptol.Utils.Logger (quietLogger)
import Cryptol.Utils.PP
Expand Down Expand Up @@ -64,7 +65,9 @@ getTypedTermOfCExp fileReader sc cenv expr =
do let ?fileReader = fileReader
let env = eModuleEnv cenv
let minp = ModuleInput True (pure defaultEvalOpts) B.readFile env
mres <- runModuleM minp $
mres <-
withSolver (meSolverConfig env) $ \s ->
runModuleM (minp s) $
do npe <- interactive (noPat expr) -- eliminate patterns

-- resolve names
Expand Down
3 changes: 2 additions & 1 deletion src/SAWScript/AutoMatch.hs
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,8 @@ processResults (TaggedSourceFile leftLang leftFile) (TaggedSourceFile rightLang

cryptolAbstractNamesSAW :: [SAWScript.LName] -> Cryptol.Expr Cryptol.PName -> Cryptol.Expr Cryptol.PName
cryptolAbstractNamesSAW names expr =
Cryptol.EFun (for names $ Cryptol.PVar . cryptolLocate . SAWScript.getVal) expr
Cryptol.EFun Cryptol.emptyFunDesc
(for names $ Cryptol.PVar . cryptolLocate . SAWScript.getVal) expr

cryptolApplyFunctionSAW :: SAWScript.LName -> [SAWScript.LName] -> Cryptol.Expr Cryptol.PName
cryptolApplyFunctionSAW function args =
Expand Down
5 changes: 4 additions & 1 deletion src/SAWScript/AutoMatch/Cryptol.hs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import Cryptol.ModuleSystem.Name
import Cryptol.Utils.Ident (unpackIdent)
import Cryptol.Utils.Logger (quietLogger)
import qualified Cryptol.TypeCheck.AST as AST
import qualified Cryptol.TypeCheck.Solver.SMT as SMT
import Cryptol.Utils.PP

-- | Parse a Cryptol module into a list of declarations
Expand All @@ -31,7 +32,9 @@ getDeclsCryptol path = do
let evalOpts = EvalOpts quietLogger defaultPPOpts
modEnv <- M.initialModuleEnv
let minp = M.ModuleInput True (pure evalOpts) BS.readFile modEnv
(result, warnings) <- M.loadModuleByPath path minp
(result, warnings) <-
SMT.withSolver (M.meSolverConfig modEnv) $ \s ->
M.loadModuleByPath path (minp s)
return $ do
forM_ warnings $ liftF . flip Warning () . pretty
case result of
Expand Down

0 comments on commit bae01f6

Please sign in to comment.