diff options
Diffstat (limited to 'compiler/main/GHC.hs')
-rw-r--r-- | compiler/main/GHC.hs | 38 |
1 files changed, 32 insertions, 6 deletions
diff --git a/compiler/main/GHC.hs b/compiler/main/GHC.hs index 59e42f9c75..cf066d0ea7 100644 --- a/compiler/main/GHC.hs +++ b/compiler/main/GHC.hs @@ -91,6 +91,7 @@ module GHC ( -- * Interactive evaluation +#ifdef GHCI -- ** Executing statements execStmt, ExecOptions(..), execOptions, ExecResult(..), resumeExec, @@ -102,10 +103,11 @@ module GHC ( parseImportDecl, setContext, getContext, setGHCiMonad, getGHCiMonad, - +#endif -- ** Inspecting the current context getBindings, getInsts, getPrintUnqual, findModule, lookupModule, +#ifdef GHCI isModuleTrusted, moduleTrustReqs, getNamesInScope, getRdrNamesInScope, @@ -121,8 +123,9 @@ module GHC ( -- ** Looking up a Name parseName, +#endif lookupName, - +#ifdef GHCI -- ** Compiling expressions HValue, parseExpr, compileParsedExpr, InteractiveEval.compileExpr, dynCompileExpr, @@ -151,6 +154,7 @@ module GHC ( RunResult(..), runStmt, runStmtWithLocation, resume, +#endif -- * Abstract syntax elements @@ -286,12 +290,14 @@ module GHC ( #include "HsVersions.h" +#ifdef GHCI import ByteCodeTypes import InteractiveEval import InteractiveEvalTypes import TcRnDriver ( runTcInteractive ) import GHCi import GHCi.RemoteTypes +#endif import PprTyThing ( pprFamInst ) import HscMain @@ -463,7 +469,9 @@ withCleanupSession ghc = ghc `gfinally` cleanup liftIO $ do cleanTempFiles dflags cleanTempDirs dflags +#ifdef GHCI stopIServ hsc_env -- shut down the IServ +#endif -- exceptions will be blocked while we clean the temporary files, -- so there shouldn't be any difficulty if we receive further -- signals. @@ -881,8 +889,10 @@ typecheckModule pmod = do minf_rdr_env = Just (tcg_rdr_env tc_gbl_env), minf_instances = fixSafeInstances safe $ md_insts details, minf_iface = Nothing, - minf_safe = safe, - minf_modBreaks = emptyModBreaks + minf_safe = safe +#ifdef GHCI + ,minf_modBreaks = emptyModBreaks +#endif }} -- | Desugar a typechecked module. @@ -1070,8 +1080,10 @@ data ModuleInfo = ModuleInfo { minf_rdr_env :: Maybe GlobalRdrEnv, -- Nothing for a compiled/package mod minf_instances :: [ClsInst], minf_iface :: Maybe ModIface, - minf_safe :: SafeHaskellMode, - minf_modBreaks :: ModBreaks + minf_safe :: SafeHaskellMode +#ifdef GHCI + ,minf_modBreaks :: ModBreaks +#endif } -- We don't want HomeModInfo here, because a ModuleInfo applies -- to package modules too. @@ -1094,6 +1106,7 @@ getModuleInfo mdl = withSession $ \hsc_env -> do -- exist... hence the isHomeModule test here. (ToDo: reinstate) getPackageModuleInfo :: HscEnv -> Module -> IO (Maybe ModuleInfo) +#ifdef GHCI getPackageModuleInfo hsc_env mdl = do eps <- hscEPS hsc_env iface <- hscGetModuleInterface hsc_env mdl @@ -1112,6 +1125,11 @@ getPackageModuleInfo hsc_env mdl minf_safe = getSafeMode $ mi_trust iface, minf_modBreaks = emptyModBreaks })) +#else +-- bogusly different for non-GHCI (ToDo) +getPackageModuleInfo _hsc_env _mdl = do + return Nothing +#endif getHomeModuleInfo :: HscEnv -> Module -> IO (Maybe ModuleInfo) getHomeModuleInfo hsc_env mdl = @@ -1127,7 +1145,9 @@ getHomeModuleInfo hsc_env mdl = minf_instances = md_insts details, minf_iface = Just iface, minf_safe = getSafeMode $ mi_trust iface +#ifdef GHCI ,minf_modBreaks = getModBreaks hmi +#endif })) -- | The list of top-level entities defined in a module @@ -1176,8 +1196,10 @@ modInfoIface = minf_iface modInfoSafe :: ModuleInfo -> SafeHaskellMode modInfoSafe = minf_safe +#ifdef GHCI modInfoModBreaks :: ModuleInfo -> ModBreaks modInfoModBreaks = minf_modBreaks +#endif isDictonaryId :: Id -> Bool isDictonaryId id @@ -1197,9 +1219,11 @@ findGlobalAnns deserialize target = withSession $ \hsc_env -> do ann_env <- liftIO $ prepareAnnotations hsc_env Nothing return (findAnns deserialize ann_env target) +#ifdef GHCI -- | get the GlobalRdrEnv for a session getGRE :: GhcMonad m => m GlobalRdrEnv getGRE = withSession $ \hsc_env-> return $ ic_rn_gbl_env (hsc_IC hsc_env) +#endif -- ----------------------------------------------------------------------------- @@ -1398,6 +1422,7 @@ lookupLoadedHomeModule mod_name = withSession $ \hsc_env -> Just mod_info -> return (Just (mi_module (hm_iface mod_info))) _not_a_home_module -> return Nothing +#ifdef GHCI -- | Check that a module is safe to import (according to Safe Haskell). -- -- We return True to indicate the import is safe and False otherwise @@ -1439,6 +1464,7 @@ obtainTermFromId :: GhcMonad m => Int -> Bool -> Id -> m Term obtainTermFromId bound force id = withSession $ \hsc_env -> liftIO $ InteractiveEval.obtainTermFromId hsc_env bound force id +#endif -- | Returns the 'TyThing' for a 'Name'. The 'Name' may refer to any -- entity known to GHC, including 'Name's defined using 'runStmt'. |