From 104baabc81fb73ef681c46dd4e0e6ff5d7117d9e Mon Sep 17 00:00:00 2001 From: simonmar Date: Tue, 27 Mar 2001 16:55:03 +0000 Subject: [PATCH] [project @ 2001-03-27 16:55:03 by simonmar] CmdLineOpts: - add dopt_set and dopt_unset utils. InteractiveUI: - unset -fwarn-unused-binds before evaluating a statement, to avoid bogus warnings about new bindings. --- ghc/compiler/ghci/InteractiveUI.hs | 6 ++++-- ghc/compiler/main/CmdLineOpts.lhs | 8 ++++++++ ghc/compiler/main/DriverFlags.hs | 6 +++--- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/ghc/compiler/ghci/InteractiveUI.hs b/ghc/compiler/ghci/InteractiveUI.hs index bb696c8..cd531b2 100644 --- a/ghc/compiler/ghci/InteractiveUI.hs +++ b/ghc/compiler/ghci/InteractiveUI.hs @@ -1,5 +1,5 @@ ----------------------------------------------------------------------------- --- $Id: InteractiveUI.hs,v 1.57 2001/03/25 13:29:54 simonmar Exp $ +-- $Id: InteractiveUI.hs,v 1.58 2001/03/27 16:55:03 simonmar Exp $ -- -- GHC Interactive User Interface -- @@ -22,6 +22,7 @@ import Linker import Util import Name ( Name ) import Outputable +import CmdLineOpts ( DynFlag(..), dopt_unset ) import Panic ( GhcException(..) ) import Config @@ -254,7 +255,8 @@ runStmt stmt | otherwise = do st <- getGHCiState dflags <- io (getDynFlags) - (new_cmstate, names) <- io (cmRunStmt (cmstate st) dflags stmt) + let dflags' = dopt_unset dflags Opt_WarnUnusedBinds + (new_cmstate, names) <- io (cmRunStmt (cmstate st) dflags' stmt) setGHCiState st{cmstate = new_cmstate} return (Just names) diff --git a/ghc/compiler/main/CmdLineOpts.lhs b/ghc/compiler/main/CmdLineOpts.lhs index 9227351..a8e232b 100644 --- a/ghc/compiler/main/CmdLineOpts.lhs +++ b/ghc/compiler/main/CmdLineOpts.lhs @@ -28,6 +28,8 @@ module CmdLineOpts ( opt_PprStyle_Debug, dopt, + dopt_set, + dopt_unset, -- other dynamic flags dopt_CoreToDo, @@ -347,6 +349,12 @@ dopt_StgToDo = stgToDo dopt_OutName :: DynFlags -> String dopt_OutName = hscOutName +dopt_set :: DynFlags -> DynFlag -> DynFlags +dopt_set dfs f = dfs{ flags = f : flags dfs } + +dopt_unset :: DynFlags -> DynFlag -> DynFlags +dopt_unset dfs f = dfs{ flags = filter (/= f) (flags dfs) } + data HscLang = HscC | HscAsm diff --git a/ghc/compiler/main/DriverFlags.hs b/ghc/compiler/main/DriverFlags.hs index d080ab7..b128364 100644 --- a/ghc/compiler/main/DriverFlags.hs +++ b/ghc/compiler/main/DriverFlags.hs @@ -1,7 +1,7 @@ {-# OPTIONS -#include "hschooks.h" #-} ----------------------------------------------------------------------------- --- $Id: DriverFlags.hs,v 1.49 2001/03/15 15:53:28 simonmar Exp $ +-- $Id: DriverFlags.hs,v 1.50 2001/03/27 16:55:03 simonmar Exp $ -- -- Driver flags -- @@ -318,8 +318,8 @@ getDynFlags = readIORef v_DynFlags dynFlag :: (DynFlags -> a) -> IO a dynFlag f = do dflags <- readIORef v_DynFlags; return (f dflags) -setDynFlag f = updDynFlags (\dfs -> dfs{ flags = f : flags dfs }) -unSetDynFlag f = updDynFlags (\dfs -> dfs{ flags = filter (/= f) (flags dfs) }) +setDynFlag f = updDynFlags (\dfs -> dopt_set dfs f) +unSetDynFlag f = updDynFlags (\dfs -> dopt_unset dfs f) addOpt_L a = updDynFlags (\s -> s{opt_L = a : opt_L s}) addOpt_P a = updDynFlags (\s -> s{opt_P = a : opt_P s}) -- 1.7.10.4