1
1
mirror of https://github.com/github/semantic.git synced 2024-12-24 23:42:31 +03:00

Extend the scope graph on assignment.

This commit is contained in:
Rob Rix 2019-07-30 09:14:32 -04:00
parent 196f2bff17
commit 100d6a18ff
No known key found for this signature in database
GPG Key ID: F188A01508EA1CF7

View File

@ -104,7 +104,10 @@ scopeGraphAnalysis = Analysis{..}
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 (Decl addr bindLoc) (Set.singleton ref)) bindLoc)))) cell
assign addr v = modify (Map.insertWith (<>) addr (Set.singleton v))
assign addr v = do
ref <- asks Ref
bindLoc <- asks (Map.lookup addr)
modify (Map.insertWith (<>) addr (Set.singleton (ScopeGraph (maybe Map.empty (\ bindLoc -> Map.singleton (Decl addr bindLoc) (Set.singleton ref)) bindLoc) <> v)))
abstract eval name body = do
addr <- alloc name
assign name (mempty @ScopeGraph)