X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=blobdiff_plain;f=compiler%2FbasicTypes%2FLiteral.lhs;h=da8685e6b3f094ae51d141b6dbd787b9cba0b35a;hp=a03e1c14e03e539a5640cddbb6aba28bd4429a79;hb=c1c2c25355bc462e521b2c5fb41ac79307da22ff;hpb=f278f0676579f67075033a4f9857715909c4b71e diff --git a/compiler/basicTypes/Literal.lhs b/compiler/basicTypes/Literal.lhs index a03e1c1..da8685e 100644 --- a/compiler/basicTypes/Literal.lhs +++ b/compiler/basicTypes/Literal.lhs @@ -27,6 +27,7 @@ module Literal -- ** Operations on Literals , literalType , hashLiteral + , absentLiteralOf -- ** Predicates on Literals and their contents , litIsDupable, litIsTrivial @@ -44,19 +45,21 @@ module Literal ) where import TysPrim +import PrelNames import Type +import TyCon import Outputable import FastTypes import FastString import BasicTypes import Binary import Constants - +import UniqFM import Data.Int import Data.Ratio import Data.Word import Data.Char -import Data.Data +import Data.Data( Data, Typeable ) \end{code} @@ -326,6 +329,21 @@ literalType (MachWord64 _) = word64PrimTy literalType (MachFloat _) = floatPrimTy literalType (MachDouble _) = doublePrimTy literalType (MachLabel _ _ _) = addrPrimTy + +absentLiteralOf :: TyCon -> Maybe Literal +-- Return a literal of the appropriate primtive +-- TyCon, to use as a placeholder when it doesn't matter +absentLiteralOf tc = lookupUFM absent_lits (tyConName tc) + +absent_lits :: UniqFM Literal +absent_lits = listToUFM [ (addrPrimTyConKey, MachNullAddr) + , (charPrimTyConKey, MachChar 'x') + , (intPrimTyConKey, MachInt 0) + , (int64PrimTyConKey, MachInt64 0) + , (floatPrimTyConKey, MachFloat 0) + , (doublePrimTyConKey, MachDouble 0) + , (wordPrimTyConKey, MachWord 0) + , (word64PrimTyConKey, MachWord64 0) ] \end{code}