X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Fcompiler%2Fghci%2FInteractiveUI.hs;h=af140e5088dc3231a9158008654fcbac1de35bdc;hb=f2e26fc5cb932857160772b64d2f17ce2a863fd4;hp=f4193fcf0fef6a918df8845839e4bfe218b84c3b;hpb=292c077de7dbe98eb44911648f16e243b40db2ac;p=ghc-hetmet.git diff --git a/ghc/compiler/ghci/InteractiveUI.hs b/ghc/compiler/ghci/InteractiveUI.hs index f4193fc..af140e5 100644 --- a/ghc/compiler/ghci/InteractiveUI.hs +++ b/ghc/compiler/ghci/InteractiveUI.hs @@ -1,213 +1,1054 @@ +{-# OPTIONS -#include "Linker.h" -#include "SchedAPI.h" #-} ----------------------------------------------------------------------------- --- $Id: InteractiveUI.hs,v 1.2 2000/11/16 11:39:37 simonmar Exp $ +-- $Id: InteractiveUI.hs,v 1.137 2002/10/17 14:49:52 simonmar 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 DriverUtil +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 Panic +import DriverUtil ( remove_spaces, handle ) +import Linker ( initLinker, showLinkerState, linkLibraries ) +import Finder ( flushFinderCache ) import Util +import Id ( isRecordSelector, recordSelectorFieldLabel, + isDataConWrapId, isDataConId, idName ) +import Class ( className ) +import TyCon ( tyConName, tyConClass_maybe, isPrimTyCon, DataConDetails(..) ) +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 ( GhcException(..), showGhcException ) +import Config -import Exception -import Readline -import IOExts +#ifndef mingw32_TARGET_OS +import System.Posix +#endif + +#if HAVE_READLINE_HEADERS && HAVE_READLINE_LIBS +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 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 System -import Directory -import IO -import Char +import GHC.Exts ( unsafeCoerce# ) + +import Foreign ( nullPtr ) +import Foreign.C.String ( CString, peekCString, withCString ) +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 ())] -commands = [ - ("cd", changeDirectory), - ("help", help), - ("?", help), - ("load", loadModule), - ("reload", reloadModule), - ("set", setOptions), - ("type", typeOfExpr), - ("quit", quit), - ("!", shellEscape) +\ ___ ___ _\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), + ("browse", keepGoing browseCmd), + ("cd", keepGoing changeDirectory), + ("def", keepGoing defineMacro), + ("help", keepGoing help), + ("?", keepGoing help), + ("info", keepGoing info), + ("load", keepGoing loadModule), + ("module", keepGoing setContext), + ("reload", keepGoing reloadModule), + ("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 + shortHelpText = "use :? for help.\n" +-- NOTE: spaces at the end of each line to workaround CPP/string gap bug. helpText = "\ -\ evaluate \n\ -\ :cd change directory to \n\ -\ :help display this list of commands\n\ -\ :? display this list of commands\n\ -\ :load load a module (and it dependents)\n\ -\ :reload reload the current program\n\ -\ :set ... set options\n\ -\ :type show the type of \n\ -\ :quit exit GHCi\n\ -\ :! run the shell command \n\ +\ Commands available from the prompt:\n\ +\\n\ +\ evaluate/run \n\ +\ :add ... add module(s) to the current target set\n\ +\ :browse [*] display the names defined by \n\ +\ :cd change directory to \n\ +\ :def define a command :\n\ +\ :help, :? display this list of commands\n\ +\ :info [ ...] display information about the given names\n\ +\ :load ... load module(s) and their dependents\n\ +\ :module [+/-] [*] ... set the context for expression evaluation\n\ +\ :reload reload the current module set\n\ +\\n\ +\ :set