summaryrefslogtreecommitdiff
path: root/compiler/GHC/Runtime/Loader.hs
diff options
context:
space:
mode:
authorSylvain Henry <sylvain@haskus.fr>2021-12-14 11:23:02 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-12-21 01:46:39 -0500
commit9728d6c2b62f38f79c8833b1819200985fe173dc (patch)
tree8e44abae10080473b22ad71f750613cdc1fa9a96 /compiler/GHC/Runtime/Loader.hs
parent00b55bfcd982bed2c9fc02d9c3ca66ba9d41bb5c (diff)
downloadhaskell-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/Loader.hs')
-rw-r--r--compiler/GHC/Runtime/Loader.hs12
1 files changed, 7 insertions, 5 deletions
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