Skip to content

Commit

Permalink
Load plugins in interactive session
Browse files Browse the repository at this point in the history
  • Loading branch information
leonschoorl committed Jul 26, 2019
1 parent 65db476 commit dd1efad
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
7 changes: 6 additions & 1 deletion clash-ghc/src-bin-861/Clash/GHCi/UI.hs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ import qualified Lexer
import StringBuffer
import Outputable hiding ( printForUser, printForUserPartWay )

import DynamicLoading ( initializePlugins )

-- Other random utilities
import BasicTypes hiding ( isTopLevel )
import Digraph
Expand Down Expand Up @@ -2834,7 +2836,10 @@ newDynFlags interactive_only minus_opts = do

when (interactive_only && packageFlagsChanged idflags1 idflags0) $ do
liftIO $ hPutStrLn stderr "cannot set package flags with :seti; use :set"
GHC.setInteractiveDynFlags idflags1
-- Load any new plugins
hsc_env0 <- GHC.getSession
idflags2 <- liftIO (initializePlugins hsc_env0 idflags1)
GHC.setInteractiveDynFlags idflags2
installInteractivePrint (interactivePrint idflags1) False

dflags0 <- getDynFlags
Expand Down
14 changes: 9 additions & 5 deletions clash-ghc/src-bin-861/Clash/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ import Util
import Panic
import UniqSupply
import MonadUtils ( liftIO )
import DynamicLoading ( initializePlugins )

-- Imports for --abi-hash
import LoadIface ( loadUserInterface )
Expand Down Expand Up @@ -298,8 +299,8 @@ main' postLoadMode dflags0 args flagWarnings clashOpts = do
DoMake -> doMake srcs
DoMkDependHS -> doMkDependHS (map fst srcs)
StopBefore p -> liftIO (oneShot hsc_env p srcs)
DoInteractive -> ghciUI clashOpts srcs Nothing
DoEval exprs -> ghciUI clashOpts srcs $ Just $ reverse exprs
DoInteractive -> ghciUI clashOpts hsc_env dflags6 srcs Nothing
DoEval exprs -> ghciUI clashOpts hsc_env dflags6 srcs $ Just $ reverse exprs
DoAbiHash -> abiHash (map fst srcs)
ShowPackages -> liftIO $ showPackages dflags6
DoFrontend f -> doFrontend f srcs
Expand All @@ -310,11 +311,14 @@ main' postLoadMode dflags0 args flagWarnings clashOpts = do

liftIO $ dumpFinalStats dflags6

ghciUI :: IORef ClashOpts -> [(FilePath, Maybe Phase)] -> Maybe [String] -> Ghc ()
ghciUI :: IORef ClashOpts -> HscEnv -> DynFlags -> [(FilePath, Maybe Phase)] -> Maybe [String] -> Ghc ()
#if !defined(GHCI)
ghciUI _ _ _ = throwGhcException (CmdLineError "not built for interactive use")
ghciUI _ _ _ _ _ = throwGhcException (CmdLineError "not built for interactive use")
#else
ghciUI opts = interactiveUI (defaultGhciSettings opts)
ghciUI opts hsc_env dflags0 srcs maybe_expr = do
dflags1 <- liftIO (initializePlugins hsc_env dflags0)
_ <- GHC.setSessionDynFlags dflags1
interactiveUI (defaultGhciSettings opts) srcs maybe_expr
#endif

-- -----------------------------------------------------------------------------
Expand Down

0 comments on commit dd1efad

Please sign in to comment.