[project @ 1998-01-08 18:03:08 by simonm]
[ghc-hetmet.git] / ghc / compiler / codeGen / SMRep.lhs
index 4adcfd7..4f106b3 100644 (file)
@@ -7,18 +7,19 @@ This is here, rather than in ClosureInfo, just to keep nhc happy.
 Other modules should access this info through ClosureInfo.
 
 \begin{code}
-#include "HsVersions.h"
-
 module SMRep (
        SMRep(..), SMSpecRepKind(..), SMUpdateKind(..),
        getSMInfoStr, getSMInitHdrStr, getSMUpdInplaceHdrStr,
-       ltSMRepHdr
+       ltSMRepHdr,
+       isConstantRep, isSpecRep, isStaticRep, isPhantomRep,
+       isIntLikeRep
     ) where
 
-import Ubiq{-uitous-}
+#include "HsVersions.h"
 
-import Pretty          ( ppStr )
+import Outputable
 import Util            ( panic )
+import GlaExts         ( Int(..), Int#, (<#), (==#), (<#), (>#) )
 \end{code}
 
 %************************************************************************
@@ -129,7 +130,27 @@ MuTupleRep == MUTUPLE
 
 --jim
 -}
+\end{code}
+
+\begin{code}
+isConstantRep, isSpecRep, isStaticRep, isPhantomRep, isIntLikeRep :: SMRep -> Bool
+isConstantRep (SpecialisedRep ConstantRep _ _ _)   = True
+isConstantRep other                               = False
 
+isSpecRep (SpecialisedRep kind _ _ _)  = True    -- All the kinds of Spec closures
+isSpecRep other                                = False   -- True indicates that the _VHS is 0 !
+
+isStaticRep (StaticRep _ _) = True
+isStaticRep _              = False
+
+isPhantomRep PhantomRep        = True
+isPhantomRep _         = False
+
+isIntLikeRep (SpecialisedRep IntLikeRep _ _ _)   = True
+isIntLikeRep other                              = False
+\end{code}
+
+\begin{code}
 instance Eq SMRep where
     (SpecialisedRep k1 a1 b1 _) == (SpecialisedRep k2 a2 b2 _) = (tagOf_SMSpecRepKind k1) _EQ_ (tagOf_SMSpecRepKind k2)
                                                               && a1 == a2 && b1 == b2
@@ -196,7 +217,7 @@ instance Text SMRep where
           MuTupleRep _                          -> "MUTUPLE")
 
 instance Outputable SMRep where
-    ppr sty rep = ppStr (show rep)
+    ppr rep = text (show rep)
 
 getSMInfoStr :: SMRep -> String
 getSMInfoStr (StaticRep _ _)                           = "STATIC"