X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=blobdiff_plain;f=compiler%2FbasicTypes%2FLiteral.lhs;h=c6782f0ad9430ab197cc933ab19f0290f79c3690;hp=f05d1bf3b9661a86719042d0044a54bd64d4f3ad;hb=6a05ec5ef5373f61b7f9f5bdc344483417fa801b;hpb=49c98d143c382a1341e1046f5ca00819a25691ba diff --git a/compiler/basicTypes/Literal.lhs b/compiler/basicTypes/Literal.lhs index f05d1bf..c6782f0 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 @@ -34,7 +42,6 @@ import FastTypes import FastString import Binary import Ratio -import FastString import Data.Int import Data.Word @@ -285,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)