X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Fcompiler%2Fghci%2FInteractiveUI.hs;h=d2a96fcd2e4a99afd9168a2a3ec8bb53e67fbc2c;hb=c5d7cfca30757811ed00bdbd8dff782b75821c0c;hp=e6990889658213d573567663e78a2d96fea0e13e;hpb=7794a5513328199916f5230521b10b874c42f2ed;p=ghc-hetmet.git diff --git a/ghc/compiler/ghci/InteractiveUI.hs b/ghc/compiler/ghci/InteractiveUI.hs index e699088..d2a96fc 100644 --- a/ghc/compiler/ghci/InteractiveUI.hs +++ b/ghc/compiler/ghci/InteractiveUI.hs @@ -1,33 +1,66 @@ +{-# OPTIONS -#include "Linker.h" -#include "SchedAPI.h" #-} ----------------------------------------------------------------------------- --- $Id: InteractiveUI.hs,v 1.25 2001/01/10 17:19:01 sewardj Exp $ +-- $Id: InteractiveUI.hs,v 1.123 2002/05/01 15:48:48 simonmar Exp $ -- -- GHC Interactive User Interface -- -- (c) The GHC Team 2000 -- ----------------------------------------------------------------------------- +module InteractiveUI ( + interactiveUI, -- :: CmState -> [FilePath] -> [LibrarySpec] -> IO () + LibrarySpec(..), + ghciWelcomeMsg + ) where -module InteractiveUI (interactiveUI) where - +#include "../includes/config.h" #include "HsVersions.h" +import Packages + import CompManager -import CmStaticInfo +import CmTypes ( Linkable, isObjectLinkable, ModSummary(..) ) +import CmLink ( findModuleLinkable_maybe ) + +import HscTypes ( TyThing(..), showModMsg, InteractiveContext(..) ) +import HsSyn ( TyClDecl(..), ConDecl(..), Sig(..) ) +import MkIface ( ifaceTyThing ) import DriverFlags -import DriverUtil import DriverState +import DriverUtil ( handle, remove_spaces ) import Linker -import Module -import Outputable +import Finder ( flushPackageCache ) import Util -import PprType {- instance Outputable Type; do not delete -} -import Panic ( GhcException(..) ) +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 ( moduleName ) +import NameEnv ( nameEnvElts ) +import Name ( Name, isHomePackageName, nameSrcLoc, nameOccName, + NamedThing(..) ) +import OccName ( isSymOcc ) +import BasicTypes ( defaultFixity ) +import Outputable +import CmdLineOpts ( DynFlag(..), DynFlags(..), getDynFlags, saveDynFlags, + restoreDynFlags, dopt_unset ) +import Panic ( GhcException(..), showGhcException ) +import Config + +#ifndef mingw32_TARGET_OS +import Posix +#endif import Exception -#ifndef NO_READLINE -import Readline +import Dynamic +#if HAVE_READLINE_HEADERS && HAVE_READLINE_LIBS +import Readline #endif +import Concurrent import IOExts +import SystemExts import Numeric import List @@ -36,30 +69,41 @@ import CPUTime import Directory import IO import Char +import Monad +import GlaExts ( unsafeCoerce# ) + +import Foreign ( nullPtr ) +import CString ( CString, peekCString, withCString ) ----------------------------------------------------------------------------- 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 = [ +\ ___ ___ _\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 setOptions), + ("set", keepGoing setCmd), + ("show", keepGoing showCmd), ("type", keepGoing typeOfExpr), ("unset", keepGoing unsetOptions), + ("undef", keepGoing undefineMacro), ("quit", quit) ] @@ -68,131 +112,308 @@ 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 = "\ \ 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