[project @ 2003-01-09 10:49:21 by simonmar]
[ghc-hetmet.git] / ghc / compiler / ghci / InteractiveUI.hs
index aa82735..3cfd5d2 100644 (file)
@@ -1,6 +1,6 @@
-{-# OPTIONS -#include "Linker.h" -#include "SchedAPI.h" #-}
+{-# OPTIONS -#include "Linker.h" #-}
 -----------------------------------------------------------------------------
--- $Id: InteractiveUI.hs,v 1.138 2002/12/05 12:36:54 simonmar Exp $
+-- $Id: InteractiveUI.hs,v 1.142 2002/12/27 12:20:06 panne Exp $
 --
 -- GHC Interactive User Interface
 --
@@ -23,8 +23,8 @@ import MkIface                ( ifaceTyThing )
 import DriverFlags
 import DriverState
 import DriverUtil      ( remove_spaces, handle )
-import Linker          ( initLinker, showLinkerState, linkLibraries )
-import Finder          ( flushFinderCache )
+import Linker          ( initLinker, showLinkerState, linkLibraries, 
+                         linkPackages )
 import Util
 import Id              ( isRecordSelector, recordSelectorFieldLabel, 
                          isDataConWrapId, isDataConId, idName )
@@ -71,8 +71,6 @@ import Control.Monad as Monad
 
 import GHC.Exts                ( unsafeCoerce# )
 
-import Foreign         ( nullPtr )
-import Foreign.C.String        ( CString, peekCString, withCString )
 import Data.IORef      ( IORef, newIORef, readIORef, writeIORef )
 
 import GHC.Posix       ( setNonBlockingFD )
@@ -157,8 +155,13 @@ interactiveUI cmstate paths cmdline_objs = do
 
    dflags <- getDynFlags
 
-       -- packages are loaded "on-demand" now
    initLinker
+
+       -- link packages requested explicitly on the command-line
+   expl <- readIORef v_ExplicitPackages
+   linkPackages dflags expl
+
+       -- link libraries from the command-line
    linkLibraries dflags cmdline_objs
 
        -- Initialise buffering for the *interpreted* I/O system
@@ -295,7 +298,7 @@ fileLoop hdl prompt = do
    l <- io (IO.try (hGetLine hdl))
    case l of
        Left e | isEOFError e -> return ()
-              | otherwise    -> throw e
+              | otherwise    -> io (ioError e)
        Right l -> 
          case remove_spaces l of
            "" -> fileLoop hdl prompt
@@ -833,9 +836,9 @@ setOptions wds =
       mapM_ setOpt plus_opts
 
       -- now, the GHC flags
-      pkgs_before <- io (readIORef v_Packages)
+      pkgs_before <- io (readIORef v_ExplicitPackages)
       leftovers   <- io (processArgs static_flags minus_opts [])
-      pkgs_after  <- io (readIORef v_Packages)
+      pkgs_after  <- io (readIORef v_ExplicitPackages)
 
       -- update things if the users wants more packages
       let new_packages = pkgs_after \\ pkgs_before
@@ -910,9 +913,10 @@ newPackages new_pkgs = do  -- The new packages are already in v_Packages
   dflags   <- io getDynFlags
   cmstate1 <- io (cmUnload (cmstate state) dflags)
   setGHCiState state{ cmstate = cmstate1, targets = [] }
+  io (linkPackages dflags new_pkgs)
   setContextAfterLoad []
 
------------------------------------------------------------------------------
+-- ---------------------------------------------------------------------------
 -- code for `:show'
 
 showCmd str =