X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2FbasicTypes%2FLiteral.lhs;h=ec1d7c473ba116c2654da7783484916beaf5802f;hb=f3399c446c7507d46d6cc550aa2fe7027dbc1b5b;hp=598b5a49170fcb58b6a54046e15c6633444907fb;hpb=c916244fe9246b4f9d88a9b1c7c9ee8c55b15696;p=ghc-hetmet.git diff --git a/compiler/basicTypes/Literal.lhs b/compiler/basicTypes/Literal.lhs index 598b5a4..ec1d7c4 100644 --- a/compiler/basicTypes/Literal.lhs +++ b/compiler/basicTypes/Literal.lhs @@ -5,6 +5,13 @@ \section[Literal]{@Literal@: Machine literals (unboxed, of course)} \begin{code} +{-# OPTIONS -w #-} +-- The above warning supression flag is a temporary kludge. +-- While working on this module you are encouraged to remove it and fix +-- any warnings in the module. See +-- http://hackage.haskell.org/trac/ghc/wiki/Commentary/CodingStyle#Warnings +-- for details + module Literal ( Literal(..) -- Exported to ParseIface , mkMachInt, mkMachWord @@ -16,6 +23,7 @@ module Literal , inIntRange, inWordRange, tARGET_MAX_INT, inCharRange , isZeroLit + , litFitsInChar , word2IntLit, int2WordLit , narrow8IntLit, narrow16IntLit, narrow32IntLit @@ -54,7 +62,7 @@ respectively (which will be wrong on a 64-bit machine). \begin{code} tARGET_MIN_INT, tARGET_MAX_INT, tARGET_MAX_WORD :: Integer -#if __GLASGOW_HASKELL__ +#ifdef __GLASGOW_HASKELL__ tARGET_MIN_INT = toInteger (minBound :: Int) tARGET_MAX_INT = toInteger (maxBound :: Int) #else @@ -284,6 +292,12 @@ litIsDupable :: Literal -> Bool litIsDupable (MachStr _) = False litIsDupable other = True +litFitsInChar :: Literal -> Bool +litFitsInChar (MachInt i) + = fromInteger i <= ord minBound + && fromInteger i >= ord maxBound +litFitsInChar _ = False + litSize :: Literal -> Int -- Used by CoreUnfold.sizeExpr litSize (MachStr str) = 1 + ((lengthFS str + 3) `div` 4)