-hashName name = IBOX( u2i (nameUnique name) )
-
-nameUnique name = n_uniq name
-nameOccName name = n_occ name
-
-nameModule name =
- case n_sort name of
- Local -> pprPanic "nameModule" (ppr name)
- x -> nameSortModule x
-
-nameSortModule (Global mod) = mod
-nameSortModule (WiredInId mod _) = mod
-nameSortModule (WiredInTyCon mod _) = mod
-
-nameRdrName :: Name -> RdrName
--- Makes a qualified name for top-level (Global) names, whether locally defined or not
--- and an unqualified name just for Locals
-nameRdrName (Name { n_sort = Local, n_occ = occ }) = mkRdrUnqual occ
-nameRdrName (Name { n_sort = sort, n_occ = occ }) = mkRdrQual (moduleName (nameSortModule sort)) occ
-
-ifaceNameRdrName :: Name -> RdrName
--- Makes a qualified naem for imported things,
--- and an unqualified one for local things
-ifaceNameRdrName n | isLocallyDefined n = mkRdrUnqual (nameOccName n)
- | otherwise = mkRdrQual (moduleName (nameModule n)) (nameOccName n)
-
-isUserExportedName (Name { n_prov = LocalDef _ Exported }) = True
-isUserExportedName other = False
-
-isUserImportedExplicitlyName (Name { n_prov = NonLocalDef (UserImport _ _ explicit) _ }) = explicit
-isUserImportedExplicitlyName other = False
-
-isUserImportedName (Name { n_prov = NonLocalDef (UserImport _ _ _) _ }) = True
-isUserImportedName other = False
-
-maybeUserImportedFrom (Name { n_prov = NonLocalDef (UserImport m _ _) _ }) = Just m
-maybeUserImportedFrom other = Nothing
-
-isDllName :: Name -> Bool
- -- Does this name refer to something in a different DLL?
-isDllName nm = not opt_Static &&
- not (isLocallyDefinedName nm) &&
--- isLocallyDefinedName test is needed because nameModule won't work on local names
- not (isLocalModule (nameModule nm))
-
-nameSrcLoc name = provSrcLoc (n_prov name)
-
-provSrcLoc (LocalDef loc _) = loc
-provSrcLoc (NonLocalDef (UserImport _ loc _) _) = loc
-provSrcLoc other = noSrcLoc
-
-isLocallyDefinedName (Name {n_sort = Local}) = True -- Local (might have SystemProv)
-isLocallyDefinedName (Name {n_prov = LocalDef _ _}) = True -- Global, but defined here
-isLocallyDefinedName other = False -- Other
-
--- Things the compiler "knows about" are in some sense
--- "imported". When we are compiling the module where
--- the entities are defined, we need to be able to pick
--- them out, often in combination with isLocallyDefined.
-isWiredInName (Name {n_sort = WiredInTyCon _ _}) = True
-isWiredInName (Name {n_sort = WiredInId _ _}) = True
-isWiredInName _ = False
-
-maybeWiredInIdName :: Name -> Maybe Id
-maybeWiredInIdName (Name {n_sort = WiredInId _ id}) = Just id
-maybeWiredInIdName other = Nothing
-
-maybeWiredInTyConName :: Name -> Maybe TyCon
-maybeWiredInTyConName (Name {n_sort = WiredInTyCon _ tc}) = Just tc
-maybeWiredInTyConName other = Nothing
-
-
-isLocalName (Name {n_sort = Local}) = True
-isLocalName _ = False
-
-isGlobalName (Name {n_sort = Local}) = False
-isGlobalName other = True
-
-isTyVarName :: Name -> Bool
-isTyVarName name = isTvOcc (nameOccName name)
-
--- Global names are by definition those that are visible
--- outside the module, *as seen by the linker*. Externally visible
--- does not mean visible at the source level (that's isExported).
-isExternallyVisibleName name = isGlobalName name
-
-hasBetterProv :: Name -> Name -> Bool
--- Choose
--- a local thing over an imported thing
--- a user-imported thing over a non-user-imported thing
--- an explicitly-imported thing over an implicitly imported thing
-hasBetterProv n1 n2
- = case (n_prov n1, n_prov n2) of
- (LocalDef _ _, _ ) -> True
- (NonLocalDef (UserImport _ _ True) _, _ ) -> True
- (NonLocalDef (UserImport _ _ _ ) _, NonLocalDef ImplicitImport _) -> True
- other -> False
-
-isSystemName (Name {n_prov = SystemProv}) = True
-isSystemName other = False