-setNameVisibility :: Maybe Module -> Unique -> Name -> Name
-
-setNameVisibility maybe_mod occ_uniq name@(Global uniq mod occ (LocalDef loc NotExported))
- | not all_toplev_ids_visible || not_top_level maybe_mod
- = Local uniq (uniqToOccName occ_uniq) loc -- Localise Global name
-
-setNameVisibility maybe_mod occ_uniq name@(Global _ _ _ _)
- = name -- Otherwise don't fiddle with Global
-
-setNameVisibility (Just mod) occ_uniq (Local uniq occ loc)
- | all_toplev_ids_visible
- = Global uniq mod -- Globalise Local name
- (uniqToOccName occ_uniq)
- (LocalDef loc NotExported)
-
-setNameVisibility maybe_mod occ_uniq (Local uniq occ loc)
- = Local uniq (uniqToOccName occ_uniq) loc -- New OccName for Local
+mkInternalName :: Unique -> OccName -> SrcLoc -> Name
+mkInternalName uniq occ loc = Name { n_uniq = uniq, n_sort = Internal, n_occ = occ, n_loc = loc }
+ -- NB: You might worry that after lots of huffing and
+ -- puffing we might end up with two local names with distinct
+ -- uniques, but the same OccName. Indeed we can, but that's ok
+ -- * the insides of the compiler don't care: they use the Unique
+ -- * when printing for -ddump-xxx you can switch on -dppr-debug to get the
+ -- uniques if you get confused
+ -- * for interface files we tidyCore first, which puts the uniques
+ -- into the print name (see setNameVisibility below)
+
+mkExternalName :: Unique -> Module -> OccName -> Maybe Name -> SrcLoc -> Name
+mkExternalName uniq mod occ mb_parent loc
+ = Name { n_uniq = uniq, n_sort = External mod mb_parent,
+ n_occ = occ, n_loc = loc }
+
+mkWiredInName :: Module -> OccName -> Unique
+ -> Maybe Name -> TyThing -> BuiltInSyntax -> Name
+mkWiredInName mod occ uniq mb_parent thing built_in
+ = Name { n_uniq = uniq,
+ n_sort = WiredIn mod mb_parent thing built_in,
+ n_occ = occ, n_loc = wiredInSrcLoc }
+
+mkSystemName :: Unique -> UserFS -> Name
+mkSystemName uniq fs = Name { n_uniq = uniq, n_sort = System,
+ n_occ = mkVarOcc fs, n_loc = noSrcLoc }
+
+-- Use this version when the string is already encoded. Avoids duplicating
+-- the string each time a new name is created.
+mkSystemNameEncoded :: Unique -> EncodedFS -> Name
+mkSystemNameEncoded uniq fs = Name { n_uniq = uniq, n_sort = System,
+ n_occ = mkSysOccFS varName fs,
+ n_loc = noSrcLoc }
+
+mkSysTvName :: Unique -> EncodedFS -> Name
+mkSysTvName uniq fs = Name { n_uniq = uniq, n_sort = System,
+ n_occ = mkSysOccFS tvName fs,
+ n_loc = noSrcLoc }
+
+mkFCallName :: Unique -> EncodedString -> Name
+ -- The encoded string completely describes the ccall
+mkFCallName uniq str = Name { n_uniq = uniq, n_sort = Internal,
+ n_occ = mkFCallOcc str, n_loc = noSrcLoc }
+
+mkIPName :: Unique -> OccName -> Name
+mkIPName uniq occ
+ = Name { n_uniq = uniq,
+ n_sort = Internal,
+ n_occ = occ,
+ n_loc = noSrcLoc }
+\end{code}