[project @ 2001-05-04 14:40:42 by simonpj]
[ghc-hetmet.git] / ghc / compiler / compMan / CompManager.lhs
index bf8d0cf..a571fa7 100644 (file)
@@ -149,7 +149,7 @@ cmSetContext cmstate str
                Nothing -> do
                   mod <- moduleNameToModule mn
                   if isHomeModule mod 
-                       then throwDyn (UserError (showSDoc 
+                       then throwDyn (CmdLineError (showSDoc 
                                (quotes (ppr (moduleName mod))
                                  <+> text "is not currently loaded")))
                        else return mod
@@ -163,7 +163,7 @@ moduleNameToModule :: ModuleName -> IO Module
 moduleNameToModule mn
  = do maybe_stuff <- findModule mn
       case maybe_stuff of
-       Nothing -> throwDyn (UserError ("can't find module `"
+       Nothing -> throwDyn (CmdLineError ("can't find module `"
                                    ++ moduleNameUserString mn ++ "'"))
        Just (m,_) -> return m
 
@@ -610,8 +610,7 @@ getValidLinkable old_linkables objects_allowed new_linkables summary
                    Just l | not (isObjectLinkable l) || stillThere l 
                                -> old_linkable
                                -- ToDo: emit a warning if not (stillThere l)
-                          | otherwise
-                               -> Nothing
+                    other -> Nothing
 
           -- make sure that if we had an old disk linkable around, that it's
           -- still there on the disk (in case we need to re-link it).
@@ -955,7 +954,7 @@ downsweep rootNm old_summaries
           | haskellish_file file
           = do exists <- doesFileExist file
                if exists then summariseFile file else do
-               throwDyn (UserError ("can't find file `" ++ file ++ "'"))       
+               throwDyn (CmdLineError ("can't find file `" ++ file ++ "'"))    
           | otherwise
           = do exists <- doesFileExist hs_file
                if exists then summariseFile hs_file else do
@@ -978,7 +977,7 @@ downsweep rootNm old_summaries
                        let old_summary = findModInSummaries old_summaries mod
                        summarise mod location old_summary
 
-                  Nothing -> throwDyn (UserError 
+                  Nothing -> throwDyn (CmdLineError 
                                    ("can't find module `" 
                                      ++ showSDoc (ppr nm) ++ "'"))
 
@@ -1016,14 +1015,13 @@ downsweep rootNm old_summaries
 summariseFile :: FilePath -> IO ModSummary
 summariseFile file
    = do hspp_fn <- preprocess file
-        modsrc <- readFile hspp_fn
+        (srcimps,imps,mod_name) <- getImportsFromFile hspp_fn
 
-        let (srcimps,imps,mod_name) = getImports modsrc
-           (path, basename, ext) = splitFilename3 file
+        let (path, basename, ext) = splitFilename3 file
 
        Just (mod, location)
           <- mkHomeModuleLocn mod_name (path ++ '/':basename) file
-          
+
         src_timestamp
            <- case ml_hs_file location of 
                  Nothing     -> noHsFileErr mod_name
@@ -1051,12 +1049,11 @@ summarise mod location old_summary
           _ -> do
 
         hspp_fn <- preprocess hs_fn
-        modsrc <- readFile hspp_fn
-        let (srcimps,imps,mod_name) = getImports modsrc
+        (srcimps,imps,mod_name) <- getImportsFromFile hspp_fn
 
        when (mod_name /= moduleName mod) $
-               throwDyn (UserError 
-                  (showSDoc (text modsrc
+               throwDyn (ProgramError 
+                  (showSDoc (text hs_fn
                              <>  text ": file name does not match module name"
                              <+> quotes (ppr (moduleName mod)))))
 
@@ -1070,7 +1067,7 @@ noHsFileErr mod
   = panic (showSDoc (text "no source file for module" <+> quotes (ppr mod)))
 
 packageModErr mod
-  = throwDyn (UserError (showSDoc (text "module" <+>
+  = throwDyn (CmdLineError (showSDoc (text "module" <+>
                                   quotes (ppr mod) <+>
                                   text "is a package module")))
 \end{code}