-\begin{code}
-nameUnique (Local u _ _ _) = u
-nameUnique (Global u _ _ _ _ _) = u
-
--- when we renumber/rename things, we need to be
--- able to change a Name's Unique to match the cached
--- one in the thing it's the name of. If you know what I mean.
-changeUnique (Local _ n b l) u = Local u n b l
-changeUnique (Global _ m n p e os) u = Global u m n p e os
-
-nameOrigName msg (Global _ m (Left n) _ _ _) = OrigName m n
-nameOrigName msg (Global _ m (Right n) _ _ _) = let str = _CONCAT_ (glue n) in
- pprTrace ("nameOrigName:"++msg) (ppPStr str) $
- OrigName m str
-#ifdef DEBUG
-nameOrigName msg (Local _ n _ _) = panic ("nameOrigName:Local:"++msg++":"++ _UNPK_ n)
-#endif
-
-nameOccName (Local _ n _ _) = Unqual n
-nameOccName (Global _ m (Left n) _ _ [] ) = Qual m n
-nameOccName (Global _ m (Right n) _ _ [] ) = let str = _CONCAT_ (glue n) in
- pprTrace "nameOccName:" (ppPStr str) $
- Qual m str
-nameOccName (Global _ m (Left _) _ _ (o:_)) = o
-nameOccName (Global _ m (Right _) _ _ (o:_)) = panic "nameOccName:compound name"
-
-nameExportFlag (Local _ _ _ _) = NotExported
-nameExportFlag (Global _ _ _ _ exp _) = exp
-
-nameSrcLoc (Local _ _ _ loc) = loc
-nameSrcLoc (Global _ _ _ (LocalDef loc) _ _) = loc
-nameSrcLoc (Global _ _ _ (Imported _ loc _) _ _) = loc
-nameSrcLoc (Global _ _ _ Implicit _ _) = mkUnknownSrcLoc
-nameSrcLoc (Global _ _ _ Primitive _ _) = mkBuiltinSrcLoc
-nameSrcLoc (Global _ _ _ (WiredIn _) _ _) = mkBuiltinSrcLoc
-
-nameImpLocs (Global _ _ _ (Imported _ _ locs) _ _) = locs
-nameImpLocs _ = []
-
-nameImportFlag (Local _ _ _ _) = NotExported
-nameImportFlag (Global _ _ _ (LocalDef _) _ _) = ExportAll
-nameImportFlag (Global _ _ _ (Imported exp _ _) _ _) = exp
-nameImportFlag (Global _ _ _ Implicit _ _) = ExportAll
-nameImportFlag (Global _ _ _ Primitive _ _) = ExportAll
-nameImportFlag (Global _ _ _ (WiredIn _) _ _) = ExportAll
-
-isLocallyDefinedName (Local _ _ _ _) = True
-isLocallyDefinedName (Global _ _ _ (LocalDef _) _ _) = True
-isLocallyDefinedName (Global _ _ _ (Imported _ _ _) _ _) = False
-isLocallyDefinedName (Global _ _ _ Implicit _ _) = False
-isLocallyDefinedName (Global _ _ _ Primitive _ _) = False
-isLocallyDefinedName (Global _ _ _ (WiredIn from_here) _ _) = from_here
-
-isWiredInName (Global _ _ _ (WiredIn _) _ _) = True
-isWiredInName _ = False
-\end{code}
-
-\begin{code}
-instance Outputable Name where
- ppr sty (Local u n emph_uniq _)
- | codeStyle sty = pprUnique u
- | emph_uniq = ppBesides [pprUnique u, ppStr "{-", ppPStr n, ppStr "-}"]
- | otherwise = ppBesides [ppPStr n, ppStr "{-", pprUnique u, ppStr "-}"]
-
- ppr PprDebug (Global u m (Left n) _ _ _) = ppBesides [pp_mod PprDebug m, pp_name PprDebug n, ppStr "{-", pprUnique u, ppStr "-}"]
- ppr PprDebug (Global u m (Right n) _ _ _) = ppBesides [pp_mod PprDebug m, pp_name2 PprDebug n, ppStr "{-", pprUnique u, ppStr "-}"]
-
- ppr PprForUser (Global u m (Left n) _ _ [] ) = ppBeside (pp_mod PprForUser m) (pp_name PprForUser n)
- ppr PprForUser (Global u m (Right n) _ _ [] ) = ppBeside (pp_mod PprForUser m) (pp_name2 PprForUser n)
- ppr PprForUser (Global u m (Left _) _ _ occs) = ppr PprForUser (head occs)
-
--- LATER:?
--- ppr PprShowAll (Global u m n prov exp occs) = pp_all (Qual m n) prov exp occs
-
- ppr sty (Global u m (Left n) _ _ _) = ppBeside (pp_mod sty m) (pp_name sty n)
- ppr sty (Global u m (Right n) _ _ _) = ppBeside (pp_mod sty m) (pp_name2 sty n)
-
-pp_all orig prov exp occs
- = ppBesides [ppr PprShowAll orig, ppr PprShowAll occs, pp_prov prov, pp_exp exp]
-
-pp_exp NotExported = ppNil
-pp_exp ExportAll = ppPStr SLIT("/EXP(..)")
-pp_exp ExportAbs = ppPStr SLIT("/EXP")
-
-pp_prov Implicit = ppPStr SLIT("/IMPLICIT")
-pp_prov Primitive = ppPStr SLIT("/PRIMITIVE")
-pp_prov (WiredIn _) = ppPStr SLIT("/WIREDIN")
-pp_prov _ = ppNil
-\end{code}