[project @ 2001-07-19 08:28:59 by andy]
[ghc-hetmet.git] / ghc / compiler / compMan / CompManager.lhs
index cc7ca58..107fe7d 100644 (file)
@@ -16,10 +16,12 @@ module CompManager (
     cmGetContext, -- :: CmState -> IO String
 
 #ifdef GHCI
-    cmRunStmt,   --  :: CmState -> DynFlags -> String -> IO (CmState, [Name])
+    cmInfoThing,  -- :: CmState -> DynFlags -> String -> IO (Maybe TyThing)
 
-    cmTypeOfExpr, --  :: CmState -> DynFlags -> String
-                 --  -> IO (CmState, Maybe String)
+    cmRunStmt,   -- :: CmState -> DynFlags -> String -> IO (CmState, [Name])
+
+    cmTypeOfExpr, -- :: CmState -> DynFlags -> String
+                 -- -> IO (CmState, Maybe String)
 
     cmTypeOfName, -- :: CmState -> Name -> IO (Maybe String)
 
@@ -39,7 +41,11 @@ import DriverFlags   ( getDynFlags )
 import DriverPhases
 import DriverUtil
 import Finder
+#ifdef GHCI
+import HscMain         ( initPersistentCompilerState, hscThing )
+#else
 import HscMain         ( initPersistentCompilerState )
+#endif
 import HscTypes
 import RnEnv           ( unQualInScope )
 import Id              ( idType, idName )
@@ -170,6 +176,11 @@ moduleNameToModule mn
 -- cmRunStmt:  Run a statement/expr.
 
 #ifdef GHCI
+cmInfoThing :: CmState -> DynFlags -> String -> IO (Maybe TyThing)
+cmInfoThing CmState{ hst=hst, hit=hit, pcs=pcs, pls=pls, ic=icontext } dflags id
+   = do (pcs, thing) <- hscThing dflags hst hit pcs icontext id
+       return thing
+
 cmRunStmt :: CmState -> DynFlags -> String
        -> IO (CmState,                 -- new state
               [Name])                  -- names bound by this evaluation
@@ -539,8 +550,18 @@ cmLoadFinish ok linkresult hst hit ui mods ghci_mode pcs
        return (new_cmstate, ok, mods_loaded)
     }
 
+-- used to fish out the preprocess output files for the purposes
+-- of cleaning up.
 ppFilesFromSummaries summaries
-  = [ fn | Just fn <- map (ml_hspp_file . ms_location) summaries ]
+  = [ fn | Just fn <- map toPpFile summaries ]
+  where
+   toPpFile sum
+     | hspp /= ml_hs_file loc = hspp
+     | otherwise              = Nothing
+    where
+      loc  = ms_location sum
+      hspp = ml_hspp_file loc
+
 
 -----------------------------------------------------------------------------
 -- getValidLinkables