[project @ 1998-02-23 13:01:32 by simonm]
authorsimonm <unknown>
Mon, 23 Feb 1998 13:01:53 +0000 (13:01 +0000)
committersimonm <unknown>
Mon, 23 Feb 1998 13:01:53 +0000 (13:01 +0000)
Fix CharLike and IntLike support:

- rename maybeCharLikeTyCon to maybeCharLikeCon
- rename maybeIntLikeTyCon  to maybeIntLikeCon

and make them return Bool instead of (Maybe TyCon).

ghc/compiler/codeGen/CgCon.lhs
ghc/compiler/codeGen/CgConTbls.lhs
ghc/compiler/codeGen/ClosureInfo.lhs
ghc/compiler/prelude/PrelInfo.lhs

index 305b7ea..bfabcf7 100644 (file)
@@ -47,7 +47,7 @@ import Id             ( idPrimRep, dataConTag, dataConTyCon,
                        )
 import Literal         ( Literal(..) )
 import Maybes          ( maybeToBool )
-import PrelInfo                ( maybeCharLikeTyCon, maybeIntLikeTyCon )
+import PrelInfo                ( maybeCharLikeCon, maybeIntLikeCon )
 import PrimRep         ( isFloatingRep, PrimRep(..) )
 import TyCon           ( TyCon{-instance Uniquable-} )
 import Util            ( isIn, zipWithEqual, panic, assertPanic )
@@ -292,16 +292,15 @@ Because of this, we use can safely return an addressing mode.
 \begin{code}
 buildDynCon binder cc con [arg_amode] all_zero_size_args@False
 
-  | maybeToBool (maybeCharLikeTyCon tycon)
+  | maybeCharLikeCon con
   = ASSERT(isDataCon con)
     absC (CAssign temp_amode (CCharLike arg_amode))    `thenC`
     returnFC temp_id_info
 
-  | maybeToBool (maybeIntLikeTyCon tycon) && in_range_int_lit arg_amode
+  | maybeIntLikeCon con && in_range_int_lit arg_amode
   = ASSERT(isDataCon con)
     returnFC (stableAmodeIdInfo binder (CIntLike arg_amode) (mkConLFInfo con))
   where
-    tycon = dataConTyCon con
     (temp_amode, temp_id_info) = newTempAmodeAndIdInfo binder (mkConLFInfo con)
 
     in_range_int_lit (CLit (MachInt val _)) = val <= mAX_INTLIKE && val >= mIN_INTLIKE
index a803226..801ad82 100644 (file)
@@ -39,7 +39,6 @@ import Id             ( dataConTag, dataConRawArgTys,
                          GenId{-instance NamedThing-}, Id
                        )
 import Name            ( getOccString )
-import PrelInfo                ( maybeIntLikeTyCon )
 import PrimRep         ( getPrimRepSize, PrimRep(..) )
 import TyCon           ( tyConDataCons, mkSpecTyCon, TyCon )
 import Type            ( typePrimRep, Type )
index 91200a0..db6a9da 100644 (file)
@@ -92,7 +92,7 @@ import IdInfo         ( ArityInfo(..) )
 import Maybes          ( maybeToBool )
 import Name            ( getOccString )
 import PprType         ( getTyDescription )
-import PrelInfo                ( maybeCharLikeTyCon, maybeIntLikeTyCon )
+import PrelInfo                ( maybeCharLikeCon, maybeIntLikeCon )
 import PrimRep         ( getPrimRepSize, separateByPtrFollowness, PrimRep )
 import SMRep           -- all of it
 import TyCon           ( TyCon, isNewTyCon )
@@ -642,11 +642,9 @@ chooseDynSMRep lf_info tot_wds ptr_wds
 
           (LFCon _ True) -> ConstantRep
 
-          (LFCon con _ ) -> if maybeToBool (maybeCharLikeTyCon tycon) then CharLikeRep
-                            else if maybeToBool (maybeIntLikeTyCon tycon) then IntLikeRep
+          (LFCon con _ ) -> if maybeCharLikeCon con then CharLikeRep
+                            else if maybeIntLikeCon con then IntLikeRep
                             else SpecRep
-                            where
-                            tycon = dataConTyCon con
 
           _              -> SpecRep
        in
index de1a41e..c289fe3 100644 (file)
@@ -9,7 +9,7 @@ module PrelInfo (
        builtinNames, derivingOccurrences,
        BuiltinNames,
 
-       maybeCharLikeTyCon, maybeIntLikeTyCon,
+       maybeCharLikeCon, maybeIntLikeCon,
 
        eq_RDR, ne_RDR, le_RDR, lt_RDR, ge_RDR, gt_RDR, max_RDR, min_RDR, 
        compare_RDR, minBound_RDR, maxBound_RDR, enumFrom_RDR, enumFromTo_RDR,
@@ -308,8 +308,9 @@ knownKeyNames
 ToDo: make it do the ``like'' part properly (as in 0.26 and before).
 
 \begin{code}
-maybeCharLikeTyCon tc = if (uniqueOf tc == charDataConKey) then Just charDataCon else Nothing
-maybeIntLikeTyCon  tc = if (uniqueOf tc == intDataConKey)  then Just intDataCon  else Nothing
+maybeCharLikeCon, maybeIntLikeCon :: Id -> Bool
+maybeCharLikeCon con = uniqueOf con == charDataConKey
+maybeIntLikeCon  con = uniqueOf con == intDataConKey
 \end{code}
 
 %************************************************************************