mirror of
https://github.com/github/semantic.git
synced 2024-12-25 07:55:12 +03:00
Merge branch 'master' into factor-abstract-value-as-value-effects
This commit is contained in:
commit
812d9cefab
@ -53,7 +53,6 @@ library
|
|||||||
, Control.Rewriting
|
, Control.Rewriting
|
||||||
-- Datatypes for abstract interpretation
|
-- Datatypes for abstract interpretation
|
||||||
, Data.Abstract.Address.Hole
|
, Data.Abstract.Address.Hole
|
||||||
, Data.Abstract.Address.Located
|
|
||||||
, Data.Abstract.Address.Monovariant
|
, Data.Abstract.Address.Monovariant
|
||||||
, Data.Abstract.Address.Precise
|
, Data.Abstract.Address.Precise
|
||||||
, Data.Abstract.BaseError
|
, Data.Abstract.BaseError
|
||||||
|
@ -20,8 +20,6 @@ import Algebra.Graph.Export.Dot hiding (vertexName)
|
|||||||
import Control.Abstract hiding (Function(..))
|
import Control.Abstract hiding (Function(..))
|
||||||
import Control.Effect.Carrier
|
import Control.Effect.Carrier
|
||||||
import Control.Effect.Sum
|
import Control.Effect.Sum
|
||||||
import Data.Abstract.Address.Hole
|
|
||||||
import Data.Abstract.Address.Located
|
|
||||||
import Data.Abstract.BaseError
|
import Data.Abstract.BaseError
|
||||||
import Data.Abstract.Declarations
|
import Data.Abstract.Declarations
|
||||||
import Data.Abstract.Module (Module (moduleInfo), ModuleInfo (..))
|
import Data.Abstract.Module (Module (moduleInfo), ModuleInfo (..))
|
||||||
@ -65,24 +63,22 @@ style = (defaultStyle (T.encodeUtf8Builder . vertexIdentifier))
|
|||||||
graphingTerms :: ( Member (Reader ModuleInfo) sig
|
graphingTerms :: ( Member (Reader ModuleInfo) sig
|
||||||
, Member (Reader Span) sig
|
, Member (Reader Span) sig
|
||||||
, Member (State (Graph ControlFlowVertex)) sig
|
, Member (State (Graph ControlFlowVertex)) sig
|
||||||
, Member (State (Map (Slot hole) ControlFlowVertex)) sig
|
, Member (State (Map (Slot address) ControlFlowVertex)) sig
|
||||||
, Member (State (Heap hole hole value)) sig
|
, Member (State (Heap address address value)) sig
|
||||||
, Member (State (ScopeGraph (Hole context (Located address)))) sig
|
, Member (State (ScopeGraph address)) sig
|
||||||
, Member (Resumable (BaseError (ScopeError hole))) sig
|
, Member (Resumable (BaseError (ScopeError address))) sig
|
||||||
, Member (Resumable (BaseError (HeapError hole))) sig
|
, Member (Resumable (BaseError (HeapError address))) sig
|
||||||
, Member (Reader (CurrentFrame hole)) sig
|
, Member (Reader (CurrentFrame address)) sig
|
||||||
, Member (Reader (CurrentScope hole)) sig
|
, Member (Reader (CurrentScope address)) sig
|
||||||
, Member (Reader ControlFlowVertex) sig
|
, Member (Reader ControlFlowVertex) sig
|
||||||
, VertexDeclaration syntax
|
, VertexDeclaration syntax
|
||||||
, Declarations1 syntax
|
, Declarations1 syntax
|
||||||
, Ord address
|
, Ord address
|
||||||
, Ord context
|
|
||||||
, Foldable syntax
|
, Foldable syntax
|
||||||
, hole ~ Hole context (Located address)
|
|
||||||
, term ~ Term syntax Location
|
, term ~ Term syntax Location
|
||||||
, Carrier sig m
|
, Carrier sig m
|
||||||
)
|
)
|
||||||
=> Open (term -> Evaluator term hole value m a)
|
=> Open (term -> Evaluator term address value m a)
|
||||||
graphingTerms recur term@(Term (In a syntax)) = do
|
graphingTerms recur term@(Term (In a syntax)) = do
|
||||||
definedInModule <- currentModule
|
definedInModule <- currentModule
|
||||||
case toVertex a definedInModule syntax of
|
case toVertex a definedInModule syntax of
|
||||||
|
@ -1,48 +0,0 @@
|
|||||||
{-# LANGUAGE LambdaCase, TypeOperators, UndecidableInstances #-}
|
|
||||||
module Data.Abstract.Address.Located
|
|
||||||
( Located(..)
|
|
||||||
) where
|
|
||||||
|
|
||||||
import Control.Abstract
|
|
||||||
import Control.Effect.Carrier
|
|
||||||
import Control.Effect.Sum
|
|
||||||
import Data.Abstract.Module (ModuleInfo)
|
|
||||||
import Data.Abstract.Name
|
|
||||||
import Data.Abstract.Package (PackageInfo)
|
|
||||||
|
|
||||||
data Located address = Located
|
|
||||||
{ address :: address
|
|
||||||
, addressPackage :: {-# UNPACK #-} !PackageInfo
|
|
||||||
, addressModule :: !ModuleInfo
|
|
||||||
, addressName :: Name
|
|
||||||
, addressSpan :: Span
|
|
||||||
}
|
|
||||||
deriving (Eq, Ord, Show)
|
|
||||||
|
|
||||||
|
|
||||||
promoteA :: AllocatorC address m a -> AllocatorC (Located address) m a
|
|
||||||
promoteA = AllocatorC . runAllocatorC
|
|
||||||
|
|
||||||
instance ( Carrier (Allocator address :+: sig) (AllocatorC address m)
|
|
||||||
, Carrier sig m
|
|
||||||
, Member (Reader ModuleInfo) sig
|
|
||||||
, Member (Reader PackageInfo) sig
|
|
||||||
, Member (Reader Span) sig
|
|
||||||
, Monad m
|
|
||||||
)
|
|
||||||
=> Carrier (Allocator (Located address) :+: sig) (AllocatorC (Located address) m) where
|
|
||||||
ret = promoteA . ret
|
|
||||||
eff = handleSum
|
|
||||||
(AllocatorC . eff . handleCoercible)
|
|
||||||
(\ (Alloc name k) -> Located <$> promoteA (eff (L (Alloc name ret))) <*> currentPackage <*> currentModule <*> pure name <*> ask >>= k)
|
|
||||||
|
|
||||||
|
|
||||||
promoteD :: DerefC address value m a -> DerefC (Located address) value m a
|
|
||||||
promoteD = DerefC . runDerefC
|
|
||||||
|
|
||||||
instance (Carrier (Deref value :+: sig) (DerefC address value m), Carrier sig m, Monad m)
|
|
||||||
=> Carrier (Deref value :+: sig) (DerefC (Located address) value m) where
|
|
||||||
ret = promoteD . ret
|
|
||||||
eff = handleSum (DerefC . eff . handleCoercible) (\case
|
|
||||||
DerefCell cell k -> promoteD (eff (L (DerefCell cell ret))) >>= k
|
|
||||||
AssignCell value cell k -> promoteD (eff (L (AssignCell value cell ret))) >>= k)
|
|
@ -34,7 +34,6 @@ import Analysis.Abstract.Graph as Graph
|
|||||||
import Control.Abstract hiding (String)
|
import Control.Abstract hiding (String)
|
||||||
import Control.Abstract.PythonPackage as PythonPackage
|
import Control.Abstract.PythonPackage as PythonPackage
|
||||||
import Data.Abstract.Address.Hole as Hole
|
import Data.Abstract.Address.Hole as Hole
|
||||||
import Data.Abstract.Address.Located as Located
|
|
||||||
import Data.Abstract.Address.Monovariant as Monovariant
|
import Data.Abstract.Address.Monovariant as Monovariant
|
||||||
import Data.Abstract.Address.Precise as Precise
|
import Data.Abstract.Address.Precise as Precise
|
||||||
import Data.Abstract.BaseError (BaseError (..))
|
import Data.Abstract.BaseError (BaseError (..))
|
||||||
@ -114,7 +113,7 @@ runCallGraph :: ( VertexDeclarationWithStrategy (VertexDeclarationStrategy synta
|
|||||||
runCallGraph lang includePackages modules package
|
runCallGraph lang includePackages modules package
|
||||||
= fmap (simplify . fst)
|
= fmap (simplify . fst)
|
||||||
. runEvaluator
|
. runEvaluator
|
||||||
. graphing @_ @_ @_ @(Hole (Maybe Name) (Located Monovariant)) @Abstract
|
. graphing @_ @_ @_ @(Hole (Maybe Name) Monovariant) @Abstract
|
||||||
. runHeap
|
. runHeap
|
||||||
. runScopeGraph
|
. runScopeGraph
|
||||||
. caching
|
. caching
|
||||||
|
Loading…
Reference in New Issue
Block a user