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)
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 )
-- 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
-- the system state at the same time.
cmLoadModule :: CmState
- -> FilePath
+ -> [FilePath]
-> IO (CmState, -- new state
Bool, -- was successful
[String]) -- list of modules loaded
-cmLoadModule cmstate1 rootname
+cmLoadModule cmstate1 rootnames
= do -- version 1's are the original, before downsweep
let pls1 = pls cmstate1
let pcs1 = pcs cmstate1
showPass dflags "Chasing dependencies"
when (verb >= 1 && ghci_mode == Batch) $
- hPutStrLn stderr (progName ++ ": chasing modules from: " ++ rootname)
+ hPutStrLn stderr (showSDoc (hcat [
+ text progName, text ": chasing modules from: ",
+ hcat (punctuate comma (map text rootnames))]))
- (mg2unsorted, a_root_is_Main) <- downsweep [rootname] mg1
+ (mg2unsorted, a_root_is_Main) <- downsweep rootnames mg1
let mg2unsorted_names = map name_of_summary mg2unsorted
-- reachable_from follows source as well as normal imports
-- unload any modules which aren't going to be re-linked this
-- time around.
- pls2 <- unload ghci_mode dflags stable_linkables pls1
+ pls2 <- CmLink.unload ghci_mode dflags stable_linkables pls1
-- We could at this point detect cycles which aren't broken by
-- a source-import, and complain immediately, but it seems better
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
src_date = ms_hs_date summary
valid_linkable
- = filter (\l -> linkableTime l > src_date) linkable
+ = filter (\l -> linkableTime l >= src_date) linkable
+ -- why '>=' rather than '>' above? If the filesystem stores
+ -- times to the nearset second, we may occasionally find that
+ -- the object & source have the same modification time,
+ -- especially if the source was automatically generated
+ -- and compiled. Using >= is slightly unsafe, but it matches
+ -- make's behaviour.
return (valid_linkable ++ new_linkables)
res = simple_transitive_closure (map toEdge summaries) [root]
in
- --trace (showSDoc (text "DC of mod" <+> ppr root
- -- <+> text "=" <+> ppr res)) (
+-- trace (showSDoc (text "DC of mod" <+> ppr root
+-- <+> text "=" <+> ppr res)) $
res
- --)
-- Calculate transitive closures from a set of roots given an adjacency list
simple_transitive_closure :: Eq a => [(a,[a])] -> [a] -> [a]
let (path, basename, ext) = splitFilename3 file
- Just (mod, location)
+ (mod, location)
<- mkHomeModuleLocn mod_name (path ++ '/':basename) (Just file)
src_timestamp