[project @ 2001-02-20 15:36:55 by simonpj]
[ghc-hetmet.git] / ghc / compiler / basicTypes / Id.lhs
index 57edb62..13443a9 100644 (file)
@@ -22,14 +22,12 @@ module Id (
        zapFragileIdInfo, zapLamIdInfo,
 
        -- Predicates
-       omitIfaceSigForId, isDeadBinder,
-       exportWithOrigOccName,
+       isImplicitId, isDeadBinder,
        externallyVisibleId,
-       isIP,
        isSpecPragmaId, isRecordSelector,
-       isPrimOpId, isPrimOpId_maybe, 
-       isDataConId, isDataConId_maybe, isDataConWrapId, 
-               isDataConWrapId_maybe,
+       isPrimOpId, isPrimOpId_maybe, isDictFunId,
+       isDataConId, isDataConId_maybe, 
+       isDataConWrapId, isDataConWrapId_maybe,
        isBottomingId,
        isExportedId, isLocalId, 
        hasNoBinding,
@@ -89,8 +87,7 @@ import IdInfo
 import Demand          ( Demand )
 import Name            ( Name, OccName,
                          mkSysLocalName, mkLocalName,
-                         nameIsLocallyDefined,
-                         getOccName, isIPOcc
+                         getOccName
                        ) 
 import OccName         ( UserFS )
 import PrimRep         ( PrimRep )
@@ -162,6 +159,7 @@ mkTemplateLocals tys = zipWith (mkSysLocal SLIT("tpl"))
                               tys
 
 mkTemplateLocalsNum :: Int -> [Type] -> [Id]
+-- The Int gives the starting point for unique allocation
 mkTemplateLocalsNum n tys = zipWith (mkSysLocal SLIT("tpl"))
                               (getNumBuiltinUniques n (length tys))
                               tys
@@ -245,6 +243,10 @@ hasNoBinding id = case idFlavour id of
        -- binding, even though it is defined in this module.  Notably,
        -- the constructors of a dictionary are in this situation.
 
+isDictFunId id = case idFlavour id of
+                  DictFunId -> True
+                  other     -> False
+
 -- Don't drop a binding for an exported Id,
 -- if it otherwise looks dead.  
 -- Perhaps a better name would be isDiscardableId
@@ -257,30 +259,26 @@ isLocalId :: Id -> Bool
 -- True of Ids that are locally defined, but are not constants
 -- like data constructors, record selectors, and the like. 
 -- See comments with CoreFVs.isLocalVar
-isLocalId id = case idFlavour id of
-                VanillaId    -> True
-                ExportedId   -> True
-                SpecPragmaId -> True
-                other        -> False
+isLocalId id 
+#ifdef DEBUG
+  | not (isId id) = pprTrace "isLocalid" (ppr id) False
+  | otherwise
+#endif
+  = case idFlavour id of
+        VanillaId    -> True
+        ExportedId   -> True
+        SpecPragmaId -> True
+        other        -> False
 \end{code}
 
 
-omitIfaceSigForId tells whether an Id's info is implied by other declarations,
-so we don't need to put its signature in an interface file, even if it's mentioned
-in some other interface unfolding.
+isImplicitId tells whether an Id's info is implied by other
+declarations, so we don't need to put its signature in an interface
+file, even if it's mentioned in some other interface unfolding.
 
 \begin{code}
-omitIfaceSigForId :: Id -> Bool
-omitIfaceSigForId id
-  = ASSERT2( not (omit && nameIsLocallyDefined (idName id)
-                       && idTyGenInfo id /= TyGenNever),
-             ppr id )
-    -- mustn't omit type signature for a name whose type might change!
-    omit
-  where
-    omit = omitIfaceSigForId' id
-
-omitIfaceSigForId' id
+isImplicitId :: Id -> Bool
+isImplicitId id
   = case idFlavour id of
        RecordSelId _   -> True -- Includes dictionary selectors
         PrimOpId _      -> True
@@ -290,22 +288,13 @@ omitIfaceSigForId' id
                -- remember that all type and class decls appear in the interface file.
                -- The dfun id must *not* be omitted, because it carries version info for
                -- the instance decl
-
-       other          -> False -- Don't omit!
-
--- Certain names must be exported with their original occ names, because
--- these names are bound by either a class declaration or a data declaration
--- or an explicit user export.
-exportWithOrigOccName :: Id -> Bool
-exportWithOrigOccName id = omitIfaceSigForId id || isExportedId id
+       other           -> False
 \end{code}
 
 \begin{code}
 isDeadBinder :: Id -> Bool
 isDeadBinder bndr | isId bndr = isDeadOcc (idOccInfo bndr)
                  | otherwise = False   -- TyVars count as not dead
-
-isIP id = isIPOcc (getOccName id)
 \end{code}