mirror of
https://github.com/github/semantic.git
synced 2024-12-03 00:16:52 +03:00
Add lookupFrameAddress to Heap
Co-Authored-By: Rick Winfrey <rick.winfrey@gmail.com>
This commit is contained in:
parent
f51d3a90a8
commit
a49b7f5440
@ -72,6 +72,20 @@ lookup address (EPath label scope path) declaration heap = do
|
||||
nextAddress <- Map.lookup scope scopeMap
|
||||
lookup nextAddress path declaration heap
|
||||
|
||||
lookupFrameAddress :: (Ord address, Ord scope) => Path scope -> Heap scope address value -> Maybe address
|
||||
lookupFrameAddress path h@Heap{..} = do
|
||||
frameAddress <- currentFrame
|
||||
go path frameAddress
|
||||
where
|
||||
go path address = case path of
|
||||
DPath decl position -> pure address
|
||||
EPath edge nextScopeAddress path' -> do
|
||||
linkMap <- frameLinks address h
|
||||
frameAddress <- do
|
||||
scopeMap <- Map.lookup edge linkMap
|
||||
Map.lookup nextScopeAddress scopeMap
|
||||
go path' frameAddress
|
||||
|
||||
newFrame :: (Ord address) => scope -> address -> Map EdgeLabel (Map scope address) -> Heap scope address value -> Heap scope address value
|
||||
newFrame scope address links = insertFrame address (Frame scope links mempty)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user