[project @ 2001-06-15 08:29:57 by simonpj]
[ghc-hetmet.git] / ghc / compiler / compMan / CmLink.lhs
index af0b8f4..4b592f5 100644 (file)
@@ -12,16 +12,21 @@ module CmLink ( Linkable(..),  Unlinked(..),
                unload,
                 PersistentLinkerState{-abstractly!-}, emptyPLS,
 #ifdef GHCI
-               updateClosureEnv,
+               delListFromClosureEnv,
+               addListToClosureEnv,
                linkExpr
 #endif
   ) where
 
 
+#ifdef GHCI
+import ByteCodeLink    ( linkIModules, linkIExpr )
+#endif
+
 import Interpreter
 import DriverPipeline
 import CmTypes
-import CmStaticInfo    ( GhciMode(..) )
+import HscTypes                ( GhciMode(..) )
 import Outputable      ( SDoc )
 import Digraph         ( SCC(..), flattenSCC )
 import Name            ( Name )
@@ -30,9 +35,8 @@ import FiniteMap
 import Outputable
 import ErrUtils                ( showPass )
 import CmdLineOpts     ( DynFlags(..) )
-import Panic           ( panic, GhcException(..) )
+import Panic           ( panic )
 
-import Exception
 import List
 import Monad
 import IO
@@ -91,9 +95,14 @@ emptyPLS = return (PersistentLinkerState {})
 #endif
 
 #ifdef GHCI
-updateClosureEnv :: PersistentLinkerState -> [(Name,HValue)] 
+delListFromClosureEnv :: PersistentLinkerState -> [Name]
+       -> IO PersistentLinkerState
+delListFromClosureEnv pls names
+  = return pls{ closure_env = delListFromFM (closure_env pls) names }
+
+addListToClosureEnv :: PersistentLinkerState -> [(Name,HValue)] 
        -> IO PersistentLinkerState
-updateClosureEnv pls new_bindings
+addListToClosureEnv pls new_bindings
   = return pls{ closure_env = addListToFM (closure_env pls) new_bindings }
 #endif
 
@@ -209,9 +218,6 @@ link' Interactive dflags batch_attempt_linking linkables pls
         linkObjs (objs ++ bcos) pls
           -- get the objects first
 
-ppLinkableSCC :: SCC Linkable -> SDoc
-ppLinkableSCC = ppr . flattenSCC
-
 filterModuleLinkables :: (ModuleName -> Bool) -> [Linkable] -> [Linkable]
 filterModuleLinkables p [] = []
 filterModuleLinkables p (li:lis)
@@ -226,7 +232,6 @@ filterModuleLinkables p (li:lis)
 
 #ifndef GHCI
 linkObjs      = panic "CmLink.linkObjs: no interpreter"
-lookupClosure = panic "CmLink.lookupClosure: no interpreter"
 #else
 linkObjs [] pls = linkFinish pls []
 linkObjs (l@(LM _ m uls) : ls) pls
@@ -251,8 +256,7 @@ linkInterpretedCode (l@(LM _ m uls) : ls) ul_trees pls
        linkInterpretedCode ls (uls++ul_trees) 
                pls{objects_loaded = l : objects_loaded pls}
    | any isObject uls
-        = throwDyn (OtherError 
-            "can't link object code that depends on interpreted code")
+        = panic "linkInterpretedCode: trying to link object code to interpreted code"
    | otherwise = invalidLinkable
 
 invalidLinkable = panic "CmLink: linkable doesn't contain entirely objects or interpreted code"