mirror of
https://github.com/github/semantic.git
synced 2024-11-28 10:15:55 +03:00
Use the Env effect to define the scope graph analysis.
This commit is contained in:
parent
0f7be2084d
commit
eb591f94df
@ -8,6 +8,7 @@ module Analysis.ScopeGraph
|
|||||||
) where
|
) where
|
||||||
|
|
||||||
import Analysis.Analysis
|
import Analysis.Analysis
|
||||||
|
import Analysis.Carrier.Env.Monovariant as A
|
||||||
import Analysis.File
|
import Analysis.File
|
||||||
import Analysis.FlowInsensitive
|
import Analysis.FlowInsensitive
|
||||||
import Control.Applicative (Alternative (..))
|
import Control.Applicative (Alternative (..))
|
||||||
@ -86,6 +87,7 @@ runFile
|
|||||||
runFile eval file = traverse run file
|
runFile eval file = traverse run file
|
||||||
where run = runReader (filePath file)
|
where run = runReader (filePath file)
|
||||||
. runReader (fileSpan file)
|
. runReader (fileSpan file)
|
||||||
|
. runEnv @name
|
||||||
. runReader (Map.empty @name @Ref)
|
. runReader (Map.empty @name @Ref)
|
||||||
. runFail
|
. runFail
|
||||||
. fmap fold
|
. fmap fold
|
||||||
@ -95,6 +97,7 @@ scopeGraphAnalysis
|
|||||||
:: ( Alternative m
|
:: ( Alternative m
|
||||||
, Carrier sig m
|
, Carrier sig m
|
||||||
, Member (Reader Path.AbsRelFile) sig
|
, Member (Reader Path.AbsRelFile) sig
|
||||||
|
, Member (Env name name) sig
|
||||||
, Member (Reader Span) sig
|
, Member (Reader Span) sig
|
||||||
, Member (Reader (Map.Map name Ref)) sig
|
, Member (Reader (Map.Map name Ref)) sig
|
||||||
, Member (State (Heap name (ScopeGraph name))) sig
|
, Member (State (Heap name (ScopeGraph name))) sig
|
||||||
@ -102,11 +105,9 @@ scopeGraphAnalysis
|
|||||||
)
|
)
|
||||||
=> Analysis term name name (ScopeGraph name) m
|
=> Analysis term name name (ScopeGraph name) m
|
||||||
scopeGraphAnalysis = Analysis{..}
|
scopeGraphAnalysis = Analysis{..}
|
||||||
where alloc = pure
|
where alloc = A.alloc
|
||||||
bind name _ m = do
|
bind = A.bind
|
||||||
ref <- askRef
|
lookupEnv = A.lookupEnv
|
||||||
local (Map.insert name ref) m
|
|
||||||
lookupEnv = pure . Just
|
|
||||||
deref addr = do
|
deref addr = do
|
||||||
ref <- askRef
|
ref <- askRef
|
||||||
bindRef <- asks (Map.lookup addr)
|
bindRef <- asks (Map.lookup addr)
|
||||||
|
Loading…
Reference in New Issue
Block a user