1
1
mirror of https://github.com/github/semantic.git synced 2024-12-22 06:11:49 +03:00

Change Exports to a Map

This commit is contained in:
joshvera 2018-03-07 15:00:36 -05:00
parent 1f3ed79c01
commit 4c5e098123
3 changed files with 9 additions and 8 deletions

View File

@ -20,7 +20,7 @@ type DeadCodeEffects t v
= '[ State (Dead t) -- The set of dead terms = '[ State (Dead t) -- The set of dead terms
, Fail -- Failure with an error message , Fail -- Failure with an error message
, State (Store (LocationFor v) v) -- The heap , 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 , State (EnvironmentFor v) -- Global (imperative) environment
, Reader (EnvironmentFor v) -- Local environment (e.g. binding over a closure) , Reader (EnvironmentFor v) -- Local environment (e.g. binding over a closure)
, Reader (Linker t) -- Cache of unevaluated modules , Reader (Linker t) -- Cache of unevaluated modules

View File

@ -25,7 +25,7 @@ type EvaluationEffects t v
= '[ Fail -- Failure with an error message = '[ Fail -- Failure with an error message
, State (Store (LocationFor v) v) -- The heap , State (Store (LocationFor v) v) -- The heap
, State (EnvironmentFor v) -- Global (imperative) environment , 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 (EnvironmentFor v) -- Local environment (e.g. binding over a closure)
, Reader (Linker t) -- Cache of unevaluated modules , Reader (Linker t) -- Cache of unevaluated modules
, State (Linker (EnvironmentFor v)) -- Cache of evaluated modules , State (Linker (EnvironmentFor v)) -- Cache of evaluated modules

View File

@ -8,9 +8,10 @@ import Control.Monad.Effect.Fresh
import Control.Monad.Effect.NonDetEff import Control.Monad.Effect.NonDetEff
import Control.Monad.Effect.Reader import Control.Monad.Effect.Reader
import Control.Monad.Effect.State import Control.Monad.Effect.State
import Data.Abstract.Address
import Data.Abstract.Linker import Data.Abstract.Linker
import Data.Abstract.FreeVariables (Name) import Data.Abstract.FreeVariables (Name)
import Data.Set as Set import Data.Map as Map
import Data.Abstract.Value import Data.Abstract.Value
import Prelude hiding (fail) 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 () modifyGlobalEnv :: (EnvironmentFor value -> EnvironmentFor value) -> m ()
-- | Scope the set of exported symbols to the global environment -- | Scope the set of exported symbols to the global environment
addExport :: (Name, Name) -> m () addExport :: Name -> (Name, Maybe (Address (LocationFor value) value)) -> m ()
getExports :: m (Set (Name, Name)) getExports :: m (Map Name (Name, Maybe (Address (LocationFor value) value)))
setExports :: Set (Name, Name) -> m () setExports :: Map Name (Name, Maybe (Address (LocationFor value) value)) -> m ()
-- | Retrieve the local environment. -- | Retrieve the local environment.
askLocalEnv :: m (EnvironmentFor value) askLocalEnv :: m (EnvironmentFor value)
@ -55,7 +56,7 @@ class MonadFail m => MonadEvaluator term value m | m -> term, m -> value where
instance Members '[ Fail instance Members '[ Fail
, Reader (EnvironmentFor value) , Reader (EnvironmentFor value)
, State (Set (Name, Name)) , State (Map Name (Name, Maybe (Address (LocationFor value) value)))
, State (EnvironmentFor value) , State (EnvironmentFor value)
, State (StoreFor value) , State (StoreFor value)
, Reader (Linker term) , Reader (Linker term)
@ -66,7 +67,7 @@ instance Members '[ Fail
putGlobalEnv = Evaluator . put putGlobalEnv = Evaluator . put
modifyGlobalEnv f = Evaluator (modify f) modifyGlobalEnv f = Evaluator (modify f)
addExport = Evaluator . modify . Set.insert addExport key = Evaluator . modify . Map.insert key
getExports = Evaluator get getExports = Evaluator get
setExports = Evaluator . put setExports = Evaluator . put