summaryrefslogtreecommitdiff
path: root/compiler/main/HeaderInfo.hs
diff options
context:
space:
mode:
authorSimon Marlow <marlowsd@gmail.com>2008-12-02 13:37:36 +0000
committerSimon Marlow <marlowsd@gmail.com>2008-12-02 13:37:36 +0000
commit25ed0cf7d4c2fbf9e455405f0a8525e0ae27b4e7 (patch)
tree4f8771323f84294de1ef53e61fbd8bb2ce294e8f /compiler/main/HeaderInfo.hs
parent95a05693c2ba2d15c1010a0cb9234484ada447cd (diff)
downloadhaskell-25ed0cf7d4c2fbf9e455405f0a8525e0ae27b4e7.tar.gz
Put full ImportDecls in ModSummary instead of just ModuleNames
... and use it to make ghc -M generate correct cross-package dependencies when using package-qualified imports (needed for the new build system). Since we're already parsing the ImportDecl from the source file, there seems no good reason not to keep it in the ModSummary, it might be useful for other things too.
Diffstat (limited to 'compiler/main/HeaderInfo.hs')
-rw-r--r--compiler/main/HeaderInfo.hs24
1 files changed, 6 insertions, 18 deletions
diff --git a/compiler/main/HeaderInfo.hs b/compiler/main/HeaderInfo.hs
index d79c3eec02..91849091b5 100644
--- a/compiler/main/HeaderInfo.hs
+++ b/compiler/main/HeaderInfo.hs
@@ -15,6 +15,7 @@ module HeaderInfo ( getImports
#include "HsVersions.h"
+import RdrName
import HscTypes
import Parser ( parseHeader )
import Lexer
@@ -51,7 +52,7 @@ getImports :: GhcMonad m =>
-- reporting parse error locations.
-> FilePath -- ^ The original source filename (used for locations
-- in the function result)
- -> m ([Located ModuleName], [Located ModuleName], Located ModuleName)
+ -> m ([Located (ImportDecl RdrName)], [Located (ImportDecl RdrName)], Located ModuleName)
-- ^ The source imports, normal imports, and the module name.
getImports dflags buf filename source_filename = do
let loc = mkSrcLoc (mkFastString filename) 1 0
@@ -68,29 +69,16 @@ getImports dflags buf filename source_filename = do
let
main_loc = mkSrcLoc (mkFastString source_filename) 1 0
mod = mb_mod `orElse` L (srcLocSpan main_loc) mAIN_NAME
- imps' = filter isHomeImp (map unLoc imps)
- (src_idecls, ord_idecls) = partition isSourceIdecl imps'
- source_imps = map getImpMod src_idecls
- ordinary_imps = filter ((/= moduleName gHC_PRIM) . unLoc)
- (map getImpMod ord_idecls)
+ (src_idecls, ord_idecls) = partition (ideclSource.unLoc) imps
+ ordinary_imps = filter ((/= moduleName gHC_PRIM) . unLoc . ideclName . unLoc)
+ ord_idecls
-- GHC.Prim doesn't exist physically, so don't go looking for it.
in
- return (source_imps, ordinary_imps, mod)
+ return (src_idecls, ordinary_imps, mod)
parseError :: GhcMonad m => SrcSpan -> Message -> m a
parseError span err = throwOneError $ mkPlainErrMsg span err
--- we aren't interested in package imports here, filter them out
-isHomeImp :: ImportDecl name -> Bool
-isHomeImp (ImportDecl _ (Just p) _ _ _ _) = p == fsLit "this"
-isHomeImp (ImportDecl _ Nothing _ _ _ _) = True
-
-isSourceIdecl :: ImportDecl name -> Bool
-isSourceIdecl (ImportDecl _ _ s _ _ _) = s
-
-getImpMod :: ImportDecl name -> Located ModuleName
-getImpMod (ImportDecl located_mod _ _ _ _ _) = located_mod
-
--------------------------------------------------------------
-- Get options
--------------------------------------------------------------