[project @ 1999-03-02 14:22:43 by sof]
[ghc-hetmet.git] / ghc / compiler / simplCore / SimplCore.lhs
index f345c08..420fc79 100644 (file)
@@ -44,18 +44,14 @@ import Name         ( mkLocalName, tidyOccName, tidyTopName, initTidyOccEnv, isExported
                        )
 import TyCon           ( TyCon, isDataTyCon )
 import PrimOp          ( PrimOp(..) )
-import PrelInfo                ( unpackCStringId, unpackCString2Id,
-                         integerZeroId, integerPlusOneId,
-                         integerPlusTwoId, integerMinusOneId,
-                         int2IntegerId, addr2IntegerId
-                       )
+import PrelInfo                ( unpackCStringId, unpackCString2Id, addr2IntegerId )
 import Type            ( Type, splitAlgTyConApp_maybe, 
-                         isUnLiftedType, mkTyVarTy, 
+                         isUnLiftedType,
                          tidyType, tidyTypes, tidyTopType, tidyTyVar, tidyTyVars,
                          Type
                        )
 import Class           ( Class, classSelIds )
-import TysWiredIn      ( isIntegerTy )
+import TysWiredIn      ( smallIntegerDataCon, isIntegerTy )
 import LiberateCase    ( liberateCase )
 import SAT             ( doStaticArgs )
 import Specialise      ( specProgram)
@@ -68,10 +64,13 @@ import Unique               ( Unique, Uniquable(..),
 import UniqSupply      ( UniqSupply, splitUniqSupply, uniqFromSupply )
 import Constants       ( tARGET_MIN_INT, tARGET_MAX_INT )
 import Util            ( mapAccumL )
+import SrcLoc          ( noSrcLoc )
 import Bag
 import Maybes
 import IO              ( hPutStr, stderr )
 import Outputable
+
+import Ratio           ( numerator, denominator )
 \end{code}
 
 \begin{code}
@@ -321,7 +320,8 @@ tidyNestedBndr env@(tidy_env, var_env) id
   =    -- Non-top-level variables
     let 
        -- Give the Id a fresh print-name, *and* rename its type
-       name'             = mkLocalName (getUnique id) occ'
+       -- The SrcLoc isn't important now, though we could extract it from the Id
+       name'             = mkLocalName (getUnique id) occ' noSrcLoc
        (tidy_env', occ') = tidyOccName tidy_env (getOccName id)
         ty'              = tidyType env (idType id)
        id'               = mkUserId name' ty'
@@ -364,7 +364,7 @@ tidyIdInfo env info
     info3 = noUnfolding `setUnfoldingInfo` info2
 
     tidy_item (tyvars, tys, rhs)
-       = (tyvars', tidyTypes env' tys, tidyExpr env rhs)
+       = (tyvars', tidyTypes env' tys, tidyExpr env' rhs)
        where
          (env', tyvars') = tidyTyVars env tyvars
 \end{code}
@@ -630,20 +630,15 @@ litToRep (NoRepStr s ty)
 
 If an Integer is small enough (Haskell implementations must support
 Ints in the range $[-2^29+1, 2^29-1]$), wrap it up in @int2Integer@;
-otherwise, wrap with @litString2Integer@.
+otherwise, wrap with @addr2Integer@.
 
 \begin{code}
 litToRep (NoRepInteger i integer_ty)
   = returnPM (integer_ty, rhs)
   where
-    rhs | i == 0    = Var integerZeroId                -- Extremely convenient to look out for
-       | i == 1    = Var integerPlusOneId      -- a few very common Integer literals!
-       | i == 2    = Var integerPlusTwoId
-       | i == (-1) = Var integerMinusOneId
-  
-       | i > tARGET_MIN_INT &&         -- Small enough, so start from an Int
+    rhs | i > tARGET_MIN_INT &&                -- Small enough, so start from an Int
          i < tARGET_MAX_INT
-       = App (Var int2IntegerId) (Con (Literal (mkMachInt i)) [])
+       = Con (DataCon smallIntegerDataCon) [Con (Literal (mkMachInt i)) []]
   
        | otherwise                     -- Big, so start from a string
        = App (Var addr2IntegerId) (Con (Literal (MachStr (_PK_ (show i)))) [])