1
1
mirror of https://github.com/github/semantic.git synced 2024-12-27 00:44:57 +03:00

Use the precise heap carrier to implement the Concrete analysis.

This commit is contained in:
Rob Rix 2019-11-04 13:35:52 -05:00
parent 327208eb15
commit 9327861790
No known key found for this signature in database
GPG Key ID: F188A01508EA1CF7

View File

@ -13,6 +13,7 @@ import qualified Algebra.Graph as G
import qualified Algebra.Graph.Export.Dot as G
import Analysis.Analysis
import qualified Analysis.Carrier.Env.Precise as A
import qualified Analysis.Carrier.Heap.Precise as A
import Analysis.File
import Control.Applicative (Alternative (..))
import Control.Carrier.Fail.WithLoc
@ -84,7 +85,7 @@ concrete
concrete eval
= run
. runFresh
. runHeap
. A.runHeap
. traverse (runFile eval)
runFile
@ -94,6 +95,7 @@ runFile
, Foldable term
, IsString name
, Member Fresh sig
, Member (A.Heap Precise (Concrete term name)) sig
, Member (State (Heap term name)) sig
, Ord name
, Show name
@ -119,6 +121,7 @@ concreteAnalysis :: ( Carrier sig m
, Foldable term
, IsString name
, Member (A.Env name Precise) sig
, Member (A.Heap Precise (Concrete term name)) sig
, Member (Reader (Env name)) sig
, Member (Reader Path.AbsRelFile) sig
, Member (Reader Span) sig
@ -130,8 +133,8 @@ concreteAnalysis :: ( Carrier sig m
)
=> Analysis term name Precise (Concrete term name) m
concreteAnalysis = Analysis{..}
where deref = gets . IntMap.lookup
assign addr value = modify (IntMap.insert addr value)
where deref = A.deref
assign = A.assign
abstract _ name body = do
path <- ask
span <- ask
@ -179,10 +182,6 @@ lookupConcrete heap name = run . evalState IntSet.empty . runNonDet . inConcrete
maybeA = maybe empty pure
runHeap :: StateC (Heap term name) m a -> m (Heap term name, a)
runHeap = runState mempty
-- | 'heapGraph', 'heapValueGraph', and 'heapAddressGraph' allow us to conveniently export SVGs of the heap:
--
-- > λ let (heap, res) = concrete [ruby]