From 6b28dc921d5ebadb851d9b53ab6fd637c744e186 Mon Sep 17 00:00:00 2001 From: simonm Date: Mon, 23 Feb 1998 13:01:53 +0000 Subject: [PATCH] [project @ 1998-02-23 13:01:32 by simonm] 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 | 7 +++---- ghc/compiler/codeGen/CgConTbls.lhs | 1 - ghc/compiler/codeGen/ClosureInfo.lhs | 8 +++----- ghc/compiler/prelude/PrelInfo.lhs | 7 ++++--- 4 files changed, 10 insertions(+), 13 deletions(-) diff --git a/ghc/compiler/codeGen/CgCon.lhs b/ghc/compiler/codeGen/CgCon.lhs index 305b7ea..bfabcf7 100644 --- a/ghc/compiler/codeGen/CgCon.lhs +++ b/ghc/compiler/codeGen/CgCon.lhs @@ -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 diff --git a/ghc/compiler/codeGen/CgConTbls.lhs b/ghc/compiler/codeGen/CgConTbls.lhs index a803226..801ad82 100644 --- a/ghc/compiler/codeGen/CgConTbls.lhs +++ b/ghc/compiler/codeGen/CgConTbls.lhs @@ -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 ) diff --git a/ghc/compiler/codeGen/ClosureInfo.lhs b/ghc/compiler/codeGen/ClosureInfo.lhs index 91200a0..db6a9da 100644 --- a/ghc/compiler/codeGen/ClosureInfo.lhs +++ b/ghc/compiler/codeGen/ClosureInfo.lhs @@ -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 diff --git a/ghc/compiler/prelude/PrelInfo.lhs b/ghc/compiler/prelude/PrelInfo.lhs index de1a41e..c289fe3 100644 --- a/ghc/compiler/prelude/PrelInfo.lhs +++ b/ghc/compiler/prelude/PrelInfo.lhs @@ -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} %************************************************************************ -- 1.7.10.4