1
1
mirror of https://github.com/github/semantic.git synced 2024-12-20 21:31:48 +03:00

Move resumingBadVariables into Semantic.Graph.

This commit is contained in:
Rob Rix 2018-05-06 17:03:26 -04:00
parent bf42793078
commit 3a79bc0dc3
2 changed files with 15 additions and 4 deletions

View File

@ -4,7 +4,6 @@ module Semantic.Graph where
import Analysis.Abstract.BadAddresses import Analysis.Abstract.BadAddresses
import Analysis.Abstract.BadSyntax import Analysis.Abstract.BadSyntax
import Analysis.Abstract.BadValues import Analysis.Abstract.BadValues
import Analysis.Abstract.BadVariables
import Analysis.Abstract.Evaluating import Analysis.Abstract.Evaluating
import Analysis.Abstract.ImportGraph import Analysis.Abstract.ImportGraph
import qualified Control.Exception as Exc import qualified Control.Exception as Exc
@ -90,7 +89,7 @@ importGraphAnalysis
. runLoadError . runLoadError
. resumingBadSyntax . resumingBadSyntax
. resumingBadValues . resumingBadValues
. resumingBadVariables . resumingEvalError
. resumingResolutionError . resumingResolutionError
. resumingBadAddresses . resumingBadAddresses
. importGraphing . importGraphing
@ -100,6 +99,19 @@ resumingResolutionError = runResolutionErrorWith (\ err -> traceM ("ResolutionEr
NotFoundError nameToResolve _ _ -> pure nameToResolve NotFoundError nameToResolve _ _ -> pure nameToResolve
GoImportError pathToResolve -> pure [pathToResolve]) GoImportError pathToResolve -> pure [pathToResolve])
resumingEvalError :: (AbstractHole value, Show value) => Evaluator location term value (Resumable (EvalError value) ': State [Name] ': effects) a -> Evaluator location term value effects (a, [Name])
resumingEvalError
= runState []
. runEvalErrorWith (\ err -> traceM ("EvalError" <> show err) *> case err of
EnvironmentLookupError{} -> pure hole
DefaultExportError{} -> pure ()
ExportError{} -> pure ()
IntegerFormatError{} -> pure 0
FloatFormatError{} -> pure 0
RationalFormatError{} -> pure 0
FreeVariableError name -> raise (modify' (name :)) *> pure hole
FreeVariablesError names -> raise (modify' (names <>)) *> pure (fromMaybeLast "unknown" names))
-- | Render the import graph for a given 'Package'. -- | Render the import graph for a given 'Package'.
graphImports :: ( Show ann graphImports :: ( Show ann
, Apply Declarations1 syntax , Apply Declarations1 syntax

View File

@ -5,7 +5,6 @@ module Semantic.Util where
import Analysis.Abstract.BadAddresses import Analysis.Abstract.BadAddresses
import Analysis.Abstract.BadSyntax import Analysis.Abstract.BadSyntax
import Analysis.Abstract.BadValues import Analysis.Abstract.BadValues
import Analysis.Abstract.BadVariables
import Analysis.Abstract.Caching import Analysis.Abstract.Caching
import Analysis.Abstract.Collecting import Analysis.Abstract.Collecting
import Analysis.Abstract.Evaluating as X import Analysis.Abstract.Evaluating as X
@ -44,7 +43,7 @@ evaluatingWithHoles
. runLoadError . runLoadError
. resumingBadSyntax @(Value Precise) . resumingBadSyntax @(Value Precise)
. resumingBadValues @(Value Precise) . resumingBadValues @(Value Precise)
. resumingBadVariables @(Value Precise) . resumingEvalError
. resumingResolutionError . resumingResolutionError
. resumingBadAddresses @(Value Precise) . resumingBadAddresses @(Value Precise)