Skip to content

Commit 4e722ec

Browse files
authored
Merge pull request #1363 from GaloisInc/functors-merge
New module system
2 parents 1baa68b + 179c2cf commit 4e722ec

File tree

370 files changed

+10027
-29476
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

370 files changed

+10027
-29476
lines changed

CHANGES.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@
4040
`sbv-cvc5` is non-functional on Windows at this time due to a downstream issue
4141
with CVC5 1.0.4 and earlier.)
4242

43+
* Add `:file-deps` commands to the REPL and Python API.
44+
It shows information about the source files and dependencies of
45+
modules or Cryptol files.
46+
4347
## Bug fixes
4448

4549
* Fix a bug in the What4 backend that could cause applications of `(@)` with

bench/Main.hs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import qualified Cryptol.ModuleSystem.Base as M
2626
import qualified Cryptol.ModuleSystem.Env as M
2727
import qualified Cryptol.ModuleSystem.Monad as M
2828
import qualified Cryptol.ModuleSystem.NamingEnv as M
29-
import Cryptol.ModuleSystem.Interface (noIfaceParams)
3029

3130
import qualified Cryptol.Parser as P
3231
import qualified Cryptol.Parser.AST as P
@@ -130,7 +129,7 @@ tc cd name path =
130129
, M.tcLinter = M.moduleLinter (P.thing (P.mName scm))
131130
, M.tcPrims = prims
132131
}
133-
M.typecheck act scm noIfaceParams tcEnv
132+
M.typecheck act scm mempty tcEnv
134133

135134
ceval :: String -> String -> FilePath -> T.Text -> Benchmark
136135
ceval cd name path expr =

cryptol-remote-api/cryptol-eval-server/Main.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import CryptolServer.Interrupt
2626
( interruptServer, interruptServerDescr )
2727
import Cryptol.ModuleSystem (ModuleInput(..), loadModuleByPath, loadModuleByName)
2828
import Cryptol.ModuleSystem.Monad (runModuleM, setFocusedModule)
29-
import Cryptol.TypeCheck.AST (mName)
29+
import Cryptol.TypeCheck.AST (tcTopEntitytName)
3030
import Cryptol.Utils.Ident (ModName, modNameToText, textToModName, preludeName)
3131
import Cryptol.Utils.Logger (quietLogger)
3232

@@ -77,7 +77,7 @@ main = customMain initMod initMod initMod initMod description buildApp
7777
case res of
7878
Left err -> die err
7979
Right (m, menv') ->
80-
do res' <- fst <$> runModuleM minp{ minpModuleEnv = menv' } (setFocusedModule (mName (snd m)))
80+
do res' <- fst <$> runModuleM minp{ minpModuleEnv = menv' } (setFocusedModule (tcTopEntitytName (snd m)))
8181
case res' of
8282
Left err -> die err
8383
Right (_, menv'') -> pure menv''

cryptol-remote-api/cryptol-remote-api.cabal

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ flag static
1313
description: Create a statically-linked binary
1414

1515
flag NotThreaded
16-
default: false
17-
manual: true
16+
default: False
17+
manual: True
1818
description: Omit the -threaded ghc flag
1919

2020
common warnings
@@ -80,6 +80,7 @@ library
8080
CryptolServer.Names
8181
CryptolServer.Sat
8282
CryptolServer.TypeCheck
83+
CryptolServer.FileDeps
8384

8485
other-modules:
8586
CryptolServer.AesonCompat

cryptol-remote-api/cryptol-remote-api/Main.hs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import CryptolServer.LoadModule
3333
import CryptolServer.Names ( visibleNames, visibleNamesDescr )
3434
import CryptolServer.Sat ( proveSat, proveSatDescr )
3535
import CryptolServer.TypeCheck ( checkType, checkTypeDescr )
36+
import CryptolServer.FileDeps( fileDeps, fileDepsDescr )
3637

3738
main :: IO ()
3839
main =
@@ -91,6 +92,10 @@ cryptolMethods =
9192
"load file"
9293
loadFileDescr
9394
loadFile
95+
, command
96+
"file-deps"
97+
fileDepsDescr
98+
fileDeps
9499
, command
95100
"focused module"
96101
focusedModuleDescr

cryptol-remote-api/docs/Cryptol.rst

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,55 @@ No return fields
388388

389389

390390

391+
file-deps (command)
392+
~~~~~~~~~~~~~~~~~~~
393+
394+
Get information about the dependencies of a file or module. The dependencies include the dependencies of modules nested in this one.
395+
396+
Parameter fields
397+
++++++++++++++++
398+
399+
400+
``name``
401+
Get information about this entity.
402+
403+
404+
405+
``is-file``
406+
Indicates if the name is a file (true) or module (false)
407+
408+
409+
410+
Return fields
411+
+++++++++++++
412+
413+
414+
``source``
415+
File containing the module. For internal modules this is an object { internal: "LABEL" }.
416+
417+
418+
419+
``fingerprint``
420+
A hash of the module content.
421+
422+
423+
424+
``includes``
425+
Files included in this module.
426+
427+
428+
429+
``imports``
430+
Modules imported by this module.
431+
432+
433+
434+
``foreign``
435+
Foreign libraries loaded by this module.
436+
437+
438+
439+
391440
focused module (command)
392441
~~~~~~~~~~~~~~~~~~~~~~~~
393442

cryptol-remote-api/python/cryptol/commands.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,21 @@ def __init__(self, connection : HasProtocolState, filename : str, timeout: Optio
7575
def process_result(self, res : Any) -> Any:
7676
return res
7777

78+
class CryptolFileDeps(argo.Command):
79+
def __init__( self
80+
, connection : HasProtocolState
81+
, name : str, isFile : bool
82+
, timeout: Optional[float]
83+
) -> None:
84+
super(CryptolFileDeps, self).__init__('file-deps'
85+
, {'name': name, 'is-file': isFile }
86+
, connection
87+
, timeout=timeout
88+
)
89+
90+
def process_result(self, res : Any) -> Any:
91+
return res
92+
7893
class CryptolExtendSearchPath(argo.Command):
7994
def __init__(self, connection : HasProtocolState, dirs : List[str], timeout: Optional[float]) -> None:
8095
super(CryptolExtendSearchPath, self).__init__('extend search path', {'paths': dirs}, connection, timeout=timeout)
@@ -83,6 +98,8 @@ def process_result(self, res : Any) -> Any:
8398
return res
8499

85100

101+
102+
86103
class CryptolEvalExprRaw(argo.Command):
87104
def __init__(self, connection : HasProtocolState, expr : Any, timeout: Optional[float]) -> None:
88105
super(CryptolEvalExprRaw, self).__init__(

cryptol-remote-api/python/cryptol/connection.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,15 @@ def load_module(self, module_name : str, *, timeout:Optional[float] = None) -> a
213213
self.most_recent_result = CryptolLoadModule(self, module_name, timeout)
214214
return self.most_recent_result
215215

216+
def file_deps(self, name : str, isFile : bool, *, timeout:Optional[float] = None) -> argo.Command:
217+
"""Get information about a module or a file.
218+
219+
:param timeout: Optional timeout for this request (in seconds).
220+
"""
221+
timeout = timeout if timeout is not None else self.timeout
222+
self.most_recent_result = CryptolFileDeps(self, name, isFile, timeout)
223+
return self.most_recent_result
224+
216225
def eval_raw(self, expression : Any, *, timeout:Optional[float] = None) -> argo.Command:
217226
"""Like the member method ``eval``, but does not call
218227
``from_cryptol_arg`` on the ``.result()``.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from typing import Dict, Any
2+
3+
def nestedFileDeps(getDeps : Any, name : str, isFile : bool) -> Any:
4+
done : Dict[str,Any] = {}
5+
start = getDeps(name, isFile)
6+
todo = start["imports"].copy()
7+
while len(todo) > 0:
8+
m = todo.pop()
9+
if m in done:
10+
continue
11+
deps = getDeps(m, False)
12+
todo.extend(deps["imports"])
13+
return (start, deps)
14+

cryptol-remote-api/python/cryptol/single_connection.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,3 +252,9 @@ def interrupt() -> None:
252252
def logging(on : bool, *, dest : TextIO = sys.stderr) -> None:
253253
"""Whether to log received and transmitted JSON."""
254254
__get_designated_connection().logging(on=on,dest=dest)
255+
256+
def file_deps(m : str, isFile:bool, timeout:Optional[float] = None) -> Any:
257+
"""Get information about a module or a file."""
258+
return __get_designated_connection().file_deps(m,isFile,timeout=timeout)
259+
260+

0 commit comments

Comments
 (0)