mirror of
https://github.com/github/semantic.git
synced 2025-01-01 11:46:14 +03:00
Exports operates on locations.
This commit is contained in:
parent
da3e9ad59c
commit
74067b20c2
@ -26,7 +26,7 @@ modifyExports = modify'
|
||||
|
||||
-- | Add an export to the global export state.
|
||||
addExport :: Member (State (Exports location)) effects => Name -> Name -> Maybe (Address location value) -> Evaluator location value effects ()
|
||||
addExport name alias = modifyExports . insert name alias
|
||||
addExport name alias = modifyExports . insert name alias . fmap unAddress
|
||||
|
||||
-- | Sets the global export state for the lifetime of the given action.
|
||||
withExports :: Member (State (Exports location)) effects => Exports location -> Evaluator location value effects a -> Evaluator location value effects a
|
||||
|
@ -7,13 +7,12 @@ module Data.Abstract.Exports
|
||||
, toEnvironment
|
||||
) where
|
||||
|
||||
import Prelude hiding (null)
|
||||
import Prologue hiding (null)
|
||||
import Data.Abstract.Address
|
||||
import Data.Abstract.Environment (Environment, unpairs)
|
||||
import Data.Abstract.Name
|
||||
import qualified Data.Map as Map
|
||||
import Data.Semilattice.Lower
|
||||
import Prelude hiding (null)
|
||||
import Prologue hiding (null)
|
||||
|
||||
-- | A map of export names to an alias & address tuple.
|
||||
newtype Exports location = Exports { unExports :: Map.Map Name (Name, Maybe location) }
|
||||
@ -25,8 +24,8 @@ null = Map.null . unExports
|
||||
toEnvironment :: Exports location -> Environment location
|
||||
toEnvironment exports = unpairs (mapMaybe sequenceA (toList (unExports exports)))
|
||||
|
||||
insert :: Name -> Name -> Maybe (Address location value) -> Exports location -> Exports location
|
||||
insert name alias address = Exports . Map.insert name (alias, unAddress <$> address) . unExports
|
||||
insert :: Name -> Name -> Maybe location -> Exports location -> Exports location
|
||||
insert name alias address = Exports . Map.insert name (alias, address) . unExports
|
||||
|
||||
-- TODO: Should we filter for duplicates here?
|
||||
aliases :: Exports location -> [(Name, Name)]
|
||||
|
Loading…
Reference in New Issue
Block a user