[project @ 2001-02-20 11:04:42 by simonmar]
[ghc-hetmet.git] / ghc / compiler / main / Main.hs
index 9790e1d..df50f1c 100644 (file)
@@ -1,6 +1,6 @@
 {-# OPTIONS -fno-warn-incomplete-patterns #-}
 -----------------------------------------------------------------------------
--- $Id: Main.hs,v 1.51 2001/02/13 15:51:57 sewardj Exp $
+-- $Id: Main.hs,v 1.54 2001/02/20 11:04:42 simonmar Exp $
 --
 -- GHC Driver program
 --
@@ -164,9 +164,26 @@ main =
    (flags2, mode, stop_flag) <- getGhcMode argv'
    writeIORef v_GhcMode mode
 
+       -- Show the GHCi banner?
+#  ifdef GHCI
+   when (mode == DoInteractive) $
+      hPutStrLn stdout ghciWelcomeMsg
+#  endif
+
        -- process all the other arguments, and get the source files
    non_static <- processArgs static_flags flags2 []
 
+       -- -O and --interactive are not a good combination
+       -- ditto with any kind of way selection
+   orig_opt_level <- readIORef v_OptLevel
+   when (orig_opt_level > 0 && mode == DoInteractive) $
+      do putStr "warning: -O conflicts with --interactive; -O turned off.\n"
+         writeIORef v_OptLevel 0
+   orig_ways <- readIORef v_Ways
+   when (not (null orig_ways) && mode == DoInteractive) $
+      do throwDyn (OtherError 
+                   "--interactive can't be used with -prof, -ticky, -unreg or -smp.")
+
        -- Find the build tag, and re-process the build-specific options.
        -- Also add in flags for unregisterised compilation, if 
        -- GhcUnregisterised=YES.
@@ -179,17 +196,8 @@ main =
    static_opts <- buildStaticHscOpts
    writeIORef v_Static_hsc_opts static_opts
 
-       -- warnings
-   warn_level <- readIORef v_Warning_opt
-
-   let warn_opts =  case warn_level of
-                       W_default -> standardWarnings
-                       W_        -> minusWOpts
-                       W_all     -> minusWallOpts
-                       W_not     -> []
-
-       -- build the default DynFlags (these may be adjusted on a per
-       -- module basis by OPTIONS pragmas and settings in the interpreter).
+   -- build the default DynFlags (these may be adjusted on a per
+   -- module basis by OPTIONS pragmas and settings in the interpreter).
 
    core_todo <- buildCoreToDo
    stg_todo  <- buildStgToDo
@@ -198,6 +206,8 @@ main =
    -- by module basis, using only the -fvia-C and -fasm flags.  If the global
    -- HscLang is not HscC or HscAsm, -fvia-C and -fasm have no effect.
    opt_level  <- readIORef v_OptLevel
+
+
    let lang = case mode of 
                 StopBefore HCc -> HscC
                 DoInteractive  -> HscInterpreted
@@ -218,8 +228,7 @@ main =
                        }
 
        -- the rest of the arguments are "dynamic"
-   srcs <- processArgs dynamic_flags (way_non_static ++ 
-                                       non_static ++ warn_opts) []
+   srcs <- processArgs dynamic_flags (way_non_static ++ non_static) []
        -- save the "initial DynFlags" away
    init_dyn_flags <- readIORef v_DynFlags
    writeIORef v_InitDynFlags init_dyn_flags
@@ -315,19 +324,18 @@ beginInteractive :: [String] -> IO ()
 beginInteractive = throwDyn (OtherError "not built for interactive use")
 #else
 beginInteractive fileish_args
-  = let is_libraryish nm
-           = let nmr = map toLower (reverse nm)
-                 in take 2 nmr == "o." ||
-                    take 3 nmr == "os." ||
-                    take 4 nmr == "lld."
-        libs = filter is_libraryish fileish_args
-        mods = filter (not.is_libraryish) fileish_args
-        mod = case mods of
-                []    -> Nothing
-                [mod] -> Just mod
-                _     -> throwDyn (UsageError 
-                                    "only one module allowed with --interactive")
-    in
-    do state <- cmInit Interactive
+  = do minus_ls <- readIORef v_Cmdline_libraries
+       let is_libraryish nm
+              = let nmr = map toLower (reverse nm)
+                    in take 2 nmr == "o."
+           libs = map Left (filter is_libraryish fileish_args)
+                  ++ map Right minus_ls
+           mods = filter (not.is_libraryish) fileish_args
+           mod = case mods of
+                   []    -> Nothing
+                   [mod] -> Just mod
+                   _     -> throwDyn (UsageError 
+                                       "only one module allowed with --interactive")
+       state <- cmInit Interactive
        interactiveUI state mod libs
 #endif