1
1
mirror of https://github.com/github/semantic.git synced 2024-11-28 10:15:55 +03:00

Revert "Run flow-insensitive analyses in an Alternative context."

This reverts commit 6199c15436.
This commit is contained in:
Rob Rix 2019-11-04 13:52:28 -05:00
parent ca50eb2fdb
commit d5b180b465
No known key found for this signature in database
GPG Key ID: F188A01508EA1CF7
4 changed files with 17 additions and 21 deletions

View File

@ -28,46 +28,45 @@ newtype FrameId name = FrameId { unFrameId :: name }
deriving (Eq, Ord, Show)
convergeTerm :: forall m sig value term address proxy
. ( Alternative m
, Carrier sig m
convergeTerm :: forall m sig a term address proxy
. ( Carrier sig m
, Effect sig
, Eq address
, Member Fresh sig
, Member (State (Heap address value)) sig
, Member (State (Heap address a)) sig
, Ord a
, Ord term
, Ord value
)
=> proxy address
-> (term -> NonDetC (ReaderC (Cache term value) (StateC (Cache term value) m)) value)
-> (term -> NonDetC (ReaderC (Cache term a) (StateC (Cache term a) m)) a)
-> term
-> m value
-> m (Set.Set a)
convergeTerm _ eval body = do
heap <- get
(cache, _) <- converge (Cache Map.empty :: Cache term value, heap :: Heap address value) $ \ (prevCache, _) -> runState (Cache Map.empty) . runReader prevCache $ do
(cache, _) <- converge (Cache Map.empty :: Cache term a, heap :: Heap address a) $ \ (prevCache, _) -> runState (Cache Map.empty) . runReader prevCache $ do
_ <- resetFresh . runNonDetM Set.singleton $ eval body
get
maybe empty (foldMapA pure) (Map.lookup body (unCache cache))
pure (fromMaybe mempty (Map.lookup body (unCache cache)))
cacheTerm :: forall m sig value term
cacheTerm :: forall m sig a term
. ( Alternative m
, Carrier sig m
, Member (Reader (Cache term value)) sig
, Member (State (Cache term value)) sig
, Ord value
, Member (Reader (Cache term a)) sig
, Member (State (Cache term a)) sig
, Ord a
, Ord term
)
=> (term -> m value)
-> (term -> m value)
=> (term -> m a)
-> (term -> m a)
cacheTerm eval term = do
cached <- gets (Map.lookup term . unCache)
case cached :: Maybe (Set.Set value) of
case cached :: Maybe (Set.Set a) of
Just results -> foldMapA pure results
Nothing -> do
results <- asks (fromMaybe mempty . Map.lookup term . unCache)
modify (Cache . Map.insert term (results :: Set.Set value) . unCache)
modify (Cache . Map.insert term (results :: Set.Set a) . unCache)
result <- eval term
result <$ modify (Cache . Map.insertWith (<>) term (Set.singleton (result :: value)) . unCache)
result <$ modify (Cache . Map.insertWith (<>) term (Set.singleton (result :: a)) . unCache)
runHeap :: StateC (Heap address a) m b -> m (Heap address a, b)
runHeap m = runState Map.empty m

View File

@ -92,7 +92,6 @@ runFile eval file = traverse run file
. runEnv @name
. runFail
. fmap fold
. runNonDetM Set.singleton
. convergeTerm (Proxy @name) (fix (cacheTerm . eval importGraphAnalysis))
-- FIXME: decompose into a product domain and two atomic domains

View File

@ -91,7 +91,6 @@ runFile eval file = traverse run file
. runReader (Map.empty @name @Ref)
. runFail
. fmap fold
. runNonDetM Set.singleton
. convergeTerm (Proxy @name) (fix (cacheTerm . eval scopeGraphAnalysis))
scopeGraphAnalysis

View File

@ -149,7 +149,6 @@ runFile eval file = traverse run file
v <- meta
bs <- m
v <$ for_ bs (unify v))
. runNonDetM Set.singleton
. convergeTerm (Proxy @name) (A.runHeap @name @(Type name) . fix (cacheTerm . eval typecheckingAnalysis))
typecheckingAnalysis