diff options
author | Sylvain Henry <sylvain@haskus.fr> | 2020-11-03 12:04:53 +0100 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2020-11-21 01:14:09 -0500 |
commit | ecfd0278cb811c93853c176fe5df60222d1a8fb5 (patch) | |
tree | 7fc212d973a0d9e5e67e13011bf30907b1458228 /compiler/GHC/Driver/Pipeline | |
parent | 53ad67eacacde8fde452f1a323d5886183375182 (diff) | |
download | haskell-ecfd0278cb811c93853c176fe5df60222d1a8fb5.tar.gz |
Move Plugins into HscEnv (#17957)
Loaded plugins have nothing to do in DynFlags so this patch moves them
into HscEnv (session state).
"DynFlags plugins" become "Driver plugins" to still be able to register
static plugins.
Bump haddock submodule
Diffstat (limited to 'compiler/GHC/Driver/Pipeline')
-rw-r--r-- | compiler/GHC/Driver/Pipeline/Monad.hs | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/compiler/GHC/Driver/Pipeline/Monad.hs b/compiler/GHC/Driver/Pipeline/Monad.hs index b2db6170ec..03ee6e14f6 100644 --- a/compiler/GHC/Driver/Pipeline/Monad.hs +++ b/compiler/GHC/Driver/Pipeline/Monad.hs @@ -7,7 +7,7 @@ module GHC.Driver.Pipeline.Monad ( , PhasePlus(..) , PipeEnv(..), PipeState(..), PipelineOutput(..) , getPipeEnv, getPipeState, setDynFlags, setModLocation, setForeignOs, setIface - , pipeStateDynFlags, pipeStateModIface + , pipeStateDynFlags, pipeStateModIface, setPlugins ) where import GHC.Prelude @@ -18,6 +18,7 @@ import GHC.Utils.Outputable import GHC.Driver.Session import GHC.Driver.Phases import GHC.Driver.Env +import GHC.Driver.Plugins import GHC.SysTools.FileCleanup (TempFileLifetime) @@ -69,9 +70,9 @@ data PipeEnv = PipeEnv { -- PipeState: information that might change during a pipeline run data PipeState = PipeState { hsc_env :: HscEnv, - -- ^ only the DynFlags change in the HscEnv. The DynFlags change - -- at various points, for example when we read the OPTIONS_GHC - -- pragmas in the Cpp phase. + -- ^ only the DynFlags and the Plugins change in the HscEnv. The + -- DynFlags change at various points, for example when we read the + -- OPTIONS_GHC pragmas in the Cpp phase. maybe_loc :: Maybe ModLocation, -- ^ the ModLocation. This is discovered during compilation, -- in the Hsc phase where we read the module header. @@ -117,6 +118,11 @@ setDynFlags :: DynFlags -> CompPipeline () setDynFlags dflags = P $ \_env state -> return (state{hsc_env= (hsc_env state){ hsc_dflags = dflags }}, ()) +setPlugins :: [LoadedPlugin] -> [StaticPlugin] -> CompPipeline () +setPlugins dyn static = P $ \_env state -> + let hsc_env' = (hsc_env state){ hsc_plugins = dyn, hsc_static_plugins = static } + in return (state{hsc_env = hsc_env'}, ()) + setModLocation :: ModLocation -> CompPipeline () setModLocation loc = P $ \_env state -> return (state{ maybe_loc = Just loc }, ()) |