From e92846c518829df368b4c32f11cb920313c5d766 Mon Sep 17 00:00:00 2001 From: Charlie Somerville Date: Wed, 8 Aug 2018 12:21:48 +1000 Subject: [PATCH] expand Ctx to EvalContext in get, put, and with function names --- src/Analysis/Abstract/Caching.hs | 4 ++-- src/Control/Abstract/Environment.hs | 34 ++++++++++++++--------------- src/Control/Abstract/Heap.hs | 2 +- src/Control/Abstract/Value.hs | 2 +- src/Data/Abstract/Value/Concrete.hs | 2 +- 5 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/Analysis/Abstract/Caching.hs b/src/Analysis/Abstract/Caching.hs index bb2131aa1..2175fe741 100644 --- a/src/Analysis/Abstract/Caching.hs +++ b/src/Analysis/Abstract/Caching.hs @@ -93,8 +93,8 @@ convergingModules recur m = do c <- getConfiguration (subterm (moduleBody m)) -- Convergence here is predicated upon an Eq instance, not α-equivalence cache <- converge lowerBound (\ prevCache -> isolateCache $ do - TermEvaluator (putHeap (configurationHeap c)) - TermEvaluator (putCtx (configurationContext c)) + TermEvaluator (putHeap (configurationHeap c)) + TermEvaluator (putEvalContext (configurationContext c)) -- We need to reset fresh generation so that this invocation converges. resetFresh 0 $ -- This is subtle: though the calling context supports nondeterminism, we want diff --git a/src/Control/Abstract/Environment.hs b/src/Control/Abstract/Environment.hs index f9a783d5c..15c17bf7a 100644 --- a/src/Control/Abstract/Environment.hs +++ b/src/Control/Abstract/Environment.hs @@ -2,9 +2,9 @@ module Control.Abstract.Environment ( Environment , Exports -, getCtx -, putCtx -, withCtx +, getEvalContext +, putEvalContext +, withEvalContext , getEnv , export , lookupEnv @@ -30,26 +30,26 @@ import Data.Abstract.Name import Prologue -- | Retrieve the current execution context -getCtx :: Member (Env address) effects => Evaluator address value effects (EvalContext address) -getCtx = send GetCtx +getEvalContext :: Member (Env address) effects => Evaluator address value effects (EvalContext address) +getEvalContext = send GetCtx -- | Retrieve the current environment getEnv :: Member (Env address) effects => Evaluator address value effects (Environment address) -getEnv = ctxEnvironment <$> getCtx +getEnv = ctxEnvironment <$> getEvalContext -- | Replace the execution context. This is only for use in Analysis.Abstract.Caching. -putCtx :: Member (Env address) effects => EvalContext address -> Evaluator address value effects () -putCtx = send . PutCtx +putEvalContext :: Member (Env address) effects => EvalContext address -> Evaluator address value effects () +putEvalContext = send . PutCtx -withCtx :: Member (Env address) effects - => EvalContext address - -> Evaluator address value effects a - -> Evaluator address value effects a -withCtx ctx comp = do - oldCtx <- getCtx - putCtx ctx +withEvalContext :: Member (Env address) effects + => EvalContext address + -> Evaluator address value effects a + -> Evaluator address value effects a +withEvalContext ctx comp = do + oldCtx <- getEvalContext + putEvalContext ctx value <- comp - putCtx oldCtx + putEvalContext oldCtx pure value -- | Add an export to the global export state. @@ -77,7 +77,7 @@ close :: Member (Env address) effects => Set Name -> Evaluator address value eff close = send . Close self :: Member (Env address) effects => Evaluator address value effects (Maybe address) -self = ctxSelf <$> getCtx +self = ctxSelf <$> getEvalContext -- Effects diff --git a/src/Control/Abstract/Heap.hs b/src/Control/Abstract/Heap.hs index cb76f5fa7..30adce7fa 100644 --- a/src/Control/Abstract/Heap.hs +++ b/src/Control/Abstract/Heap.hs @@ -39,7 +39,7 @@ import Prologue -- | Get the current 'Configuration' with a passed-in term. getConfiguration :: (Member (Reader (Live address)) effects, Member (Env address) effects, Member (State (Heap address (Cell address) value)) effects) => term -> TermEvaluator term address value effects (Configuration term address (Cell address) value) -getConfiguration term = Configuration term <$> TermEvaluator askRoots <*> TermEvaluator getCtx <*> TermEvaluator getHeap +getConfiguration term = Configuration term <$> TermEvaluator askRoots <*> TermEvaluator getEvalContext <*> TermEvaluator getHeap -- | Retrieve the heap. diff --git a/src/Control/Abstract/Value.hs b/src/Control/Abstract/Value.hs index 2c43f3134..559869aa3 100644 --- a/src/Control/Abstract/Value.hs +++ b/src/Control/Abstract/Value.hs @@ -219,7 +219,7 @@ evaluateInScopedEnv :: ( AbstractValue address value effects evaluateInScopedEnv receiver term = do scopedEnv <- scopedEnvironment receiver env <- maybeM getEnv scopedEnv - withCtx (EvalContext (Just receiver) env) term + withEvalContext (EvalContext (Just receiver) env) term -- | Evaluates a 'Value' returning the referenced value diff --git a/src/Data/Abstract/Value/Concrete.hs b/src/Data/Abstract/Value/Concrete.hs index 6ec6bd69a..b96ecc5d8 100644 --- a/src/Data/Abstract/Value/Concrete.hs +++ b/src/Data/Abstract/Value/Concrete.hs @@ -87,7 +87,7 @@ runFunction toEvaluator fromEvaluator = interpret $ \case withCurrentPackage packageInfo . withCurrentModule moduleInfo $ do bindings <- foldr (\ (name, addr) rest -> Env.insert name addr <$> rest) (pure lowerBound) (zip names params) let fnCtx = EvalContext (Just self) (Env.push env) - withCtx fnCtx (catchReturn (bindAll bindings *> runFunction toEvaluator fromEvaluator (toEvaluator body))) + withEvalContext fnCtx (catchReturn (bindAll bindings *> runFunction toEvaluator fromEvaluator (toEvaluator body))) _ -> throwValueError (CallError op) >>= box