-\subsection{Tidying a name}
-%* *
-%************************************************************************
-
-tidyTopName is applied to top-level names in the final program
-
-For top-level things,
- it globalises Local names
- (if all top-level things should be visible)
- and localises non-exported Global names
- (if only exported things should be visible)
-
-In all cases except an exported global, it gives it a new occurrence name.
-
-The "visibility" here concerns whether the .o file's symbol table
-mentions the thing; if so, it needs a module name in its symbol.
-The Global things are "visible" and the Local ones are not
-
-Why should things be "visible"? Certainly they must be if they
-are exported. But also:
-
-(a) In certain (prelude only) modules we split up the .hc file into
- lots of separate little files, which are separately compiled by the C
- compiler. That gives lots of little .o files. The idea is that if
- you happen to mention one of them you don't necessarily pull them all
- in. (Pulling in a piece you don't need can be v bad, because it may
- mention other pieces you don't need either, and so on.)
-
- Sadly, splitting up .hc files means that local names (like s234) are
- now globally visible, which can lead to clashes between two .hc
- files. So unlocaliseWhatnot goes through making all the local things
- into global things, essentially by giving them full names so when they
- are printed they'll have their module name too. Pretty revolting
- really.
-
-(b) When optimisation is on we want to make all the internal
- top-level defns externally visible
-
-\begin{code}
-tidyTopName :: Module -> TidyOccEnv -> Name -> (TidyOccEnv, Name)
-tidyTopName mod env name
- = (env', name')
- where
- (env', occ') = tidyOccName env (n_occ name)
-
- name' = Name { n_uniq = n_uniq name, n_sort = mk_top_sort mod,
- n_occ = occ', n_loc = n_loc name }
-
-mk_top_sort mod | all_toplev_ids_visible = Global mod
- | otherwise = Local
-
-all_toplev_ids_visible =
- not opt_OmitInterfacePragmas || -- Pragmas can make them visible
- opt_EnsureSplittableC -- Splitting requires visiblilty
-\end{code}
-
-
-
-%************************************************************************
-%* *