X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Fcompiler%2Fghci%2FInteractiveUI.hs;h=0bf37dc4005e408893fc4663c9dc5d34b22a9528;hb=8d180b0dd5b3796c96b162464b93ab1cacc3b789;hp=be216e6c85bcd8c3d0489605a1f70920a0a009ef;hpb=55411b4b8faa19db3c746d07e13d41fb931ab646;p=ghc-hetmet.git diff --git a/ghc/compiler/ghci/InteractiveUI.hs b/ghc/compiler/ghci/InteractiveUI.hs index be216e6..0bf37dc 100644 --- a/ghc/compiler/ghci/InteractiveUI.hs +++ b/ghc/compiler/ghci/InteractiveUI.hs @@ -1,75 +1,117 @@ +{-# OPTIONS -#include "Linker.h" #-} ----------------------------------------------------------------------------- --- $Id: InteractiveUI.hs,v 1.64 2001/04/26 11:38:53 qrczak Exp $ -- -- GHC Interactive User Interface -- --- (c) The GHC Team 2000 +-- (c) The GHC Team 2005 -- ----------------------------------------------------------------------------- +module InteractiveUI ( + interactiveUI, + ghciWelcomeMsg + ) where -{-# OPTIONS -#include "Linker.h" #-} -module InteractiveUI ( interactiveUI, ghciWelcomeMsg ) where - -#include "../includes/config.h" #include "HsVersions.h" -import CompManager -import CmStaticInfo -import ByteCodeLink -import DriverFlags -import DriverState -import DriverUtil -import Linker -import Util -import Name ( Name ) +-- The GHC interface +import qualified GHC +import GHC ( Session, verbosity, dopt, DynFlag(..), Target(..), + TargetId(..), + mkModule, pprModule, Type, Module, SuccessFlag(..), + TyThing(..), Name, LoadHowMuch(..), Phase, + GhcException(..), showGhcException, + CheckedModule(..), SrcLoc ) +import PprTyThing import Outputable -import CmdLineOpts ( DynFlag(..), dopt_unset ) -import Panic ( GhcException(..) ) + +-- for createtags (should these come via GHC?) +import Module( moduleUserString ) +import Name( nameSrcLoc, nameModule, nameOccName ) +import OccName( pprOccName ) +import SrcLoc( isGoodSrcLoc, srcLocFile, srcLocLine, srcLocCol ) + +-- Other random utilities +import Digraph ( flattenSCCs ) +import BasicTypes ( failed, successIf ) +import Panic ( panic, installSignalHandlers ) import Config +import StaticFlags ( opt_IgnoreDotGhci ) +import Linker ( showLinkerState ) +import Util ( removeSpaces, handle, global, toArgs, + looksLikeModuleName, prefixMatch, sortLe ) + +#ifndef mingw32_HOST_OS +import System.Posix +#if __GLASGOW_HASKELL__ > 504 + hiding (getEnv) +#endif +#else +import GHC.ConsoleHandler ( flushConsole ) +#endif -import Exception -import Dynamic -#if HAVE_READLINE_HEADERS && HAVE_READLINE_LIBS -import Readline +#ifdef USE_READLINE +import Control.Concurrent ( yield ) -- Used in readline loop +import System.Console.Readline as Readline #endif -import IOExts + +--import SystemExts + +import Control.Exception as Exception +import Data.Dynamic +-- import Control.Concurrent import Numeric -import List -import System -import CPUTime -import Directory -import IO -import Char -import Monad ( when ) - -import PrelGHC ( unsafeCoerce# ) -import Foreign ( nullPtr ) -import CString ( peekCString ) +import Data.List +import Data.Int ( Int64 ) +import Data.Maybe ( isJust, fromMaybe, catMaybes ) +import System.Cmd +import System.CPUTime +import System.Environment +import System.Exit ( exitWith, ExitCode(..) ) +import System.Directory +import System.IO +import System.IO.Error as IO +import Data.Char +import Control.Monad as Monad +import Foreign.StablePtr ( newStablePtr ) + +import GHC.Exts ( unsafeCoerce# ) +import GHC.IOBase ( IOErrorType(InvalidArgument) ) + +import Data.IORef ( IORef, newIORef, readIORef, writeIORef ) + +import System.Posix.Internals ( setNonBlockingFD ) ----------------------------------------------------------------------------- -ghciWelcomeMsg = "\ -\ ___ ___ _\n\ -\ / _ \\ /\\ /\\/ __(_)\n\ -\ / /_\\// /_/ / / | | GHC Interactive, version " ++ cProjectVersion ++ ", For Haskell 98.\n\ -\/ /_\\\\/ __ / /___| | http://www.haskell.org/ghc/\n\ -\\\____/\\/ /_/\\____/|_| Type :? for help.\n" +ghciWelcomeMsg = + " ___ ___ _\n"++ + " / _ \\ /\\ /\\/ __(_)\n"++ + " / /_\\// /_/ / / | | GHC Interactive, version " ++ cProjectVersion ++ ", for Haskell 98.\n"++ + "/ /_\\\\/ __ / /___| | http://www.haskell.org/ghc/\n"++ + "\\____/\\/ /_/\\____/|_| Type :? for help.\n" GLOBAL_VAR(commands, builtin_commands, [(String, String -> GHCi Bool)]) builtin_commands :: [(String, String -> GHCi Bool)] builtin_commands = [ - ("add", keepGoing addModule), + ("add", keepGoingPaths addModule), + ("browse", keepGoing browseCmd), ("cd", keepGoing changeDirectory), ("def", keepGoing defineMacro), ("help", keepGoing help), ("?", keepGoing help), - ("load", keepGoing loadModule), + ("info", keepGoing info), + ("load", keepGoingPaths loadModule_), ("module", keepGoing setContext), ("reload", keepGoing reloadModule), - ("set", keepGoing setOptions), + ("check", keepGoing checkModule), + ("set", keepGoing setCmd), + ("show", keepGoing showCmd), + ("etags", keepGoing createETagsFileCmd), + ("ctags", keepGoing createCTagsFileCmd), ("type", keepGoing typeOfExpr), + ("kind", keepGoing kindOfType), ("unset", keepGoing unsetOptions), ("undef", keepGoing undefineMacro), ("quit", quit) @@ -78,116 +120,236 @@ builtin_commands = [ keepGoing :: (String -> GHCi ()) -> (String -> GHCi Bool) keepGoing a str = a str >> return False +keepGoingPaths :: ([FilePath] -> GHCi ()) -> (String -> GHCi Bool) +keepGoingPaths a str = a (toArgs str) >> return False + shortHelpText = "use :? for help.\n" -helpText = "\ -\ Commands available from the prompt:\n\ -\\ -\ evaluate/run \n\ -\ :cd change directory to \n\ -\ :def define a command :\n\ -\ :help, :? display this list of commands\n\ -\ :load load a module (and it dependents)\n\ -\ :module set the context for expression evaluation to \n\ -\ :reload reload the current module set\n\ -\ :set