diff options
Diffstat (limited to 'compiler/main')
-rw-r--r-- | compiler/main/Annotations.hs | 142 | ||||
-rw-r--r-- | compiler/main/ErrUtils.hs | 2 | ||||
-rw-r--r-- | compiler/main/ErrUtils.hs-boot | 2 | ||||
-rw-r--r-- | compiler/main/HeaderInfo.hs | 6 | ||||
-rw-r--r-- | compiler/main/HscStats.hs | 2 | ||||
-rw-r--r-- | compiler/main/StaticPtrTable.hs | 6 | ||||
-rw-r--r-- | compiler/main/SysTools.hs | 2 | ||||
-rw-r--r-- | compiler/main/SysTools/ExtraObj.hs | 4 | ||||
-rw-r--r-- | compiler/main/SysTools/Process.hs | 2 | ||||
-rw-r--r-- | compiler/main/UnitInfo.hs | 4 | ||||
-rw-r--r-- | compiler/main/UpdateCafInfos.hs | 10 |
11 files changed, 20 insertions, 162 deletions
diff --git a/compiler/main/Annotations.hs b/compiler/main/Annotations.hs deleted file mode 100644 index 3c4340e900..0000000000 --- a/compiler/main/Annotations.hs +++ /dev/null @@ -1,142 +0,0 @@ --- | --- Support for source code annotation feature of GHC. That is the ANN pragma. --- --- (c) The University of Glasgow 2006 --- (c) The GRASP/AQUA Project, Glasgow University, 1992-1998 --- -{-# LANGUAGE DeriveFunctor #-} -module Annotations ( - -- * Main Annotation data types - Annotation(..), AnnPayload, - AnnTarget(..), CoreAnnTarget, - - -- * AnnEnv for collecting and querying Annotations - AnnEnv, - mkAnnEnv, extendAnnEnvList, plusAnnEnv, emptyAnnEnv, - findAnns, findAnnsByTypeRep, - deserializeAnns - ) where - -import GhcPrelude - -import Binary -import Module ( Module - , ModuleEnv, emptyModuleEnv, extendModuleEnvWith - , plusModuleEnv_C, lookupWithDefaultModuleEnv - , mapModuleEnv ) -import NameEnv -import Name -import Outputable -import GHC.Serialized - -import Control.Monad -import Data.Maybe -import Data.Typeable -import Data.Word ( Word8 ) - - --- | Represents an annotation after it has been sufficiently desugared from --- it's initial form of 'HsDecls.AnnDecl' -data Annotation = Annotation { - ann_target :: CoreAnnTarget, -- ^ The target of the annotation - ann_value :: AnnPayload - } - -type AnnPayload = Serialized -- ^ The "payload" of an annotation - -- allows recovery of its value at a given type, - -- and can be persisted to an interface file - --- | An annotation target -data AnnTarget name - = NamedTarget name -- ^ We are annotating something with a name: - -- a type or identifier - | ModuleTarget Module -- ^ We are annotating a particular module - deriving (Functor) - --- | The kind of annotation target found in the middle end of the compiler -type CoreAnnTarget = AnnTarget Name - -instance Outputable name => Outputable (AnnTarget name) where - ppr (NamedTarget nm) = text "Named target" <+> ppr nm - ppr (ModuleTarget mod) = text "Module target" <+> ppr mod - -instance Binary name => Binary (AnnTarget name) where - put_ bh (NamedTarget a) = do - putByte bh 0 - put_ bh a - put_ bh (ModuleTarget a) = do - putByte bh 1 - put_ bh a - get bh = do - h <- getByte bh - case h of - 0 -> liftM NamedTarget $ get bh - _ -> liftM ModuleTarget $ get bh - -instance Outputable Annotation where - ppr ann = ppr (ann_target ann) - --- | A collection of annotations -data AnnEnv = MkAnnEnv { ann_mod_env :: !(ModuleEnv [AnnPayload]) - , ann_name_env :: !(NameEnv [AnnPayload]) - } - --- | An empty annotation environment. -emptyAnnEnv :: AnnEnv -emptyAnnEnv = MkAnnEnv emptyModuleEnv emptyNameEnv - --- | Construct a new annotation environment that contains the list of --- annotations provided. -mkAnnEnv :: [Annotation] -> AnnEnv -mkAnnEnv = extendAnnEnvList emptyAnnEnv - --- | Add the given annotation to the environment. -extendAnnEnvList :: AnnEnv -> [Annotation] -> AnnEnv -extendAnnEnvList env = - foldl' extendAnnEnv env - -extendAnnEnv :: AnnEnv -> Annotation -> AnnEnv -extendAnnEnv (MkAnnEnv mod_env name_env) (Annotation tgt payload) = - case tgt of - NamedTarget name -> MkAnnEnv mod_env (extendNameEnv_C (++) name_env name [payload]) - ModuleTarget mod -> MkAnnEnv (extendModuleEnvWith (++) mod_env mod [payload]) name_env - --- | Union two annotation environments. -plusAnnEnv :: AnnEnv -> AnnEnv -> AnnEnv -plusAnnEnv a b = - MkAnnEnv { ann_mod_env = plusModuleEnv_C (++) (ann_mod_env a) (ann_mod_env b) - , ann_name_env = plusNameEnv_C (++) (ann_name_env a) (ann_name_env b) - } - --- | Find the annotations attached to the given target as 'Typeable' --- values of your choice. If no deserializer is specified, --- only transient annotations will be returned. -findAnns :: Typeable a => ([Word8] -> a) -> AnnEnv -> CoreAnnTarget -> [a] -findAnns deserialize env - = mapMaybe (fromSerialized deserialize) . findAnnPayloads env - --- | Find the annotations attached to the given target as 'Typeable' --- values of your choice. If no deserializer is specified, --- only transient annotations will be returned. -findAnnsByTypeRep :: AnnEnv -> CoreAnnTarget -> TypeRep -> [[Word8]] -findAnnsByTypeRep env target tyrep - = [ ws | Serialized tyrep' ws <- findAnnPayloads env target - , tyrep' == tyrep ] - --- | Find payloads for the given 'CoreAnnTarget' in an 'AnnEnv'. -findAnnPayloads :: AnnEnv -> CoreAnnTarget -> [AnnPayload] -findAnnPayloads env target = - case target of - ModuleTarget mod -> lookupWithDefaultModuleEnv (ann_mod_env env) [] mod - NamedTarget name -> fromMaybe [] $ lookupNameEnv (ann_name_env env) name - --- | Deserialize all annotations of a given type. This happens lazily, that is --- no deserialization will take place until the [a] is actually demanded and --- the [a] can also be empty (the UniqFM is not filtered). -deserializeAnns :: Typeable a => ([Word8] -> a) -> AnnEnv -> (ModuleEnv [a], NameEnv [a]) -deserializeAnns deserialize env - = ( mapModuleEnv deserAnns (ann_mod_env env) - , mapNameEnv deserAnns (ann_name_env env) - ) - where deserAnns = mapMaybe (fromSerialized deserialize) - diff --git a/compiler/main/ErrUtils.hs b/compiler/main/ErrUtils.hs index 118c5a70ba..0096891e54 100644 --- a/compiler/main/ErrUtils.hs +++ b/compiler/main/ErrUtils.hs @@ -71,7 +71,7 @@ import Exception import Outputable import Panic import qualified PprColour as Col -import SrcLoc +import GHC.Types.SrcLoc as SrcLoc import GHC.Driver.Session import FastString (unpackFS) import StringBuffer (atLine, hGetStringBuffer, len, lexemeToString) diff --git a/compiler/main/ErrUtils.hs-boot b/compiler/main/ErrUtils.hs-boot index e071d09272..f7f8b12f80 100644 --- a/compiler/main/ErrUtils.hs-boot +++ b/compiler/main/ErrUtils.hs-boot @@ -4,7 +4,7 @@ module ErrUtils where import GhcPrelude import Outputable (SDoc, PprStyle ) -import SrcLoc (SrcSpan) +import GHC.Types.SrcLoc (SrcSpan) import Json import {-# SOURCE #-} GHC.Driver.Session ( DynFlags ) diff --git a/compiler/main/HeaderInfo.hs b/compiler/main/HeaderInfo.hs index 8d88f7b097..cb1b1e3c2b 100644 --- a/compiler/main/HeaderInfo.hs +++ b/compiler/main/HeaderInfo.hs @@ -28,10 +28,10 @@ import Parser ( parseHeader ) import Lexer import FastString import GHC.Hs -import Module +import GHC.Types.Module import PrelNames import StringBuffer -import SrcLoc +import GHC.Types.SrcLoc import GHC.Driver.Session import ErrUtils import Util @@ -40,7 +40,7 @@ import Maybes import Bag ( emptyBag, listToBag, unitBag ) import MonadUtils import Exception -import BasicTypes +import GHC.Types.Basic import qualified GHC.LanguageExtensions as LangExt import Control.Monad diff --git a/compiler/main/HscStats.hs b/compiler/main/HscStats.hs index 5c034a373f..67eddf1f2a 100644 --- a/compiler/main/HscStats.hs +++ b/compiler/main/HscStats.hs @@ -15,7 +15,7 @@ import GhcPrelude import Bag import GHC.Hs import Outputable -import SrcLoc +import GHC.Types.SrcLoc import Util import Data.Char diff --git a/compiler/main/StaticPtrTable.hs b/compiler/main/StaticPtrTable.hs index 81a72230f3..24bb7c974f 100644 --- a/compiler/main/StaticPtrTable.hs +++ b/compiler/main/StaticPtrTable.hs @@ -130,10 +130,10 @@ import GHC.Core.Utils (collectMakeStaticArgs) import GHC.Core.DataCon import GHC.Driver.Session import GHC.Driver.Types -import Id +import GHC.Types.Id import GHC.Core.Make (mkStringExprFSWith) -import Module -import Name +import GHC.Types.Module +import GHC.Types.Name import Outputable import GHC.Platform import PrelNames diff --git a/compiler/main/SysTools.hs b/compiler/main/SysTools.hs index b2b13d424b..ea6eb178ee 100644 --- a/compiler/main/SysTools.hs +++ b/compiler/main/SysTools.hs @@ -42,7 +42,7 @@ import GhcPrelude import GHC.Settings -import Module +import GHC.Types.Module import GHC.Driver.Packages import Outputable import ErrUtils diff --git a/compiler/main/SysTools/ExtraObj.hs b/compiler/main/SysTools/ExtraObj.hs index 73b28a368f..27cc4f7aae 100644 --- a/compiler/main/SysTools/ExtraObj.hs +++ b/compiler/main/SysTools/ExtraObj.hs @@ -19,8 +19,8 @@ import GHC.Driver.Session import GHC.Driver.Packages import GHC.Platform import Outputable -import SrcLoc ( noSrcSpan ) -import Module +import GHC.Types.SrcLoc ( noSrcSpan ) +import GHC.Types.Module import Elf import Util import GhcPrelude diff --git a/compiler/main/SysTools/Process.hs b/compiler/main/SysTools/Process.hs index aa5d6617d3..a95d9c958a 100644 --- a/compiler/main/SysTools/Process.hs +++ b/compiler/main/SysTools/Process.hs @@ -18,7 +18,7 @@ import Outputable import Panic import GhcPrelude import Util -import SrcLoc ( SrcLoc, mkSrcLoc, noSrcSpan, mkSrcSpan ) +import GHC.Types.SrcLoc ( SrcLoc, mkSrcLoc, noSrcSpan, mkSrcSpan ) import Control.Concurrent import Data.Char diff --git a/compiler/main/UnitInfo.hs b/compiler/main/UnitInfo.hs index de8c94541a..b1a307a7fe 100644 --- a/compiler/main/UnitInfo.hs +++ b/compiler/main/UnitInfo.hs @@ -37,8 +37,8 @@ import Data.Version import FastString import Outputable -import Module -import Unique +import GHC.Types.Module as Module +import GHC.Types.Unique -- ----------------------------------------------------------------------------- -- Our UnitInfo type is the InstalledPackageInfo from ghc-boot, diff --git a/compiler/main/UpdateCafInfos.hs b/compiler/main/UpdateCafInfos.hs index dd4881ec6e..c8a0e725e3 100644 --- a/compiler/main/UpdateCafInfos.hs +++ b/compiler/main/UpdateCafInfos.hs @@ -9,13 +9,13 @@ import GhcPrelude import GHC.Core import GHC.Driver.Session import GHC.Driver.Types -import Id -import IdInfo +import GHC.Types.Id +import GHC.Types.Id.Info import GHC.Core.InstEnv -import NameEnv -import NameSet +import GHC.Types.Name.Env +import GHC.Types.Name.Set import Util -import Var +import GHC.Types.Var import Outputable #include "HsVersions.h" |