diff options
author | Sylvain Henry <sylvain@haskus.fr> | 2021-12-14 11:23:02 +0100 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-12-21 01:46:39 -0500 |
commit | 9728d6c2b62f38f79c8833b1819200985fe173dc (patch) | |
tree | 8e44abae10080473b22ad71f750613cdc1fa9a96 /compiler/GHC/Runtime | |
parent | 00b55bfcd982bed2c9fc02d9c3ca66ba9d41bb5c (diff) | |
download | haskell-9728d6c2b62f38f79c8833b1819200985fe173dc.tar.gz |
Give plugins a better interface (#17957)
Plugins were directly fetched from HscEnv (hsc_static_plugins and
hsc_plugins). The tight coupling of plugins and of HscEnv is undesirable
and it's better to store them in a new Plugins datatype and to use it in
the plugins' API (e.g. withPlugins, mapPlugins...).
In the process, the interactive context (used by GHCi) got proper
support for different static plugins than those used for loaded modules.
Bump haddock submodule
Diffstat (limited to 'compiler/GHC/Runtime')
-rw-r--r-- | compiler/GHC/Runtime/Context.hs | 4 | ||||
-rw-r--r-- | compiler/GHC/Runtime/Loader.hs | 12 |
2 files changed, 9 insertions, 7 deletions
diff --git a/compiler/GHC/Runtime/Context.hs b/compiler/GHC/Runtime/Context.hs index a1df5fd029..8222e96ce8 100644 --- a/compiler/GHC/Runtime/Context.hs +++ b/compiler/GHC/Runtime/Context.hs @@ -284,7 +284,7 @@ data InteractiveContext ic_cwd :: Maybe FilePath, -- ^ virtual CWD of the program - ic_plugins :: ![LoadedPlugin] + ic_plugins :: !Plugins -- ^ Cache of loaded plugins. We store them here to avoid having to -- load them everytime we switch to the interctive context. } @@ -321,7 +321,7 @@ emptyInteractiveContext dflags ic_default = Nothing, ic_resume = [], ic_cwd = Nothing, - ic_plugins = [] + ic_plugins = emptyPlugins } icReaderEnv :: InteractiveContext -> GlobalRdrEnv diff --git a/compiler/GHC/Runtime/Loader.hs b/compiler/GHC/Runtime/Loader.hs index 704f499a4f..e93e6969bc 100644 --- a/compiler/GHC/Runtime/Loader.hs +++ b/compiler/GHC/Runtime/Loader.hs @@ -74,14 +74,16 @@ import GHC.Unit.Types (ModuleNameWithIsBoot) initializePlugins :: HscEnv -> Maybe ModuleNameWithIsBoot -> IO HscEnv initializePlugins hsc_env mnwib -- plugins not changed - | map lpModuleName (hsc_plugins hsc_env) == reverse (pluginModNames dflags) + | loaded_plugins <- loadedPlugins (hsc_plugins hsc_env) + , map lpModuleName loaded_plugins == reverse (pluginModNames dflags) -- arguments not changed - , all same_args (hsc_plugins hsc_env) - = return hsc_env -- no need to reload plugins + , all same_args loaded_plugins + = return hsc_env -- no need to reload plugins FIXME: doesn't take static plugins into account | otherwise = do loaded_plugins <- loadPlugins hsc_env mnwib - let hsc_env' = hsc_env { hsc_plugins = loaded_plugins } - withPlugins hsc_env' driverPlugin hsc_env' + let plugins' = (hsc_plugins hsc_env) { loadedPlugins = loaded_plugins } + let hsc_env' = hsc_env { hsc_plugins = plugins' } + withPlugins (hsc_plugins hsc_env') driverPlugin hsc_env' where plugin_args = pluginModNameOpts dflags same_args p = paArguments (lpPlugin p) == argumentsForPlugin p plugin_args |