Skip to content

Commit 9effbfd

Browse files
committed
refactor: put initialization code in proximity; whitespace.
1 parent 43adb99 commit 9effbfd

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

cryptol-saw-core/src/CryptolSAWCore/CryptolEnv.hs

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,20 @@ initCryptolEnv sc = do
260260
, eFFITypes = Map.empty
261261
}
262262

263+
-- | Translate all declarations in all loaded modules to SAWCore terms
264+
-- NOTE: used only for initialization code.
265+
266+
genTermEnv :: SharedContext -> ME.ModuleEnv -> C.Env -> IO (Map T.Name Term)
267+
genTermEnv sc modEnv cryEnv0 = do
268+
let declGroups = concatMap T.mDecls
269+
$ filter (not . T.isParametrizedModule)
270+
$ ME.loadedModules modEnv
271+
nominals = ME.loadedNominalTypes modEnv
272+
cryEnv1 <- C.genCodeForNominalTypes sc nominals cryEnv0
273+
cryEnv2 <- C.importTopLevelDeclGroups sc C.defaultPrimitiveOptions cryEnv1 declGroups
274+
return (C.envE cryEnv2)
275+
276+
263277
-- Parse -----------------------------------------------------------------------
264278

265279
ioParseExpr :: InputText -> IO (P.Expr P.PName)
@@ -400,17 +414,6 @@ translateDeclGroups sc env dgs =
400414
, eTermEnv = C.envE cryEnv'
401415
}
402416

403-
-- | Translate all declarations in all loaded modules to SAWCore terms
404-
genTermEnv :: SharedContext -> ME.ModuleEnv -> C.Env -> IO (Map T.Name Term)
405-
genTermEnv sc modEnv cryEnv0 = do
406-
let declGroups = concatMap T.mDecls
407-
$ filter (not . T.isParametrizedModule)
408-
$ ME.loadedModules modEnv
409-
nominals = ME.loadedNominalTypes modEnv
410-
cryEnv1 <- C.genCodeForNominalTypes sc nominals cryEnv0
411-
cryEnv2 <- C.importTopLevelDeclGroups sc C.defaultPrimitiveOptions cryEnv1 declGroups
412-
return (C.envE cryEnv2)
413-
414417
--------------------------------------------------------------------------------
415418

416419

@@ -669,7 +672,7 @@ importModule sc env src as vis imps = do
669672
do oldCryEnv <- mkCryEnv env
670673
cEnv <- C.genCodeForNominalTypes sc newNominal oldCryEnv
671674
newCryEnv <- C.importTopLevelDeclGroups
672-
sc C.defaultPrimitiveOptions cEnv newDeclGroups
675+
sc C.defaultPrimitiveOptions cEnv newDeclGroups
673676
return (C.envE newCryEnv)
674677

675678
let newImport = (vis, P.Import { T.iModule= locate $ T.mName m

0 commit comments

Comments
 (0)