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); \ ...@@ -46,18 +46,9 @@ name :: IORef (ty); \
name = Util.globalM (value); name = Util.globalM (value);
#endif #endif
#ifdef DEBUG #define ASSERT(e) if debugIsOn && not (e) then (assertPanic __FILE__ __LINE__) else
#define ASSERT(e) if (not (e)) then (assertPanic __FILE__ __LINE__) else #define ASSERT2(e,msg) if debugIsOn && not (e) then (assertPprPanic __FILE__ __LINE__ (msg)) else
#define ASSERT2(e,msg) if (not (e)) then (assertPprPanic __FILE__ __LINE__ (msg)) else
#define WARN( e, msg ) (warnPprTrace (e) __FILE__ __LINE__ (msg)) $ #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 -- Examples: Assuming flagSet :: String -> m Bool
-- --
......
...@@ -126,7 +126,7 @@ import Outputable ...@@ -126,7 +126,7 @@ import Outputable
import Unique import Unique
import UniqSupply import UniqSupply
import FastString import FastString
import Util( count ) import Util
import StaticFlags import StaticFlags
-- infixl so you can say (id `set` a `set` b) -- infixl so you can say (id `set` a `set` b)
......
...@@ -62,6 +62,8 @@ import BasicTypes ...@@ -62,6 +62,8 @@ import BasicTypes
import Binary import Binary
import Constants import Constants
import UniqFM import UniqFM
import Util
import Data.Int import Data.Int
import Data.Ratio import Data.Ratio
import Data.Word import Data.Word
......
...@@ -71,6 +71,7 @@ import FastTypes ...@@ -71,6 +71,7 @@ import FastTypes
import FastString import FastString
import Outputable import Outputable
-- import StaticFlags -- import StaticFlags
import Util
#if defined(__GLASGOW_HASKELL__) #if defined(__GLASGOW_HASKELL__)
--just for implementing a fast [0,61) -> Char function --just for implementing a fast [0,61) -> Char function
......
...@@ -32,7 +32,7 @@ import Constants ...@@ -32,7 +32,7 @@ import Constants
import Digraph import Digraph
import qualified Prelude as P import qualified Prelude as P
import Prelude hiding (succ) import Prelude hiding (succ)
import Util (sortLe) import Util
import BlockId import BlockId
import Bitmap import Bitmap
......
...@@ -27,6 +27,8 @@ import Platform ...@@ -27,6 +27,8 @@ import Platform
import StaticFlags import StaticFlags
import UniqSupply import UniqSupply
import MonadUtils import MonadUtils
import Util
import Data.Bits import Data.Bits
import Data.Word import Data.Word
......
...@@ -83,6 +83,7 @@ import OptimizationFuel as F ...@@ -83,6 +83,7 @@ import OptimizationFuel as F
import Unique import Unique
import UniqSupply import UniqSupply
import Constants( wORD_SIZE, tAG_MASK ) import Constants( wORD_SIZE, tAG_MASK )
import Util
import Data.Word import Data.Word
import Data.Maybe import Data.Maybe
......
...@@ -42,6 +42,7 @@ import SMRep (ByteOff) ...@@ -42,6 +42,7 @@ import SMRep (ByteOff)
import StaticFlags import StaticFlags
import Unique import Unique
import UniqSupply import UniqSupply
import Util
#include "HsVersions.h" #include "HsVersions.h"
......
...@@ -22,6 +22,7 @@ import Control.Monad ...@@ -22,6 +22,7 @@ import Control.Monad
import StaticFlags (opt_Fuel) import StaticFlags (opt_Fuel)
import UniqSupply import UniqSupply
import Panic import Panic
import Util
import Compiler.Hoopl import Compiler.Hoopl
import Compiler.Hoopl.GHC (getFuel, setFuel) import Compiler.Hoopl.GHC (getFuel, setFuel)
......
...@@ -77,6 +77,7 @@ import VarEnv ...@@ -77,6 +77,7 @@ import VarEnv
import OrdList import OrdList
import Unique import Unique
import UniqSupply import UniqSupply
import Util
import Outputable import Outputable
import Control.Monad import Control.Monad
......
...@@ -43,6 +43,7 @@ import StgSyn ...@@ -43,6 +43,7 @@ import StgSyn
import PrimOp import PrimOp
import Outputable import Outputable
import StaticFlags import StaticFlags
import Util
import Control.Monad import Control.Monad
import Data.Maybe import Data.Maybe
......
...@@ -96,6 +96,7 @@ import Outputable ...@@ -96,6 +96,7 @@ import Outputable
import FastString import FastString
import Constants import Constants
import DynFlags import DynFlags
import Util
\end{code} \end{code}
......
...@@ -45,6 +45,7 @@ import TyCon ...@@ -45,6 +45,7 @@ import TyCon
import Module import Module
import ErrUtils import ErrUtils
import Panic import Panic
import Util
codeGen :: DynFlags codeGen :: DynFlags
-> Module -- Module we are compiling -> Module -- Module we are compiling
......
...@@ -46,6 +46,7 @@ import TyCon ...@@ -46,6 +46,7 @@ import TyCon
import Module import Module
import ErrUtils import ErrUtils
import Outputable import Outputable
import Util
codeGen :: DynFlags codeGen :: DynFlags
-> Module -> Module
......
...@@ -90,6 +90,7 @@ import Outputable ...@@ -90,6 +90,7 @@ import Outputable
import Platform import Platform
import Constants import Constants
import DynFlags import DynFlags
import Util
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
-- Representations -- Representations
......
...@@ -41,7 +41,7 @@ import PrelInfo ...@@ -41,7 +41,7 @@ import PrelInfo
import Outputable import Outputable
import Platform import Platform
import StaticFlags import StaticFlags
import Util ( lengthIs ) import Util
import Control.Monad import Control.Monad
import Data.Char import Data.Char
......
...@@ -44,6 +44,7 @@ import Module ...@@ -44,6 +44,7 @@ import Module
import FastString( mkFastString, fsLit ) import FastString( mkFastString, fsLit )
import Constants import Constants
import DynFlags import DynFlags
import Util
----------------------------------------------------------- -----------------------------------------------------------
-- Initialise dynamic heap objects -- Initialise dynamic heap objects
......
...@@ -43,6 +43,7 @@ import Module ...@@ -43,6 +43,7 @@ import Module
import FastString import FastString
import Outputable import Outputable
import StaticFlags import StaticFlags
import Util
------------------------------------------------------------------------ ------------------------------------------------------------------------
-- Primitive operations and foreign calls -- Primitive operations and foreign calls
......
...@@ -85,7 +85,7 @@ import Outputable ...@@ -85,7 +85,7 @@ import Outputable
import FastString import FastString
import UniqSupply import UniqSupply
import BasicTypes import BasicTypes
import Util ( notNull, zipEqual, sortLe ) import Util
import Pair import Pair
import Constants import Constants
......
...@@ -49,6 +49,7 @@ import PrelNames ...@@ -49,6 +49,7 @@ import PrelNames
import VarSet import VarSet
import Constants import Constants
import Outputable import Outputable
import Util
\end{code} \end{code}
Desugaring of @ccall@s consists of adding some state manipulation, Desugaring of @ccall@s consists of adding some state manipulation,
......
...@@ -47,6 +47,8 @@ import Config ...@@ -47,6 +47,8 @@ import Config
import Constants import Constants
import OrdList import OrdList
import Pair import Pair
import Util
import Data.Maybe import Data.Maybe
import Data.List import Data.List
\end{code} \end{code}
......
...@@ -33,6 +33,7 @@ import SrcLoc ...@@ -33,6 +33,7 @@ import SrcLoc
import Outputable import Outputable
import FastString import FastString
import TcType import TcType
import Util
\end{code} \end{code}
List comprehensions may be desugared in one of two ways: ``ordinary'' List comprehensions may be desugared in one of two ways: ``ordinary''
......
...@@ -65,7 +65,7 @@ import Bag ...@@ -65,7 +65,7 @@ import Bag
import FastString import FastString
import ForeignCall import ForeignCall
import MonadUtils import MonadUtils
import Util( equalLength, filterOut ) import Util
import Data.Maybe import Data.Maybe
import Control.Monad import Control.Monad
......
...@@ -26,7 +26,7 @@ import TcType ...@@ -26,7 +26,7 @@ import TcType
import DsMonad import DsMonad
import DsUtils import DsUtils
import MkCore ( mkCoreLets ) import MkCore ( mkCoreLets )
import Util ( all2, takeList, zipEqual ) import Util
import ListSetOps ( runs ) import ListSetOps ( runs )
import Id import Id
import NameEnv import NameEnv
......
...@@ -34,6 +34,7 @@ import ClosureInfo -- CgRep stuff ...@@ -34,6 +34,7 @@ import ClosureInfo -- CgRep stuff
import DynFlags import DynFlags
import Outputable import Outputable
import Platform import Platform
import Util
import Control.Monad import Control.Monad
import Control.Monad.ST ( runST ) import Control.Monad.ST ( runST )
......
...@@ -27,6 +27,7 @@ import Module ...@@ -27,6 +27,7 @@ import Module
import FastString import FastString
import Panic import Panic
import Outputable import Outputable
import Util
-- Standard libraries -- Standard libraries
......
...@@ -32,7 +32,7 @@ import Name ...@@ -32,7 +32,7 @@ import Name
import BasicTypes import BasicTypes
import DataCon import DataCon
import SrcLoc import SrcLoc
import Util( dropTail ) import Util
import StaticFlags( opt_PprStyle_Debug ) import StaticFlags( opt_PprStyle_Debug )
import Outputable import Outputable
import FastString import FastString
......
...@@ -51,6 +51,7 @@ import Outputable ...@@ -51,6 +51,7 @@ import Outputable
import Platform import Platform
import FastString import FastString
import Constants import Constants
import Util
import Data.Bits import Data.Bits
import Data.Char import Data.Char
......
...@@ -38,7 +38,7 @@ import Type ...@@ -38,7 +38,7 @@ import Type
import Coercion import Coercion
import TcRnMonad import TcRnMonad
import Util ( isSingleton ) import Util
import Outputable import Outputable
\end{code} \end{code}
......
...@@ -41,6 +41,7 @@ import FastString ...@@ -41,6 +41,7 @@ import FastString
import UniqSupply import UniqSupply
import SrcLoc import SrcLoc
import BasicTypes import BasicTypes
import Util
import Outputable import Outputable
import Exception ( evaluate ) import Exception ( evaluate )
......
...@@ -147,6 +147,7 @@ import UniqFM ( emptyUFM ) ...@@ -147,6 +147,7 @@ import UniqFM ( emptyUFM )
import UniqSupply ( initUs_ ) import UniqSupply ( initUs_ )
import Bag import Bag
import Exception import Exception
import Util
import Data.List import Data.List
import Control.Monad import Control.Monad
......
...@@ -57,6 +57,7 @@ import Data.Word ...@@ -57,6 +57,7 @@ import Data.Word
import BasicTypes import BasicTypes
import FastString import FastString
import Util
-- ----------------------------------------------------------------------------- -- -----------------------------------------------------------------------------
-- Top-level of the instruction selector -- Top-level of the instruction selector
......
...@@ -54,6 +54,7 @@ import FastString ...@@ -54,6 +54,7 @@ import FastString
import FastBool ( isFastTrue ) import FastBool ( isFastTrue )
import Constants ( wORD_SIZE ) import Constants ( wORD_SIZE )
import DynFlags import DynFlags
import Util
import Control.Monad import Control.Monad
import Data.Bits import Data.Bits
......
...@@ -76,6 +76,8 @@ import Bag ( Bag, emptyBag, consBag ) ...@@ -76,6 +76,8 @@ import Bag ( Bag, emptyBag, consBag )
import Outputable import Outputable
import FastString import FastString
import Maybes import Maybes
import Util
import Control.Applicative ((<$>)) import Control.Applicative ((<$>))
import Control.Monad import Control.Monad
import Text.ParserCombinators.ReadP as ReadP import Text.ParserCombinators.ReadP as ReadP
......
...@@ -41,6 +41,7 @@ import FastString ...@@ -41,6 +41,7 @@ import FastString
import StaticFlags ( opt_SimplExcessPrecision ) import StaticFlags ( opt_SimplExcessPrecision )
import Constants import Constants
import BasicTypes import BasicTypes
import Util
import Data.Bits as Bits import Data.Bits as Bits
import Data.Int ( Int64 ) import Data.Int ( Int64 )
......
...@@ -104,6 +104,7 @@ import Data.Array ...@@ -104,6 +104,7 @@ import Data.Array
import FastString import FastString
import Outputable import Outputable
import Config import Config
import Util
alpha_tyvar :: [TyVar] alpha_tyvar :: [TyVar]
alpha_tyvar = [alphaTyVar] alpha_tyvar = [alphaTyVar]
......
...@@ -34,6 +34,7 @@ import Outputable ...@@ -34,6 +34,7 @@ import Outputable
import DynFlags import DynFlags
import FastString import FastString
import SrcLoc import SrcLoc
import Util
stgMassageForProfiling stgMassageForProfiling
......
...@@ -46,7 +46,7 @@ import RdrName ...@@ -46,7 +46,7 @@ import RdrName
import LoadIface ( loadInterfaceForName ) import LoadIface ( loadInterfaceForName )
import UniqSet import UniqSet
import Data.List import Data.List
import Util ( isSingleton, snocView ) import Util
import ListSetOps ( removeDups ) import ListSetOps ( removeDups )
import Outputable import Outputable
import SrcLoc import SrcLoc
......
...@@ -55,7 +55,7 @@ import Name ...@@ -55,7 +55,7 @@ import Name
import NameSet import NameSet
import RdrName import RdrName
import BasicTypes import BasicTypes
import Util ( notNull ) import Util
import ListSetOps ( removeDups ) import ListSetOps ( removeDups )
import Outputable import Outputable
import SrcLoc import SrcLoc
......
...@@ -49,7 +49,7 @@ import Name ...@@ -49,7 +49,7 @@ import Name
import SrcLoc import SrcLoc
import NameSet import NameSet
import Util ( filterOut ) import Util
import BasicTypes ( IPName(..), ipNameName, compareFixity, funTyFixity, negateFixity, import BasicTypes ( IPName(..), ipNameName, compareFixity, funTyFixity, negateFixity,
Fixity(..), FixityDirection(..) ) Fixity(..), FixityDirection(..) )
import Outputable import Outputable
......
...@@ -31,7 +31,7 @@ import Id ( isOneShotBndr, idType ) ...@@ -31,7 +31,7 @@ import Id ( isOneShotBndr, idType )
import Var import Var
import Type ( isUnLiftedType ) import Type ( isUnLiftedType )
import VarSet import VarSet
import Util ( zipEqual, zipWithEqual, count ) import Util
import UniqFM import UniqFM
import Outputable import Outputable
\end{code} \end{code}
......
...@@ -44,7 +44,7 @@ import Digraph ( SCC(..), stronglyConnCompFromEdgedVerticesR ) ...@@ -44,7 +44,7 @@ import Digraph ( SCC(..), stronglyConnCompFromEdgedVerticesR )
import PrelNames ( buildIdKey, foldrIdKey, runSTRepIdKey, augmentIdKey ) import PrelNames ( buildIdKey, foldrIdKey, runSTRepIdKey, augmentIdKey )
import Unique import Unique
import UniqFM import UniqFM
import Util ( mapAndUnzip, filterOut, fstOf3 ) import Util
import Bag import Bag
import Outputable import Outputable
import FastString import FastString
......
...@@ -63,6 +63,7 @@ import BasicTypes ...@@ -63,6 +63,7 @@ import BasicTypes
import MonadUtils import MonadUtils
import Outputable import Outputable
import FastString import FastString
import Util
import Data.List import Data.List
\end{code} \end{code}
......
...@@ -49,6 +49,7 @@ import Data.List ( mapAccumL ) ...@@ -49,6 +49,7 @@ import Data.List ( mapAccumL )
import Outputable import Outputable
import FastString import FastString
import Pair import Pair
import Util
\end{code} \end{code}
......
...@@ -67,6 +67,7 @@ import Type ( Type ) ...@@ -67,6 +67,7 @@ import Type ( Type )
import Type ( typePrimRep ) import Type ( typePrimRep )
import UniqSet import UniqSet
import Unique ( Unique ) import Unique ( Unique )
import Util
import VarSet ( IdSet, isEmptyVarSet ) import VarSet ( IdSet, isEmptyVarSet )
\end{code} \end{code}
......
...@@ -44,7 +44,7 @@ import UniqFM ( addToUFM_Directly, lookupUFM_Directly, ...@@ -44,7 +44,7 @@ import UniqFM ( addToUFM_Directly, lookupUFM_Directly,
minusUFM, filterUFM ) minusUFM, filterUFM )
import Type ( isUnLiftedType, eqType, tyConAppTyCon_maybe ) import Type ( isUnLiftedType, eqType, tyConAppTyCon_maybe )
import Coercion ( coercionKind ) import Coercion ( coercionKind )
import Util ( mapAndUnzip, lengthIs, zipEqual ) import Util
import BasicTypes ( Arity, TopLevelFlag(..), isTopLevel, isNeverActive, import BasicTypes ( Arity, TopLevelFlag(..), isTopLevel, isNeverActive,
RecFlag(..), isRec, isMarkedStrict ) RecFlag(..), isRec, isMarkedStrict )
import Maybes ( orElse, expectJust ) import Maybes ( orElse, expectJust )
......
...@@ -27,7 +27,7 @@ import BasicTypes ...@@ -27,7 +27,7 @@ import BasicTypes
import VarEnv ( isEmptyVarEnv ) import VarEnv ( isEmptyVarEnv )
import Maybes ( orElse ) import Maybes ( orElse )
import WwLib import WwLib
import Util ( lengthIs, notNull ) import Util
import Outputable import Outputable
import MonadUtils import MonadUtils
......
...@@ -28,7 +28,7 @@ import Outputable ...@@ -28,7 +28,7 @@ import Outputable
import UniqFM import UniqFM
import VarSet import VarSet
import FastString import FastString
import Util( filterOut, sortWith ) import Util
import Maybes import Maybes
import Control.Monad import Control.Monad
import Data.Map (Map) import Data.Map (Map)
......
...@@ -36,7 +36,7 @@ import VarSet ...@@ -36,7 +36,7 @@ import VarSet
import TcSMonad import TcSMonad
import FastString import FastString
import Util ( equalLength ) import Util
import TysWiredIn ( eqTyCon ) import TysWiredIn ( eqTyCon )
......
...@@ -48,6 +48,7 @@ import Maybes ...@@ -48,6 +48,7 @@ import Maybes
import BasicTypes import BasicTypes
import Bag import Bag
import FastString import FastString
import Util
import Control.Monad import Control.Monad
\end{code} \end{code}
......
...@@ -81,6 +81,7 @@ import Outputable ...@@ -81,6 +81,7 @@ import Outputable
import Unique import Unique
import FastString import FastString
import ListSetOps import ListSetOps
import Util
\end{code} \end{code}
......
...@@ -48,6 +48,7 @@ import Platform ...@@ -48,6 +48,7 @@ import Platform
import SrcLoc import SrcLoc
import Bag import Bag
import FastString