X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2FbasicTypes%2FLiteral.lhs;h=a03e1c14e03e539a5640cddbb6aba28bd4429a79;hb=a51fe79ebcdcb8285573a18f12cade2101533419;hp=f2ea137567308255cbf26c2c382cce0c5ec2396c;hpb=497302c44ad08c6c27d0e15d94a787f332c0cfec;p=ghc-hetmet.git diff --git a/compiler/basicTypes/Literal.lhs b/compiler/basicTypes/Literal.lhs index f2ea137..a03e1c1 100644 --- a/compiler/basicTypes/Literal.lhs +++ b/compiler/basicTypes/Literal.lhs @@ -11,6 +11,7 @@ -- any warnings in the module. See -- http://hackage.haskell.org/trac/ghc/wiki/Commentary/CodingStyle#Warnings -- for details +{-# LANGUAGE DeriveDataTypeable #-} module Literal ( @@ -24,7 +25,6 @@ module Literal , mkMachChar, mkMachString -- ** Operations on Literals - , litSize , literalType , hashLiteral @@ -50,42 +50,18 @@ import FastTypes import FastString import BasicTypes import Binary -import Ratio +import Constants import Data.Int +import Data.Ratio import Data.Word import Data.Char +import Data.Data \end{code} %************************************************************************ %* * -\subsection{Sizes} -%* * -%************************************************************************ - -If we're compiling with GHC (and we're not cross-compiling), then we -know that minBound and maxBound :: Int are the right values for the -target architecture. Otherwise, we assume -2^31 and 2^31-1 -respectively (which will be wrong on a 64-bit machine). - -\begin{code} -tARGET_MIN_INT, tARGET_MAX_INT, tARGET_MAX_WORD :: Integer -#ifdef __GLASGOW_HASKELL__ -tARGET_MIN_INT = toInteger (minBound :: Int) -tARGET_MAX_INT = toInteger (maxBound :: Int) -#else -tARGET_MIN_INT = -2147483648 -tARGET_MAX_INT = 2147483647 -#endif -tARGET_MAX_WORD = (tARGET_MAX_INT * 2) + 1 - -tARGET_MAX_CHAR :: Int -tARGET_MAX_CHAR = 0x10ffff -\end{code} - -%************************************************************************ -%* * \subsection{Literals} %* * %************************************************************************ @@ -132,6 +108,7 @@ data Literal -- the label expects. Only applicable with -- @stdcall@ labels. @Just x@ => @\@ will -- be appended to label name when emitting assembly. + deriving (Data, Typeable) \end{code} Binary instance @@ -332,15 +309,6 @@ litFitsInChar (MachInt i) = fromInteger i <= ord minBound && fromInteger i >= ord maxBound litFitsInChar _ = False - --- | Finds a nominal size of a string literal. Every literal has size at least 1 -litSize :: Literal -> Int --- Used by CoreUnfold.sizeExpr -litSize (MachStr str) = 1 + ((lengthFS str + 3) `div` 4) - -- If size could be 0 then @f "x"@ might be too small - -- [Sept03: make literal strings a bit bigger to avoid fruitless - -- duplication of little strings] -litSize _other = 1 \end{code} Types