1
1
mirror of https://github.com/github/semantic.git synced 2024-11-28 01:47:01 +03:00

Construct scope graphs on deref.

This commit is contained in:
Rob Rix 2019-07-29 16:07:29 -04:00
parent 6cb9af299e
commit a4066b9df6
No known key found for this signature in database
GPG Key ID: F188A01508EA1CF7

View File

@ -95,7 +95,11 @@ scopeGraphAnalysis = Analysis{..}
loc <- ask @Loc
local (Map.insert name loc) m
lookupEnv = pure . Just
deref addr = gets (Map.lookup addr >=> nonEmpty . Set.toList) >>= maybe (pure Nothing) (foldMapA (pure . Just))
deref addr = do
loc <- ask @Loc
bindLoc <- asks (Map.lookup addr)
cell <- gets (Map.lookup addr >=> nonEmpty . Set.toList)
maybe (pure Nothing) (foldMapA (pure . Just . mappend (ScopeGraph (maybe Map.empty (\ bindLoc -> Map.singleton (Entry addr bindLoc) (Set.singleton (Entry addr loc))) bindLoc)))) cell
assign addr v = modify (Map.insertWith (<>) addr (Set.singleton v))
abstract eval name body = do
addr <- alloc name