-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make test binary load, translate, and typecheck
Cryptol.cry
.
(This addresses part of #25.)
- Loading branch information
Brian Huffman
committed
Jul 30, 2020
1 parent
f72b9cf
commit 497effb
Showing
2 changed files
with
29 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,37 @@ | ||
{-# LANGUAGE ImplicitParams #-} | ||
|
||
module Main where | ||
|
||
import qualified Data.ByteString as BS | ||
import qualified Data.Map as Map | ||
|
||
import qualified Cryptol.ModuleSystem.Name as N | ||
import qualified Cryptol.Utils.Ident as N | ||
|
||
import qualified Verifier.SAW.Cryptol as C | ||
import Verifier.SAW.SharedTerm | ||
import qualified Verifier.SAW.SCTypeCheck as TC | ||
import qualified Verifier.SAW.Cryptol.Prelude as C | ||
import qualified Verifier.SAW.CryptolEnv as CEnv | ||
|
||
main :: IO () | ||
main = | ||
do sc <- mkSharedContext | ||
C.scLoadPreludeModule sc | ||
C.scLoadCryptolModule sc | ||
putStrLn "Loaded!" | ||
putStrLn "Loaded Cryptol.sawcore!" | ||
let ?fileReader = BS.readFile | ||
cenv <- CEnv.initCryptolEnv sc | ||
putStrLn "Translated Cryptol.cry!" | ||
mapM_ (checkTranslation sc) $ Map.assocs (CEnv.eTermEnv cenv) | ||
putStrLn "Checked all terms!" | ||
|
||
checkTranslation :: SharedContext -> (N.Name, Term) -> IO () | ||
checkTranslation sc (name, term) = | ||
do result <- TC.scTypeCheck sc Nothing term | ||
case result of | ||
Right _ -> pure () | ||
Left err -> | ||
do putStrLn $ "Type error when checking " ++ show (N.unpackIdent (N.nameIdent name)) | ||
putStrLn $ unlines $ TC.prettyTCError err | ||
fail "internal type error" |