diff options
author | Edward Z. Yang <ezyang@cs.stanford.edu> | 2015-12-10 20:41:53 -0800 |
---|---|---|
committer | Edward Z. Yang <ezyang@cs.stanford.edu> | 2015-12-12 00:38:47 -0800 |
commit | a3c2a26b3af034f09c960b2dad38f73be7e3a655 (patch) | |
tree | 74efe130fc04633aebfe6f022689089fd2a8318d /compiler/main/DynamicLoading.hs | |
parent | 779dfea1d9cc713d9b1e26bb559e8da309b2aeec (diff) | |
download | haskell-a3c2a26b3af034f09c960b2dad38f73be7e3a655.tar.gz |
Frontend plugins.
Summary:
Frontend plugins enable users to write plugins to replace
GHC major modes. E.g. instead of saying
ghc --make A B C
a user can now say
ghc --frontend GHC.Frontend.Shake A B C
which might provide an alternative implementation of a multi-module
build. For more details, see the manual entry.
Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
Test Plan: validate
Reviewers: simonmar, bgamari, austin, simonpj
Subscribers: thomie
Differential Revision: https://phabricator.haskell.org/D1598
GHC Trac Issues: #11194
Diffstat (limited to 'compiler/main/DynamicLoading.hs')
-rw-r--r-- | compiler/main/DynamicLoading.hs | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/compiler/main/DynamicLoading.hs b/compiler/main/DynamicLoading.hs index 5942d6c91c..0d4b84252f 100644 --- a/compiler/main/DynamicLoading.hs +++ b/compiler/main/DynamicLoading.hs @@ -5,6 +5,7 @@ module DynamicLoading ( #ifdef GHCI -- * Loading plugins loadPlugins, + loadFrontendPlugin, -- * Force loading information forceLoadModuleInterfaces, @@ -30,11 +31,11 @@ import LoadIface ( loadPluginInterface ) import RdrName ( RdrName, ImportSpec(..), ImpDeclSpec(..) , ImpItemSpec(..), mkGlobalRdrEnv, lookupGRE_RdrName , gre_name, mkRdrQual ) -import OccName ( mkVarOcc ) +import OccName ( OccName, mkVarOcc ) import RnNames ( gresFromAvails ) import DynFlags -import Plugins ( Plugin, CommandLineOption ) -import PrelNames ( pluginTyConName ) +import Plugins ( Plugin, FrontendPlugin, CommandLineOption ) +import PrelNames ( pluginTyConName, frontendPluginTyConName ) import HscTypes import BasicTypes ( HValue ) @@ -68,8 +69,14 @@ loadPlugins hsc_env , opt_mod_nm == mod_nm ] loadPlugin :: HscEnv -> ModuleName -> IO Plugin -loadPlugin hsc_env mod_name - = do { let plugin_rdr_name = mkRdrQual mod_name (mkVarOcc "plugin") +loadPlugin = loadPlugin' (mkVarOcc "plugin") pluginTyConName + +loadFrontendPlugin :: HscEnv -> ModuleName -> IO FrontendPlugin +loadFrontendPlugin = loadPlugin' (mkVarOcc "frontendPlugin") frontendPluginTyConName + +loadPlugin' :: OccName -> Name -> HscEnv -> ModuleName -> IO a +loadPlugin' occ_name plugin_name hsc_env mod_name + = do { let plugin_rdr_name = mkRdrQual mod_name occ_name dflags = hsc_dflags hsc_env ; mb_name <- lookupRdrNameInModuleForPlugins hsc_env mod_name plugin_rdr_name @@ -81,7 +88,7 @@ loadPlugin hsc_env mod_name , ppr plugin_rdr_name ]) ; Just name -> - do { plugin_tycon <- forceLoadTyCon hsc_env pluginTyConName + do { plugin_tycon <- forceLoadTyCon hsc_env plugin_name ; mb_plugin <- getValueSafely hsc_env name (mkTyConTy plugin_tycon) ; case mb_plugin of Nothing -> |