X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2Fmain%2FFinder.lhs;h=6e2b11d0257fc0734ea711de682b2d538311f055;hb=aafdba3bce91afb003f5f50e001e141744837bae;hp=62d6740230aaee1bc25c71e54cde2dd1c29e7b14;hpb=17b297d97d327620ed6bfab942f8992b2446f1bf;p=ghc-hetmet.git diff --git a/compiler/main/Finder.lhs b/compiler/main/Finder.lhs index 62d6740..6e2b11d 100644 --- a/compiler/main/Finder.lhs +++ b/compiler/main/Finder.lhs @@ -4,13 +4,6 @@ \section[Finder]{Module Finder} \begin{code} -{-# OPTIONS_GHC -w #-} --- The above warning supression flag is a temporary kludge. --- While working on this module you are encouraged to remove it and fix --- any warnings in the module. See --- http://hackage.haskell.org/trac/ghc/wiki/WorkingConventions#Warnings --- for details - module Finder ( flushFinderCaches, FindResult(..), @@ -87,16 +80,25 @@ flushModLocationCache this_pkg ref = do where is_ext mod _ | modulePackageId mod /= this_pkg = True | otherwise = False +addToFinderCache :: IORef FinderCache -> ModuleName -> FindResult -> IO () addToFinderCache ref key val = modifyIORef ref $ \c -> addToUFM c key val + +addToModLocationCache :: IORef ModLocationCache -> Module -> ModLocation -> IO () addToModLocationCache ref key val = modifyIORef ref $ \c -> addToFM c key val +removeFromFinderCache :: IORef FinderCache -> ModuleName -> IO () removeFromFinderCache ref key = modifyIORef ref $ \c -> delFromUFM c key + +removeFromModLocationCache :: IORef ModLocationCache -> Module -> IO () removeFromModLocationCache ref key = modifyIORef ref $ \c -> delFromFM c key +lookupFinderCache :: IORef FinderCache -> ModuleName -> IO (Maybe FindResult) lookupFinderCache ref key = do c <- readIORef ref return $! lookupUFM c key +lookupModLocationCache :: IORef ModLocationCache -> Module + -> IO (Maybe ModLocation) lookupModLocationCache ref key = do c <- readIORef ref return $! lookupFM c key @@ -148,6 +150,7 @@ findExactModule hsc_env mod = -- ----------------------------------------------------------------------------- -- Helpers +orIfNotFound :: IO FindResult -> IO FindResult -> IO FindResult this `orIfNotFound` or_this = do res <- this case res of @@ -273,6 +276,7 @@ findPackageModule hsc_env mod = do Nothing -> return (NoPackage pkg_id) Just pkg_conf -> findPackageModule_ hsc_env mod pkg_conf +findPackageModule_ :: HscEnv -> Module -> PackageConfig -> IO FindResult findPackageModule_ hsc_env mod pkg_conf = modLocationCache hsc_env mod $ @@ -468,7 +472,7 @@ mkStubPaths :: DynFlags -> ModuleName -> ModLocation - -> (FilePath,FilePath) + -> (FilePath,FilePath,FilePath) mkStubPaths dflags mod location = let @@ -483,9 +487,23 @@ mkStubPaths dflags mod location | otherwise = src_basename stub_basename = stub_basename0 ++ "_stub" + + -- this is the filename we're going to use when + -- #including the stub_h file from the .hc file. + -- Without -stubdir, we just #include the basename + -- (eg. for a module A.B, we #include "B_stub.h"), + -- relying on the fact that we add an implicit -I flag + -- for the directory in which the source file resides + -- (see DriverPipeline.hs). With -stubdir, we + -- #include "A/B.h", assuming that the user has added + -- -I