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

Commit ed94104

Browse files
committed
Map entries to references.
1 parent a4066b9 commit ed94104

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

semantic-core/src/Analysis/ScopeGraph.hs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@ data Entry = Entry
3333
}
3434
deriving (Eq, Ord, Show)
3535

36-
newtype ScopeGraph = ScopeGraph { unScopeGraph :: Map.Map Entry (Set.Set Entry) }
36+
newtype Ref = Ref Loc
37+
deriving (Eq, Ord, Show)
38+
39+
newtype ScopeGraph = ScopeGraph { unScopeGraph :: Map.Map Entry (Set.Set Ref) }
3740
deriving (Eq, Ord, Show)
3841

3942
instance Semigroup ScopeGraph where
@@ -96,10 +99,10 @@ scopeGraphAnalysis = Analysis{..}
9699
local (Map.insert name loc) m
97100
lookupEnv = pure . Just
98101
deref addr = do
99-
loc <- ask @Loc
102+
ref <- asks Ref
100103
bindLoc <- asks (Map.lookup addr)
101104
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
105+
maybe (pure Nothing) (foldMapA (pure . Just . mappend (ScopeGraph (maybe Map.empty (\ bindLoc -> Map.singleton (Entry addr bindLoc) (Set.singleton ref)) bindLoc)))) cell
103106
assign addr v = modify (Map.insertWith (<>) addr (Set.singleton v))
104107
abstract eval name body = do
105108
addr <- alloc name

0 commit comments

Comments
 (0)