[project @ 2001-05-09 09:55:41 by simonmar]
[ghc-hetmet.git] / ghc / compiler / compMan / CmLink.lhs
index 3b3e28b..9371eb4 100644 (file)
@@ -12,17 +12,24 @@ module CmLink ( Linkable(..),  Unlinked(..),
                unload,
                 PersistentLinkerState{-abstractly!-}, emptyPLS,
 #ifdef GHCI
+               delListFromClosureEnv,
+               addListToClosureEnv,
                linkExpr
 #endif
   ) where
 
 
+#ifdef GHCI
+import ByteCodeLink    ( linkIModules, linkIExpr )
+#endif
+
 import Interpreter
 import DriverPipeline
 import CmTypes
 import CmStaticInfo    ( GhciMode(..) )
 import Outputable      ( SDoc )
 import Digraph         ( SCC(..), flattenSCC )
+import Name            ( Name )
 import Module          ( ModuleName )
 import FiniteMap
 import Outputable
@@ -88,6 +95,18 @@ emptyPLS = return (PersistentLinkerState { closure_env = emptyFM,
 emptyPLS = return (PersistentLinkerState {})
 #endif
 
+#ifdef GHCI
+delListFromClosureEnv :: PersistentLinkerState -> [Name]
+       -> IO PersistentLinkerState
+delListFromClosureEnv pls names
+  = return pls{ closure_env = delListFromFM (closure_env pls) names }
+
+addListToClosureEnv :: PersistentLinkerState -> [(Name,HValue)] 
+       -> IO PersistentLinkerState
+addListToClosureEnv pls new_bindings
+  = return pls{ closure_env = addListToFM (closure_env pls) new_bindings }
+#endif
+
 -----------------------------------------------------------------------------
 -- Unloading old objects ready for a new compilation sweep.
 --
@@ -100,6 +119,7 @@ emptyPLS = return (PersistentLinkerState {})
 --
 --     * otherwise, we unload it.
 --
+--      * we also implicitly unload all temporary bindings at this point.
 
 unload :: GhciMode
        -> DynFlags
@@ -216,7 +236,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
@@ -241,8 +260,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"