X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Fcompiler%2Fghci%2FInteractiveUI.hs;h=d2a96fcd2e4a99afd9168a2a3ec8bb53e67fbc2c;hb=315a1f6c671b9800909752c702bda347198dd60a;hp=a03b2fe3ddeaf15ba8fef907295408789c1e9700;hpb=d9d1dc64baab3284103676fb14b4128e47a1da4f;p=ghc-hetmet.git diff --git a/ghc/compiler/ghci/InteractiveUI.hs b/ghc/compiler/ghci/InteractiveUI.hs index a03b2fe..c4b5f97 100644 --- a/ghc/compiler/ghci/InteractiveUI.hs +++ b/ghc/compiler/ghci/InteractiveUI.hs @@ -1,203 +1,410 @@ +{-# OPTIONS -#include "Linker.h" #-} ----------------------------------------------------------------------------- --- $Id: InteractiveUI.hs,v 1.37 2001/02/09 15:33:51 simonmar Exp $ -- -- GHC Interactive User Interface -- --- (c) The GHC Team 2000 +-- (c) The GHC Team 2005 -- ----------------------------------------------------------------------------- - -module InteractiveUI (interactiveUI) where +module InteractiveUI ( + interactiveUI, + ghciWelcomeMsg + ) where #include "HsVersions.h" -import CompManager -import CmStaticInfo -import ByteCodeLink -import DriverFlags -import DriverState -import DriverUtil -import Type -import Linker -import Finder -import Module +-- The GHC interface +import qualified GHC +import GHC ( Session, verbosity, dopt, DynFlag(..), Target(..), + TargetId(..), DynFlags(..), + pprModule, Type, Module, SuccessFlag(..), + TyThing(..), Name, LoadHowMuch(..), Phase, + GhcException(..), showGhcException, + CheckedModule(..), SrcLoc ) +import Packages ( PackageState(..) ) +import PackageConfig ( InstalledPackageInfo(..) ) +import UniqFM ( eltsUFM ) +import PprTyThing import Outputable -import Util -import PprType {- instance Outputable Type; do not delete -} -import Panic ( GhcException(..) ) - -import Exception -import Dynamic -#ifndef NO_READLINE -import Readline + +-- for createtags (should these come via GHC?) +import Module ( moduleString ) +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 IOExts -import Numeric -import List -import System -import CPUTime -import Directory -import IO -import Char -import Monad ( when ) +#ifdef USE_READLINE +import Control.Concurrent ( yield ) -- Used in readline loop +import System.Console.Readline as Readline +#endif +--import SystemExts + +import Control.Exception as Exception +import Data.Dynamic +-- import Control.Concurrent + +import Numeric +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 Text.Printf + +import GHC.Exts ( unsafeCoerce# ) +import GHC.IOBase ( IOErrorType(InvalidArgument) ) + +import Data.IORef ( IORef, newIORef, readIORef, writeIORef ) + +import System.Posix.Internals ( setNonBlockingFD ) ----------------------------------------------------------------------------- -ghciWelcomeMsg = "\ -\ ___ ___ _ \n\ -\ / _ \\ /\\ /\\/ __(_) GHC Interactive, version 5.00, For Haskell 98. \n\ -\ / /_\\// /_/ / / | | http://www.haskell.org/ghc \n\ -\/ /_\\\\/ __ / /___| | Bug reports to: glasgow-haskell-bugs@haskell.org \n\ -\\\____/\\/ /_/\\____/|_| Type :? for help.\n" - -commands :: [(String, String -> GHCi Bool)] -commands = [ - ("add", keepGoing addModule), - ("cd", keepGoing changeDirectory), - ("help", keepGoing help), - ("?", keepGoing help), - ("load", keepGoing loadModule), - ("module", keepGoing setContext), - ("reload", keepGoing reloadModule), - ("set", keepGoing setOptions), - ("type", keepGoing typeOfExpr), - ("unset", keepGoing unsetOptions), - ("quit", quit) +ghciWelcomeMsg = + " ___ ___ _\n"++ + " / _ \\ /\\ /\\/ __(_)\n"++ + " / /_\\// /_/ / / | | GHC Interactive, version " ++ cProjectVersion ++ ", for Haskell 98.\n"++ + "/ /_\\\\/ __ / /___| | http://www.haskell.org/ghc/\n"++ + "\\____/\\/ /_/\\____/|_| Type :? for help.\n" + +type Command = (String, String -> GHCi Bool, String -> IO [String]) +cmdName (n,_,_) = n + +GLOBAL_VAR(commands, builtin_commands, [Command]) + +builtin_commands :: [Command] +builtin_commands = [ + ("add", keepGoingPaths addModule, completeFilename), + ("browse", keepGoing browseCmd, completeModule), + ("cd", keepGoing changeDirectory, completeFilename), + ("def", keepGoing defineMacro, completeIdentifier), + ("help", keepGoing help, completeNone), + ("?", keepGoing help, completeNone), + ("info", keepGoing info, completeIdentifier), + ("load", keepGoingPaths loadModule_, completeHomeModuleOrFile), + ("module", keepGoing setContext, completeModule), + ("main", keepGoing runMain, completeIdentifier), + ("reload", keepGoing reloadModule, completeNone), + ("check", keepGoing checkModule, completeHomeModule), + ("set", keepGoing setCmd, completeNone), -- ToDo + ("show", keepGoing showCmd, completeNone), + ("etags", keepGoing createETagsFileCmd, completeFilename), + ("ctags", keepGoing createCTagsFileCmd, completeFilename), + ("type", keepGoing typeOfExpr, completeIdentifier), + ("kind", keepGoing kindOfType, completeIdentifier), + ("unset", keepGoing unsetOptions, completeNone), -- ToDo + ("undef", keepGoing undefineMacro, completeNone), -- ToDo + ("quit", quit, completeNone) ] 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 \n\ -\ :add add a module to the current set\n\ -\ :cd change directory to \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