From 2ace0e219a4dac709f9a518bc9ae1c39082fdc0f Mon Sep 17 00:00:00 2001 From: simonmar Date: Wed, 22 Nov 2000 15:51:48 +0000 Subject: [PATCH] [project @ 2000-11-22 15:51:48 by simonmar] :l now unloads the previously loaded module collection before loading the new ones. This allows you to :l Main, :cd and :l Main again without it saying "compilation IS NOT required". --- ghc/compiler/compMan/CompManager.lhs | 21 +++++++++++++++++---- ghc/compiler/ghci/InteractiveUI.hs | 13 +++++++------ 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/ghc/compiler/compMan/CompManager.lhs b/ghc/compiler/compMan/CompManager.lhs index 8041e61..d489559 100644 --- a/ghc/compiler/compMan/CompManager.lhs +++ b/ghc/compiler/compMan/CompManager.lhs @@ -4,7 +4,7 @@ \section[CompManager]{The Compilation Manager} \begin{code} -module CompManager ( cmInit, cmLoadModule, +module CompManager ( cmInit, cmLoadModule, cmUnload, #ifdef GHCI cmGetExpr, cmTypeExpr, cmRunExpr, #endif @@ -160,6 +160,22 @@ emptyMG = [] \end{code} +Unload the compilation manager's state: everything it knows about the +current collection of modules in the Home package. + +\begin{code} +cmUnload :: CmState -> IO CmState +cmUnload state + = do -- Throw away the old home dir cache + emptyHomeDirCache + -- Throw away the HIT and the HST + return state{ pcms=pcms{ hst=new_hst, hit=new_hit } } + where + CmState{ pcms=pcms } = state + PersistentCMState{ hst=hst, hit=hit } = pcms + (new_hst, new_hit) = retainInTopLevelEnvs [] (hst,hit) +\end{code} + The real business of the compilation manager: given a system state and a module name, try and bring the module up to date, probably changing the system state at the same time. @@ -187,9 +203,6 @@ cmLoadModule cmstate1 rootname -- then generate version 2's by removing from HIT,HST,UI any -- modules in the old MG which are not in the new one. - -- Throw away the old home dir cache - emptyHomeDirCache - dflags <- getDynFlags let verb = verbosity dflags diff --git a/ghc/compiler/ghci/InteractiveUI.hs b/ghc/compiler/ghci/InteractiveUI.hs index 3c663ec..4160844 100644 --- a/ghc/compiler/ghci/InteractiveUI.hs +++ b/ghc/compiler/ghci/InteractiveUI.hs @@ -1,5 +1,5 @@ ----------------------------------------------------------------------------- --- $Id: InteractiveUI.hs,v 1.12 2000/11/22 11:12:52 simonmar Exp $ +-- $Id: InteractiveUI.hs,v 1.13 2000/11/22 15:51:48 simonmar Exp $ -- -- GHC Interactive User Interface -- @@ -180,10 +180,11 @@ changeDirectory = io . setCurrentDirectory loadModule :: String -> GHCi () loadModule path = do state <- getGHCiState - (new_cmstate, ok, mods) <- io (cmLoadModule (cmstate state) path) + cmstate1 <- io (cmUnload (cmstate state)) + (cmstate2, ok, mods) <- io (cmLoadModule cmstate1 path) let new_state = GHCiState { - cmstate = new_cmstate, + cmstate = cmstate2, modules = mods, current_module = case mods of [] -> defaultCurrentModule @@ -207,9 +208,9 @@ reloadModule "" = do state <- getGHCiState case target state of Nothing -> io (putStr "no current target\n") - Just path -> do (new_cmstate, ok, mod) - <- io (cmLoadModule (cmstate state) path) - setGHCiState state{cmstate=new_cmstate} + Just path + -> do (new_cmstate, ok, mod) <- io (cmLoadModule (cmstate state) path) + setGHCiState state{cmstate=new_cmstate} reloadModule _ = noArgs ":reload" -- set options in the interpreter. Syntax is exactly the same as the -- 1.7.10.4