Commit 243439e6 authored by Ian Lynagh's avatar Ian Lynagh

Change how macros like ASSERT are defined

By using Haskell's debugIsOn rather than CPP's "#ifdef DEBUG", we
don't need to kludge things to keep the warning checker happy etc.
parent 50fddb2b
......@@ -46,18 +46,9 @@ name :: IORef (ty); \
name = Util.globalM (value);
#endif
#ifdef DEBUG
#define ASSERT(e) if (not (e)) then (assertPanic __FILE__ __LINE__) else
#define ASSERT2(e,msg) if (not (e)) then (assertPprPanic __FILE__ __LINE__ (msg)) else
#define ASSERT(e) if debugIsOn && not (e) then (assertPanic __FILE__ __LINE__) else
#define ASSERT2(e,msg) if debugIsOn && not (e) then (assertPprPanic __FILE__ __LINE__ (msg)) else
#define WARN( e, msg ) (warnPprTrace (e) __FILE__ __LINE__ (msg)) $
#else
-- We have to actually use all the variables we are given or we may get
-- unused variable warnings when DEBUG is off.
#define ASSERT(e) if False && (not (e)) then panic "ASSERT" else
#define ASSERT2(e,msg) if False && (const False (e,msg)) then pprPanic "ASSERT2" (msg) else
#define WARN(e,msg) if False && (e) then pprPanic "WARN" (msg) else
-- Here we deliberately don't use when as Control.Monad might not be imported
#endif
-- Examples: Assuming flagSet :: String -> m Bool
--
......
......@@ -126,7 +126,7 @@ import Outputable
import Unique
import UniqSupply
import FastString
import Util( count )
import Util
import StaticFlags
-- infixl so you can say (id `set` a `set` b)
......
......@@ -62,6 +62,8 @@ import BasicTypes
import Binary
import Constants
import UniqFM
import Util
import Data.Int
import Data.Ratio
import Data.Word
......
......@@ -71,6 +71,7 @@ import FastTypes
import FastString
import Outputable
-- import StaticFlags
import Util
#if defined(__GLASGOW_HASKELL__)
--just for implementing a fast [0,61) -> Char function
......
......@@ -32,7 +32,7 @@ import Constants
import Digraph
import qualified Prelude as P
import Prelude hiding (succ)
import Util (sortLe)
import Util
import BlockId
import Bitmap
......
......@@ -27,6 +27,8 @@ import Platform
import StaticFlags
import UniqSupply
import MonadUtils
import Util
import Data.Bits
import Data.Word
......
......@@ -83,6 +83,7 @@ import OptimizationFuel as F
import Unique
import UniqSupply
import Constants( wORD_SIZE, tAG_MASK )
import Util
import Data.Word
import Data.Maybe
......
......@@ -42,6 +42,7 @@ import SMRep (ByteOff)
import StaticFlags
import Unique
import UniqSupply
import Util
#include "HsVersions.h"
......
......@@ -22,6 +22,7 @@ import Control.Monad
import StaticFlags (opt_Fuel)
import UniqSupply
import Panic
import Util
import Compiler.Hoopl
import Compiler.Hoopl.GHC (getFuel, setFuel)
......
......@@ -77,6 +77,7 @@ import VarEnv
import OrdList
import Unique
import UniqSupply
import Util
import Outputable
import Control.Monad
......
......@@ -43,6 +43,7 @@ import StgSyn
import PrimOp
import Outputable
import StaticFlags
import Util
import Control.Monad
import Data.Maybe
......
......@@ -96,6 +96,7 @@ import Outputable
import FastString
import Constants
import DynFlags
import Util
\end{code}
......
......@@ -45,6 +45,7 @@ import TyCon
import Module
import ErrUtils
import Panic
import Util
codeGen :: DynFlags
-> Module -- Module we are compiling
......
......@@ -46,6 +46,7 @@ import TyCon
import Module
import ErrUtils
import Outputable
import Util
codeGen :: DynFlags
-> Module
......
......@@ -90,6 +90,7 @@ import Outputable
import Platform
import Constants
import DynFlags
import Util
-----------------------------------------------------------------------------
-- Representations
......
......@@ -41,7 +41,7 @@ import PrelInfo
import Outputable
import Platform
import StaticFlags
import Util ( lengthIs )
import Util
import Control.Monad
import Data.Char
......
......@@ -44,6 +44,7 @@ import Module
import FastString( mkFastString, fsLit )
import Constants
import DynFlags
import Util
-----------------------------------------------------------
-- Initialise dynamic heap objects
......
......@@ -43,6 +43,7 @@ import Module
import FastString
import Outputable
import StaticFlags
import Util
------------------------------------------------------------------------
-- Primitive operations and foreign calls
......
......@@ -85,7 +85,7 @@ import Outputable
import FastString
import UniqSupply
import BasicTypes
import Util ( notNull, zipEqual, sortLe )
import Util
import Pair
import Constants
......
......@@ -49,6 +49,7 @@ import PrelNames
import VarSet
import Constants
import Outputable
import Util
\end{code}
Desugaring of @ccall@s consists of adding some state manipulation,
......
......@@ -47,6 +47,8 @@ import Config
import Constants
import OrdList
import Pair
import Util
import Data.Maybe
import Data.List
\end{code}
......
......@@ -33,6 +33,7 @@ import SrcLoc
import Outputable
import FastString
import TcType
import Util
\end{code}
List comprehensions may be desugared in one of two ways: ``ordinary''
......
......@@ -65,7 +65,7 @@ import Bag
import FastString
import ForeignCall
import MonadUtils
import Util( equalLength, filterOut )
import Util
import Data.Maybe
import Control.Monad
......
......@@ -26,7 +26,7 @@ import TcType
import DsMonad
import DsUtils
import MkCore ( mkCoreLets )
import Util ( all2, takeList, zipEqual )
import Util
import ListSetOps ( runs )
import Id
import NameEnv
......
......@@ -34,6 +34,7 @@ import ClosureInfo -- CgRep stuff
import DynFlags
import Outputable
import Platform
import Util
import Control.Monad
import Control.Monad.ST ( runST )
......
......@@ -27,6 +27,7 @@ import Module
import FastString
import Panic
import Outputable
import Util
-- Standard libraries
......
......@@ -32,7 +32,7 @@ import Name
import BasicTypes
import DataCon
import SrcLoc
import Util( dropTail )
import Util
import StaticFlags( opt_PprStyle_Debug )
import Outputable
import FastString
......
......@@ -51,6 +51,7 @@ import Outputable
import Platform
import FastString
import Constants
import Util
import Data.Bits
import Data.Char
......
......@@ -38,7 +38,7 @@ import Type
import Coercion
import TcRnMonad
import Util ( isSingleton )
import Util
import Outputable
\end{code}
......
......@@ -41,6 +41,7 @@ import FastString
import UniqSupply
import SrcLoc
import BasicTypes
import Util
import Outputable
import Exception ( evaluate )
......
......@@ -147,6 +147,7 @@ import UniqFM ( emptyUFM )
import UniqSupply ( initUs_ )
import Bag
import Exception
import Util
import Data.List
import Control.Monad
......
......@@ -57,6 +57,7 @@ import Data.Word
import BasicTypes
import FastString
import Util
-- -----------------------------------------------------------------------------
-- Top-level of the instruction selector
......
......@@ -54,6 +54,7 @@ import FastString
import FastBool ( isFastTrue )
import Constants ( wORD_SIZE )
import DynFlags
import Util
import Control.Monad
import Data.Bits
......
......@@ -76,6 +76,8 @@ import Bag ( Bag, emptyBag, consBag )
import Outputable
import FastString
import Maybes
import Util
import Control.Applicative ((<$>))
import Control.Monad
import Text.ParserCombinators.ReadP as ReadP
......
......@@ -41,6 +41,7 @@ import FastString
import StaticFlags ( opt_SimplExcessPrecision )
import Constants
import BasicTypes
import Util
import Data.Bits as Bits
import Data.Int ( Int64 )
......
......@@ -104,6 +104,7 @@ import Data.Array
import FastString
import Outputable
import Config
import Util
alpha_tyvar :: [TyVar]
alpha_tyvar = [alphaTyVar]
......
......@@ -34,6 +34,7 @@ import Outputable
import DynFlags
import FastString
import SrcLoc
import Util
stgMassageForProfiling
......
......@@ -46,7 +46,7 @@ import RdrName
import LoadIface ( loadInterfaceForName )
import UniqSet
import Data.List
import Util ( isSingleton, snocView )
import Util
import ListSetOps ( removeDups )
import Outputable
import SrcLoc
......
......@@ -55,7 +55,7 @@ import Name
import NameSet
import RdrName
import BasicTypes
import Util ( notNull )
import Util
import ListSetOps ( removeDups )
import Outputable
import SrcLoc
......
......@@ -49,7 +49,7 @@ import Name
import SrcLoc
import NameSet
import Util ( filterOut )
import Util
import BasicTypes ( IPName(..), ipNameName, compareFixity, funTyFixity, negateFixity,
Fixity(..), FixityDirection(..) )
import Outputable
......
......@@ -31,7 +31,7 @@ import Id ( isOneShotBndr, idType )
import Var
import Type ( isUnLiftedType )
import VarSet
import Util ( zipEqual, zipWithEqual, count )
import Util
import UniqFM
import Outputable
\end{code}
......
......@@ -44,7 +44,7 @@ import Digraph ( SCC(..), stronglyConnCompFromEdgedVerticesR )
import PrelNames ( buildIdKey, foldrIdKey, runSTRepIdKey, augmentIdKey )
import Unique
import UniqFM
import Util ( mapAndUnzip, filterOut, fstOf3 )
import Util
import Bag
import Outputable
import FastString
......
......@@ -63,6 +63,7 @@ import BasicTypes
import MonadUtils
import Outputable
import FastString
import Util
import Data.List
\end{code}
......
......@@ -49,6 +49,7 @@ import Data.List ( mapAccumL )
import Outputable
import FastString
import Pair
import Util
\end{code}
......
......@@ -67,6 +67,7 @@ import Type ( Type )
import Type ( typePrimRep )
import UniqSet
import Unique ( Unique )
import Util
import VarSet ( IdSet, isEmptyVarSet )
\end{code}
......
......@@ -44,7 +44,7 @@ import UniqFM ( addToUFM_Directly, lookupUFM_Directly,
minusUFM, filterUFM )
import Type ( isUnLiftedType, eqType, tyConAppTyCon_maybe )
import Coercion ( coercionKind )
import Util ( mapAndUnzip, lengthIs, zipEqual )
import Util
import BasicTypes ( Arity, TopLevelFlag(..), isTopLevel, isNeverActive,
RecFlag(..), isRec, isMarkedStrict )
import Maybes ( orElse, expectJust )
......
......@@ -27,7 +27,7 @@ import BasicTypes
import VarEnv ( isEmptyVarEnv )
import Maybes ( orElse )
import WwLib
import Util ( lengthIs, notNull )
import Util
import Outputable
import MonadUtils
......
......@@ -28,7 +28,7 @@ import Outputable
import UniqFM
import VarSet
import FastString
import Util( filterOut, sortWith )
import Util
import Maybes
import Control.Monad
import Data.Map (Map)
......
......@@ -36,7 +36,7 @@ import VarSet
import TcSMonad
import FastString
import Util ( equalLength )
import Util
import TysWiredIn ( eqTyCon )
......
......@@ -48,6 +48,7 @@ import Maybes
import BasicTypes
import Bag
import FastString
import Util
import Control.Monad
\end{code}
......
......@@ -81,6 +81,7 @@ import Outputable
import Unique
import FastString
import ListSetOps
import Util
\end{code}
......
......@@ -48,6 +48,7 @@ import Platform
import SrcLoc
import Bag
import FastString
import Util
import Control.Monad
\end{code}
......
......@@ -43,6 +43,7 @@ import Bag
import Outputable
import FastString
import UniqSupply
import Util
#include "HsVersions.h"
\end{code}
......
......@@ -59,6 +59,7 @@ import SrcLoc
import Bag
import FastString
import Outputable
import Util
-- import Data.Traversable( traverse )
\end{code}
......
......@@ -73,6 +73,8 @@ import DynFlags ( ExtensionFlag( Opt_DataKinds ) )
import UniqSupply
import Outputable
import FastString
import Util
import Control.Monad ( unless, when, zipWithM )
\end{code}
......
......@@ -55,6 +55,7 @@ import Pair ()
import UniqFM
import FastString ( sLit )
import DynFlags
import Util
\end{code}
**********************************************************************
* *
......
......@@ -119,6 +119,7 @@ import DynFlags
import Outputable
import ListSetOps
import FastString
import Util
import Data.Set (Set)
......
......@@ -66,7 +66,7 @@ import Serialized
import ErrUtils
import SrcLoc
import Outputable
import Util ( dropList )
import Util
import Data.List ( mapAccumL )
import Pair
import Unique
......
......@@ -32,6 +32,7 @@ import Outputable
import ErrUtils
import BasicTypes
import UniqFM
import Util
import Id
import FastString
import Data.Data ( Data, Typeable )
......
......@@ -63,6 +63,7 @@ import TyCon
import VarSet
import PrelNames
import Outputable
import Util
\end{code}
%************************************************************************
......
......@@ -26,6 +26,7 @@ import Outputable
import Pair
import Maybes( allMaybes )
import FastString
import Util
\end{code}
%************************************************************************
......
......@@ -71,6 +71,7 @@ import Outputable
import FastString
import Pair
import StaticFlags( opt_PprStyle_Debug )
import Util
-- libraries
import qualified Data.Data as Data hiding ( TyCon )
......
......@@ -78,7 +78,7 @@ import FastString
import FastTypes
import Platform
import qualified Pretty
import Util ( snocView )
import Util
import Pretty ( Doc, Mode(..) )
import Panic
......@@ -936,6 +936,7 @@ pprPanicFastInt heading pretty_msg =
warnPprTrace :: Bool -> String -> Int -> SDoc -> a -> a
-- ^ Just warn about an assertion failure, recording the given file and line number.
-- Should typically be accessed with the WARN macros
warnPprTrace _ _ _ _ x | not debugIsOn = x
warnPprTrace _ _file _line _msg x | opt_NoDebugOutput = x
warnPprTrace False _file _line _msg x = x
warnPprTrace True file line msg x
......
......@@ -49,6 +49,7 @@ import Data.Maybe
import Data.List
import TcRnMonad (doptM)
import DynFlags (DynFlag(Opt_AvoidVect))
import Util
-- Main entry point to vectorise expressions -----------------------------------
......
......@@ -14,6 +14,7 @@ import Class
import Type
import TyCon
import Outputable
import Util
#include "HsVersions.h"
......
......@@ -50,8 +50,7 @@ import Maybes ( orElse, expectJust )
import NameSet
import Panic hiding ( showException )
import StaticFlags
import Util ( on, global, toArgs, toCmdArgs, removeSpaces, getCmd,
filterOut, seqList, looksLikeModuleName, partitionWith )
import Util
-- Haskell Libraries
import System.Console.Haskeline as Haskeline
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment