1
1
mirror of https://github.com/github/semantic.git synced 2024-12-15 01:51:39 +03:00

Set currentScope and currentFrame after running an initial action

Co-Authored-By: Josh Vera <vera@github.com>
This commit is contained in:
Rick Winfrey 2018-11-09 12:43:35 -08:00
parent cbafcd8114
commit d020f71862
2 changed files with 6 additions and 2 deletions

View File

@ -177,7 +177,9 @@ withFrame address action = do
prevFrame <- currentFrame @address @value
modify @(Heap address address value) (\h -> h { Heap.currentFrame = Just address })
value <- action
modify @(Heap address address value) (\h -> h { Heap.currentFrame = prevFrame })
case prevFrame of
Nothing -> modify @(Heap address address value) (\h -> h { Heap.currentFrame = Just address })
_ -> modify @(Heap address address value) (\h -> h { Heap.currentFrame = prevFrame })
pure value
-- box :: ( Member (Allocator address) effects

View File

@ -191,7 +191,9 @@ withScope scope action = do
prevScope <- currentScope
modify (\g -> g { ScopeGraph.currentScope = Just scope })
value <- action
modify (\g -> g { ScopeGraph.currentScope = prevScope })
case prevScope of
Nothing -> modify (\g -> g { ScopeGraph.currentScope = Just scope })
_ -> modify (\g -> g { ScopeGraph.currentScope = prevScope })
pure value
putCurrentScope :: (Ord address, Member (State (ScopeGraph address)) sig, Carrier sig m) => address -> Evaluator term address value m ()