mirror of
https://github.com/github/semantic.git
synced 2024-12-18 20:31:55 +03:00
Generalize everything over AnalyzeTerm.
This commit is contained in:
parent
f9f6801b0d
commit
70f33d45ef
@ -145,16 +145,8 @@ runGraph CallGraph includePackages project
|
|||||||
modules <- topologicalSort <$> runImportGraphToModules lang package
|
modules <- topologicalSort <$> runImportGraphToModules lang package
|
||||||
runCallGraph lang includePackages modules package
|
runCallGraph lang includePackages modules package
|
||||||
|
|
||||||
runCallGraph :: ( VertexDeclaration term
|
runCallGraph :: ( AnalyzeTerm term
|
||||||
, Declarations (term Loc)
|
|
||||||
, AccessControls (term Loc)
|
|
||||||
, Ord (term Loc)
|
|
||||||
, Evaluatable (Base (term Loc))
|
|
||||||
, FreeVariables (term Loc)
|
|
||||||
, Recursive (term Loc)
|
|
||||||
, Show (term Loc)
|
|
||||||
, HasPrelude lang
|
, HasPrelude lang
|
||||||
, HasSpan (term Loc)
|
|
||||||
, Member Trace sig
|
, Member Trace sig
|
||||||
, Carrier sig m
|
, Carrier sig m
|
||||||
, Effect sig
|
, Effect sig
|
||||||
@ -195,59 +187,41 @@ runModuleTable :: Evaluator term address value (ReaderC (ModuleTable (Module (Mo
|
|||||||
-> Evaluator term address value m a
|
-> Evaluator term address value m a
|
||||||
runModuleTable = raiseHandler $ runReader lowerBound
|
runModuleTable = raiseHandler $ runReader lowerBound
|
||||||
|
|
||||||
runImportGraphToModuleInfos :: ( Declarations term
|
runImportGraphToModuleInfos :: ( AnalyzeTerm term
|
||||||
, Evaluatable (Base term)
|
|
||||||
, FreeVariables term
|
|
||||||
, AccessControls term
|
|
||||||
, HasSpan term
|
|
||||||
, HasPrelude lang
|
, HasPrelude lang
|
||||||
, Member Trace sig
|
, Member Trace sig
|
||||||
, Recursive term
|
|
||||||
, Carrier sig m
|
, Carrier sig m
|
||||||
, Show term
|
|
||||||
, Effect sig
|
, Effect sig
|
||||||
)
|
)
|
||||||
=> Proxy lang
|
=> Proxy lang
|
||||||
-> Package term
|
-> Package (term Loc)
|
||||||
-> m (Graph ControlFlowVertex)
|
-> m (Graph ControlFlowVertex)
|
||||||
runImportGraphToModuleInfos lang (package :: Package term) = runImportGraph lang package allModuleInfos
|
runImportGraphToModuleInfos lang (package :: Package (term Loc)) = runImportGraph lang package allModuleInfos
|
||||||
where allModuleInfos info = vertex (maybe (unknownModuleVertex info) (moduleVertex . moduleInfo) (ModuleTable.lookup (modulePath info) (packageModules package)))
|
where allModuleInfos info = vertex (maybe (unknownModuleVertex info) (moduleVertex . moduleInfo) (ModuleTable.lookup (modulePath info) (packageModules package)))
|
||||||
|
|
||||||
runImportGraphToModules :: ( Declarations term
|
runImportGraphToModules :: ( AnalyzeTerm term
|
||||||
, Evaluatable (Base term)
|
|
||||||
, FreeVariables term
|
|
||||||
, AccessControls term
|
|
||||||
, HasSpan term
|
|
||||||
, HasPrelude lang
|
, HasPrelude lang
|
||||||
, Member Trace sig
|
, Member Trace sig
|
||||||
, Recursive term
|
|
||||||
, Carrier sig m
|
, Carrier sig m
|
||||||
, Show term
|
|
||||||
, Effect sig
|
, Effect sig
|
||||||
)
|
)
|
||||||
=> Proxy lang
|
=> Proxy lang
|
||||||
-> Package term
|
-> Package (term Loc)
|
||||||
-> m (Graph (Module term))
|
-> m (Graph (Module (term Loc)))
|
||||||
runImportGraphToModules lang (package :: Package term) = runImportGraph lang package resolveOrLowerBound
|
runImportGraphToModules lang (package :: Package (term Loc)) = runImportGraph lang package resolveOrLowerBound
|
||||||
where resolveOrLowerBound info = maybe lowerBound vertex (ModuleTable.lookup (modulePath info) (packageModules package))
|
where resolveOrLowerBound info = maybe lowerBound vertex (ModuleTable.lookup (modulePath info) (packageModules package))
|
||||||
|
|
||||||
runImportGraph :: ( AccessControls term
|
runImportGraph :: ( AnalyzeTerm term
|
||||||
, Evaluatable (Base term)
|
|
||||||
, FreeVariables term
|
|
||||||
, HasSpan term
|
|
||||||
, Declarations term
|
|
||||||
, HasPrelude lang
|
, HasPrelude lang
|
||||||
, Member Trace sig
|
, Member Trace sig
|
||||||
, Recursive term
|
|
||||||
, Carrier sig m
|
, Carrier sig m
|
||||||
, Show term
|
|
||||||
, Effect sig
|
, Effect sig
|
||||||
)
|
)
|
||||||
=> Proxy lang
|
=> Proxy lang
|
||||||
-> Package term
|
-> Package (term Loc)
|
||||||
-> (ModuleInfo -> Graph vertex)
|
-> (ModuleInfo -> Graph vertex)
|
||||||
-> m (Graph vertex)
|
-> m (Graph vertex)
|
||||||
runImportGraph lang (package :: Package term) f
|
runImportGraph lang (package :: Package (term Loc)) f
|
||||||
= fmap (fst >=> f)
|
= fmap (fst >=> f)
|
||||||
. runEvaluator @_ @_ @(Value _ (Hole (Maybe Name) Precise))
|
. runEvaluator @_ @_ @(Value _ (Hole (Maybe Name) Precise))
|
||||||
. raiseHandler (runState lowerBound)
|
. raiseHandler (runState lowerBound)
|
||||||
@ -300,27 +274,21 @@ parseModules parser p = distributeFor (projectBlobs p) (parseModule p parser)
|
|||||||
|
|
||||||
-- | Parse a list of packages from a python project.
|
-- | Parse a list of packages from a python project.
|
||||||
parsePythonPackage :: forall term sig m .
|
parsePythonPackage :: forall term sig m .
|
||||||
( Declarations term
|
( AnalyzeTerm term
|
||||||
, Evaluatable (Base term)
|
|
||||||
, FreeVariables term
|
|
||||||
, AccessControls term
|
|
||||||
, Recursive term
|
|
||||||
, Member Distribute sig
|
, Member Distribute sig
|
||||||
, Member Parse sig
|
, Member Parse sig
|
||||||
, Member Resolution sig
|
, Member Resolution sig
|
||||||
, Member Trace sig
|
, Member Trace sig
|
||||||
, HasSpan term
|
|
||||||
, Show term
|
|
||||||
, Carrier sig m
|
, Carrier sig m
|
||||||
, Effect sig
|
, Effect sig
|
||||||
)
|
)
|
||||||
=> Parser term -- ^ A parser.
|
=> Parser (term Loc) -- ^ A parser.
|
||||||
-> Project -- ^ Project to parse into a package.
|
-> Project -- ^ Project to parse into a package.
|
||||||
-> m (Package term)
|
-> m (Package (term Loc))
|
||||||
parsePythonPackage parser project = do
|
parsePythonPackage parser project = do
|
||||||
let runAnalysis = runEvaluator @_ @_ @(Value term (Hole (Maybe Name) Precise))
|
let runAnalysis = runEvaluator @_ @_ @(Value (term Loc) (Hole (Maybe Name) Precise))
|
||||||
. raiseHandler (runState PythonPackage.Unknown)
|
. raiseHandler (runState PythonPackage.Unknown)
|
||||||
. raiseHandler (runState (lowerBound @(Heap (Hole (Maybe Name) Precise) (Hole (Maybe Name) Precise) (Value term (Hole (Maybe Name) Precise)))))
|
. raiseHandler (runState (lowerBound @(Heap (Hole (Maybe Name) Precise) (Hole (Maybe Name) Precise) (Value (term Loc) (Hole (Maybe Name) Precise)))))
|
||||||
. raiseHandler runFresh
|
. raiseHandler runFresh
|
||||||
. resumingLoadError
|
. resumingLoadError
|
||||||
. resumingUnspecialized
|
. resumingUnspecialized
|
||||||
|
Loading…
Reference in New Issue
Block a user