{-# OPTIONS -W -fno-warn-incomplete-patterns #-}
-----------------------------------------------------------------------------
--- $Id: Main.hs,v 1.21 2000/11/14 16:28:38 simonmar Exp $
+-- $Id: Main.hs,v 1.28 2000/11/20 16:37:42 sewardj Exp $
--
-- GHC Driver program
--
#include "HsVersions.h"
import CompManager
+import Interpreter
+#ifdef GHCI
+import InteractiveUI
+#endif
import DriverPipeline
import DriverState
import DriverFlags
import DriverMkDepend
import DriverUtil
+import Panic
import DriverPhases ( Phase(..) )
import CmdLineOpts ( HscLang(..), DynFlags(..), v_Static_hsc_opts )
import Module ( mkModuleName )
import CmStaticInfo
import Config
import Util
-import Panic
import Concurrent
#ifndef mingw32_TARGET_OS
-- reading the package configuration file is too slow
-- -H, -K, -Rghc-timing
-- hi-diffs
+-- -ddump-all doesn't do anything
-----------------------------------------------------------------------------
-- Differences vs. old driver:
installHandler sigINT sig_handler Nothing
#endif
- pgm <- getProgName
- writeIORef v_Prog_name pgm
-
argv <- getArgs
-- grab any -B options from the command line first
stgToDo = stg_todo,
hscLang = lang,
-- leave out hscOutName for now
+ hscOutName = panic "Main.main:hscOutName not set",
flags = [] }
-- the rest of the arguments are "dynamic"
-- complain about any unknown flags
mapM unknownFlagErr [ f | f@('-':_) <- srcs ]
+ -- save the flag state, because this could be modified by OPTIONS
+ -- pragmas during the compilation, and we'll need to restore it
+ -- before starting the next compilation.
+ saved_driver_state <- readIORef v_Driver_state
+ writeIORef v_InitDriverState saved_driver_state
+
-- get the -v flag
verb <- readIORef v_Verbose
if null srcs then throwDyn (UsageError "no input files") else do
- -- save the flag state, because this could be modified by OPTIONS
- -- pragmas during the compilation, and we'll need to restore it
- -- before starting the next compilation.
- saved_driver_state <- readIORef v_Driver_state
-
let compileFile (src, phases) = do
writeIORef v_Driver_state saved_driver_state
writeIORef v_DynFlags init_dyn_flags
beginMake pkg_details mods
= do case mods of
[] -> throwDyn (UsageError "no input files")
- [mod] -> do state <- cmInit pkg_details
- cmLoadModule state (mkModuleName mod)
+ [mod] -> do state <- cmInit pkg_details Batch
+ cmLoadModule state mod
return ()
_ -> throwDyn (UsageError "only one module allowed with --make")
+#ifndef GHCI
+beginInteractive = throwDyn (OtherError "not build for interactive use")
+#else
beginInteractive pkg_details mods
- = do case mods of
- [] -> return ()
- [mod] -> do state <- cmInit pkg_details
- cmLoadModule state (mkModuleName mod)
- return ()
- _ -> throwDyn (UsageError
+ = do state <- cmInit pkg_details Interactive
+ case mods of
+ [] -> return ()
+ [mod] -> do cmLoadModule state mod; return ()
+ _ -> throwDyn (UsageError
"only one module allowed with --interactive")
- interactiveUI
-
-interactiveUI :: IO ()
-interactiveUI = do
- hPutStr stdout ghciWelcomeMsg
- throwDyn (OtherError "GHCi not implemented yet")
-
-ghciWelcomeMsg = "\
-\ _____ __ __ ____ ------------------------------------------------\n\
-\(| || || (| |) GHCi: GHC Interactive, version 5.00 \n\
-\|| __ ||___|| || () For Haskell 98. \n\
-\|| |) ||---|| || // http://www.haskell.org/ghc \n\
-\|| || || || || // Bug reports to: glasgow-haskell-bugs@haskell.org\n\
-\(|___|| || || (|__|) (| ________________________________________________\n"
-
+ interactiveUI state
+#endif