projects
/
ghc-hetmet.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
[project @ 2005-07-26 08:16:24 by simonpj]
[ghc-hetmet.git]
/
ghc
/
compiler
/
main
/
GetImports.hs
diff --git
a/ghc/compiler/main/GetImports.hs
b/ghc/compiler/main/GetImports.hs
index
6c9f9ef
..
6ccb8be
100644
(file)
--- a/
ghc/compiler/main/GetImports.hs
+++ b/
ghc/compiler/main/GetImports.hs
@@
-17,9
+17,9
@@
import HsSyn ( ImportDecl(..), HsModule(..) )
import Module ( Module, mkModule )
import PrelNames ( gHC_PRIM )
import StringBuffer ( StringBuffer, hGetStringBuffer )
import Module ( Module, mkModule )
import PrelNames ( gHC_PRIM )
import StringBuffer ( StringBuffer, hGetStringBuffer )
-import SrcLoc ( Located(..), mkSrcLoc, unLoc )
+import SrcLoc ( Located(..), mkSrcLoc, unLoc, noSrcSpan )
import FastString ( mkFastString )
import FastString ( mkFastString )
-import CmdLineOpts ( DynFlags )
+import DynFlags ( DynFlags )
import ErrUtils
import Pretty
import Panic
import ErrUtils
import Pretty
import Panic
@@
-32,12
+32,14
@@
import List
-- getImportsFromFile is careful to close the file afterwards, otherwise
-- we can end up with a large number of open handles before the garbage
-- collector gets around to closing them.
-- getImportsFromFile is careful to close the file afterwards, otherwise
-- we can end up with a large number of open handles before the garbage
-- collector gets around to closing them.
-getImportsFromFile :: DynFlags -> FilePath -> IO ([Module], [Module], Module)
+getImportsFromFile :: DynFlags -> FilePath
+ -> IO ([Located Module], [Located Module], Located Module)
getImportsFromFile dflags filename = do
buf <- hGetStringBuffer filename
getImports dflags buf filename
getImportsFromFile dflags filename = do
buf <- hGetStringBuffer filename
getImports dflags buf filename
-getImports :: DynFlags -> StringBuffer -> FilePath -> IO ([Module], [Module], Module)
+getImports :: DynFlags -> StringBuffer -> FilePath
+ -> IO ([Located Module], [Located Module], Located Module)
getImports dflags buf filename = do
let loc = mkSrcLoc (mkFastString filename) 1 0
case unP parseHeader (mkPState buf loc dflags) of
getImports dflags buf filename = do
let loc = mkSrcLoc (mkFastString filename) 1 0
case unP parseHeader (mkPState buf loc dflags) of
@@
-46,18
+48,18
@@
getImports dflags buf filename = do
case rdr_module of
L _ (HsModule mod _ imps _ _) ->
let
case rdr_module of
L _ (HsModule mod _ imps _ _) ->
let
- mod_name | Just (L _ m) <- mod = m
- | otherwise = mkModule "Main"
+ mod_name | Just located_mod <- mod = located_mod
+ | otherwise = L noSrcSpan (mkModule "Main")
(src_idecls, ord_idecls) = partition isSourceIdecl (map unLoc imps)
source_imps = map getImpMod src_idecls
(src_idecls, ord_idecls) = partition isSourceIdecl (map unLoc imps)
source_imps = map getImpMod src_idecls
- ordinary_imps = filter (/= gHC_PRIM) (map getImpMod ord_idecls)
+ ordinary_imps = filter ((/= gHC_PRIM) . unLoc)
+ (map getImpMod ord_idecls)
-- GHC.Prim doesn't exist physically, so don't go looking for it.
in
return (source_imps, ordinary_imps, mod_name)
-- GHC.Prim doesn't exist physically, so don't go looking for it.
in
return (source_imps, ordinary_imps, mod_name)
-parseError span err = throwDyn (ProgramError err_doc)
- where err_doc = render (pprBagOfErrors (unitBag (mkPlainErrMsg span err)))
+parseError span err = throwDyn $ mkPlainErrMsg span err
isSourceIdecl (ImportDecl _ s _ _ _) = s
isSourceIdecl (ImportDecl _ s _ _ _) = s
-getImpMod (ImportDecl (L _ mod) _ _ _ _) = mod
+getImpMod (ImportDecl located_mod _ _ _ _) = located_mod