diff options
author | Sylvain Henry <sylvain@haskus.fr> | 2020-02-17 18:12:30 +0100 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2020-02-29 05:09:25 -0500 |
commit | 18757cab04c5c5c48eaceea19469d4811c5d0371 (patch) | |
tree | 5437de47247b8fe69f8b83db6a66524cabddee3f /ghc | |
parent | b5fb58fd1a4a24b9273d9d2de65b6347e1654e98 (diff) | |
download | haskell-18757cab04c5c5c48eaceea19469d4811c5d0371.tar.gz |
Refactor runtime interpreter code
In #14335 we want to be able to use both the internal interpreter (for
the plugins) and the external interpreter (for TH and GHCi) at the same
time.
This patch performs some preliminary refactoring: the `hsc_interp` field
of HscEnv replaces `hsc_iserv` and is now used to indicate which
interpreter (internal, external) to use to execute TH and GHCi.
Opt_ExternalInterpreter flag and iserv options in DynFlags are now
queried only when we set the session DynFlags. It should help making GHC
multi-target in the future by selecting an interpreter according to the
selected target.
Diffstat (limited to 'ghc')
-rw-r--r-- | ghc/GHCi/UI.hs | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/ghc/GHCi/UI.hs b/ghc/GHCi/UI.hs index 7793b7183a..67903c80bf 100644 --- a/ghc/GHCi/UI.hs +++ b/ghc/GHCi/UI.hs @@ -37,6 +37,7 @@ import GHC.Runtime.Debugger -- The GHC interface import GHC.Runtime.Interpreter +import GHC.Runtime.Interpreter.Types import GHCi.RemoteTypes import GHCi.BreakArray import GHC.Driver.Session as DynFlags @@ -53,7 +54,7 @@ import GHC.Hs.ImpExp import GHC.Hs import GHC.Driver.Types ( tyThingParent_maybe, handleFlagWarnings, getSafeMode, hsc_IC, setInteractivePrintName, hsc_dflags, msObjFilePath, runInteractiveHsc, - hsc_dynLinker ) + hsc_dynLinker, hsc_interp ) import Module import Name import GHC.Driver.Packages ( trusted, getPackageDetails, getInstalledPackageDetails, @@ -1559,14 +1560,15 @@ changeDirectory dir = do GHC.workingDirectoryChanged dir' <- expandPath dir liftIO $ setCurrentDirectory dir' - dflags <- getDynFlags -- With -fexternal-interpreter, we have to change the directory of the subprocess too. -- (this gives consistent behaviour with and without -fexternal-interpreter) - when (gopt Opt_ExternalInterpreter dflags) $ do - hsc_env <- GHC.getSession - fhv <- compileGHCiExpr $ - "System.Directory.setCurrentDirectory " ++ show dir' - liftIO $ evalIO hsc_env fhv + hsc_env <- GHC.getSession + case hsc_interp hsc_env of + Just (ExternalInterp {}) -> do + fhv <- compileGHCiExpr $ + "System.Directory.setCurrentDirectory " ++ show dir' + liftIO $ evalIO hsc_env fhv + _ -> pure () trySuccess :: GHC.GhcMonad m => m SuccessFlag -> m SuccessFlag trySuccess act = |