2008/9/30 David Waern <[EMAIL PROTECTED]>:
> Here's the reduced program:

Sorry, here's the correct version (it got messed up during copy-paste):

(mkGhcModule is a complete no-op, it just creates a record out of some
of the typechecking results)

main :: IO ()
main = handleTopExceptions $ do
  -- parse command-line flags and handle some of them initially
  args <- getArgs
  (flags, fileArgs) <- parseHaddockOpts args
  handleEasyFlags flags fileArgs

  when (null fileArgs) $ exitWith ExitSuccess

  libDir <- case getGhcLibDir flags of
    Just dir -> return dir
    Nothing ->
#ifdef IN_GHC_TREE
      do m <- getExecDir
         case m of
           Nothing -> error "No GhcLibDir found"
           Just d -> return (d </> "..")
#else
      return libdir -- from GHC.Paths
#endif

  startGhc libDir (ghcFlags flags) $ \dynflags -> do
      -- load all argument files
    targets <- mapM (\f -> guessTarget f Nothing) fileArgs
    setTargets targets

    flag <- load LoadAllTargets
    when (failed flag) $
      throwE "Failed to load all needed modules"

    modgraph <- getModuleGraph

    let mods = concatMap flattenSCC $ topSortModuleGraph False modgraph Nothing
        getModFile = fromJust . ml_hs_file . ms_location
        mods'= [ (ms_mod modsum, ms_hspp_opts modsum, getModFile modsum) |
                 modsum <- mods ]

      -- typecheck the argument modules

    forM_ mods' $ \(mod, flags, file) ->
      handleSourceError
          (\err -> do
             printExceptionAndWarnings err
             throwE ("Failed to check module: " ++ moduleString mod)) $
        do tc_mod <- typecheckModule =<< parseModule (moduleName mod)
           let Just renamed_src = renamedSource tc_mod
           return $ mkGhcModule (mod, file, (parsedSource tc_mod,
                                             renamed_src,
                                             typecheckedSource tc_mod,
                                             moduleInfo tc_mod))
                                 flags

_______________________________________________
Cvs-ghc mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/cvs-ghc

Reply via email to