Skip to content
This repository was archived by the owner on Apr 1, 2025. It is now read-only.

Commit 100d6a1

Browse files
committed
Extend the scope graph on assignment.
1 parent 196f2bf commit 100d6a1

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

semantic-core/src/Analysis/ScopeGraph.hs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,10 @@ scopeGraphAnalysis = Analysis{..}
104104
bindLoc <- asks (Map.lookup addr)
105105
cell <- gets (Map.lookup addr >=> nonEmpty . Set.toList)
106106
maybe (pure Nothing) (foldMapA (pure . Just . mappend (ScopeGraph (maybe Map.empty (\ bindLoc -> Map.singleton (Decl addr bindLoc) (Set.singleton ref)) bindLoc)))) cell
107-
assign addr v = modify (Map.insertWith (<>) addr (Set.singleton v))
107+
assign addr v = do
108+
ref <- asks Ref
109+
bindLoc <- asks (Map.lookup addr)
110+
modify (Map.insertWith (<>) addr (Set.singleton (ScopeGraph (maybe Map.empty (\ bindLoc -> Map.singleton (Decl addr bindLoc) (Set.singleton ref)) bindLoc) <> v)))
108111
abstract eval name body = do
109112
addr <- alloc name
110113
assign name (mempty @ScopeGraph)

0 commit comments

Comments
 (0)