From 4c5e098123fb3145e38950a0d4802f6b5a74c3ea Mon Sep 17 00:00:00 2001 From: joshvera Date: Wed, 7 Mar 2018 15:00:36 -0500 Subject: [PATCH] Change Exports to a Map --- src/Analysis/Abstract/Dead.hs | 2 +- src/Analysis/Abstract/Evaluating.hs | 2 +- src/Control/Abstract/Evaluator.hs | 13 +++++++------ 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/Analysis/Abstract/Dead.hs b/src/Analysis/Abstract/Dead.hs index f3627abc8..0f5bbe452 100644 --- a/src/Analysis/Abstract/Dead.hs +++ b/src/Analysis/Abstract/Dead.hs @@ -20,7 +20,7 @@ type DeadCodeEffects t v = '[ State (Dead t) -- The set of dead terms , Fail -- Failure with an error message , State (Store (LocationFor v) v) -- The heap - , State (Set (Name, Name)) -- Set of exports + , State (Map Name (Name, Maybe (Address (LocationFor v) v))) -- Set of exports , State (EnvironmentFor v) -- Global (imperative) environment , Reader (EnvironmentFor v) -- Local environment (e.g. binding over a closure) , Reader (Linker t) -- Cache of unevaluated modules diff --git a/src/Analysis/Abstract/Evaluating.hs b/src/Analysis/Abstract/Evaluating.hs index b92daceaa..9d2c74288 100644 --- a/src/Analysis/Abstract/Evaluating.hs +++ b/src/Analysis/Abstract/Evaluating.hs @@ -25,7 +25,7 @@ type EvaluationEffects t v = '[ Fail -- Failure with an error message , State (Store (LocationFor v) v) -- The heap , State (EnvironmentFor v) -- Global (imperative) environment - , State (Set (Name, Name)) -- Set of exports + , State (Map Name (Name, Maybe (Address (LocationFor v) v))) -- Set of exports , Reader (EnvironmentFor v) -- Local environment (e.g. binding over a closure) , Reader (Linker t) -- Cache of unevaluated modules , State (Linker (EnvironmentFor v)) -- Cache of evaluated modules diff --git a/src/Control/Abstract/Evaluator.hs b/src/Control/Abstract/Evaluator.hs index dcbe68b7c..39147b278 100644 --- a/src/Control/Abstract/Evaluator.hs +++ b/src/Control/Abstract/Evaluator.hs @@ -8,9 +8,10 @@ import Control.Monad.Effect.Fresh import Control.Monad.Effect.NonDetEff import Control.Monad.Effect.Reader import Control.Monad.Effect.State +import Data.Abstract.Address import Data.Abstract.Linker import Data.Abstract.FreeVariables (Name) -import Data.Set as Set +import Data.Map as Map import Data.Abstract.Value import Prelude hiding (fail) @@ -29,9 +30,9 @@ class MonadFail m => MonadEvaluator term value m | m -> term, m -> value where modifyGlobalEnv :: (EnvironmentFor value -> EnvironmentFor value) -> m () -- | Scope the set of exported symbols to the global environment - addExport :: (Name, Name) -> m () - getExports :: m (Set (Name, Name)) - setExports :: Set (Name, Name) -> m () + addExport :: Name -> (Name, Maybe (Address (LocationFor value) value)) -> m () + getExports :: m (Map Name (Name, Maybe (Address (LocationFor value) value))) + setExports :: Map Name (Name, Maybe (Address (LocationFor value) value)) -> m () -- | Retrieve the local environment. askLocalEnv :: m (EnvironmentFor value) @@ -55,7 +56,7 @@ class MonadFail m => MonadEvaluator term value m | m -> term, m -> value where instance Members '[ Fail , Reader (EnvironmentFor value) - , State (Set (Name, Name)) + , State (Map Name (Name, Maybe (Address (LocationFor value) value))) , State (EnvironmentFor value) , State (StoreFor value) , Reader (Linker term) @@ -66,7 +67,7 @@ instance Members '[ Fail putGlobalEnv = Evaluator . put modifyGlobalEnv f = Evaluator (modify f) - addExport = Evaluator . modify . Set.insert + addExport key = Evaluator . modify . Map.insert key getExports = Evaluator get setExports = Evaluator . put