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

Commit a4066b9

Browse files
committed
Construct scope graphs on deref.
1 parent 6cb9af2 commit a4066b9

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

semantic-core/src/Analysis/ScopeGraph.hs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,11 @@ scopeGraphAnalysis = Analysis{..}
9595
loc <- ask @Loc
9696
local (Map.insert name loc) m
9797
lookupEnv = pure . Just
98-
deref addr = gets (Map.lookup addr >=> nonEmpty . Set.toList) >>= maybe (pure Nothing) (foldMapA (pure . Just))
98+
deref addr = do
99+
loc <- ask @Loc
100+
bindLoc <- asks (Map.lookup addr)
101+
cell <- gets (Map.lookup addr >=> nonEmpty . Set.toList)
102+
maybe (pure Nothing) (foldMapA (pure . Just . mappend (ScopeGraph (maybe Map.empty (\ bindLoc -> Map.singleton (Entry addr bindLoc) (Set.singleton (Entry addr loc))) bindLoc)))) cell
99103
assign addr v = modify (Map.insertWith (<>) addr (Set.singleton v))
100104
abstract eval name body = do
101105
addr <- alloc name

0 commit comments

Comments
 (0)