X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Fcompiler%2Fghci%2FInteractiveUI.hs;h=707b2785006872f7eba436d7950b881022d49c6a;hb=3355c9d53b220ccb110e5a3c81a1a8b2c9c41555;hp=c3c163aab172da51988ae324bcd657a7acf8ed61;hpb=f81c9189fccc07c33506de8480648f28f893d882;p=ghc-hetmet.git diff --git a/ghc/compiler/ghci/InteractiveUI.hs b/ghc/compiler/ghci/InteractiveUI.hs index c3c163a..125c899 100644 --- a/ghc/compiler/ghci/InteractiveUI.hs +++ b/ghc/compiler/ghci/InteractiveUI.hs @@ -1,210 +1,421 @@ +{-# OPTIONS -#include "Linker.h" #-} ----------------------------------------------------------------------------- --- $Id: InteractiveUI.hs,v 1.27 2001/01/18 10:51:53 simonmar Exp $ +-- $Id: InteractiveUI.hs,v 1.146 2003/02/19 15:54:07 simonpj Exp $ -- -- GHC Interactive User Interface -- -- (c) The GHC Team 2000 -- ----------------------------------------------------------------------------- +module InteractiveUI ( + interactiveUI, -- :: CmState -> [FilePath] -> [LibrarySpec] -> IO () + ghciWelcomeMsg + ) where -module InteractiveUI (interactiveUI) where - +#include "../includes/config.h" #include "HsVersions.h" import CompManager -import CmStaticInfo +import HscTypes ( TyThing(..), HomeModInfo(hm_linkable), HomePackageTable, + isObjectLinkable ) +import HsSyn ( TyClDecl(..), ConDecl(..), Sig(..) ) +import MkIface ( ifaceTyThing ) import DriverFlags import DriverState -import Linker -import Module -import Outputable +import DriverUtil ( remove_spaces, handle ) +import Linker ( initLinker, showLinkerState, linkLibraries, + linkPackages ) import Util -import PprType {- instance Outputable Type; do not delete -} -import Panic ( GhcException(..) ) +import IdInfo ( GlobalIdDetails(..) ) +import Id ( isImplicitId, idName ) +import Class ( className ) +import TyCon ( tyConName, tyConClass_maybe, isPrimTyCon, DataConDetails(..) ) +import DataCon ( dataConName ) +import FieldLabel ( fieldLabelTyCon ) +import SrcLoc ( isGoodSrcLoc ) +import Module ( showModMsg, lookupModuleEnv ) +import Name ( Name, isHomePackageName, nameSrcLoc, nameOccName, + NamedThing(..) ) +import OccName ( isSymOcc ) +import BasicTypes ( defaultFixity, SuccessFlag(..) ) +import Packages +import Outputable +import CmdLineOpts ( DynFlag(..), DynFlags(..), getDynFlags, saveDynFlags, + restoreDynFlags, dopt_unset ) +import Panic hiding ( showException ) +import Config + +#ifndef mingw32_TARGET_OS +import System.Posix +#endif -import Exception -#ifndef NO_READLINE -import Readline +#if HAVE_READLINE_HEADERS && HAVE_READLINE_LIBS +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 Data.List +import System.Cmd +import System.CPUTime +import System.Environment +import System.Directory +import System.IO as IO +import Data.Char +import Control.Monad as Monad + +import GHC.Exts ( unsafeCoerce# ) + +import Data.IORef ( IORef, newIORef, readIORef, writeIORef ) +import GHC.Posix ( setNonBlockingFD ) ----------------------------------------------------------------------------- ghciWelcomeMsg = "\ -\ _____ __ __ ____ _________________________________________________\n\ -\(| || || (| |) 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" - -commands :: [(String, String -> GHCi Bool)] -commands = [ - ("add", keepGoing addModule), +\ ___ ___ _\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", 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), + ("set", keepGoing setCmd), + ("show", keepGoing showCmd), ("type", keepGoing typeOfExpr), ("unset", keepGoing unsetOptions), + ("undef", keepGoing undefineMacro), ("quit", quit) ] 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" +-- NOTE: spaces at the end of each line to workaround CPP/string gap bug. 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