Commit 1553c778 authored by simonpj's avatar simonpj

[project @ 2002-03-14 15:27:15 by simonpj]

------------------------
	Change
		GlobalName --> ExternalName
		LocalName  ->  InternalName
	------------------------

For a long time there's been terminological confusion between

	GlobalName vs LocalName	 (property of a Name)
	GlobalId vs LocalId	 (property of an Id)

I've now changed the terminology for Name to be

	ExternalName vs InternalName

I've also added quite a bit of documentation in the Commentary.
parent 057e3f0d
%
% (c) The GRASP/AQUA Project, Glasgow University, 1992-1998
%
% $Id: CLabel.lhs,v 1.50 2001/12/12 18:12:45 sewardj Exp $
% $Id: CLabel.lhs,v 1.51 2002/03/14 15:27:15 simonpj Exp $
%
\section[CLabel]{@CLabel@: Information to make C Labels}
......@@ -84,7 +84,7 @@ import CStrings ( pp_cSEP )
import DataCon ( ConTag )
import Module ( moduleName, moduleNameFS,
Module, isHomeModule )
import Name ( Name, getName, isDllName, isExternallyVisibleName )
import Name ( Name, getName, isDllName, isExternalName )
import TyCon ( TyCon )
import Unique ( pprUnique, Unique )
import PrimOp ( PrimOp )
......@@ -335,7 +335,7 @@ externallyVisibleCLabel (ModuleInitLabel _)= True
externallyVisibleCLabel (RtsLabel RtsModuleRegd) = False --hack
externallyVisibleCLabel (RtsLabel _) = True
externallyVisibleCLabel (ForeignLabel _ _) = True
externallyVisibleCLabel (IdLabel id _) = isExternallyVisibleName id
externallyVisibleCLabel (IdLabel id _) = isExternalName id
externallyVisibleCLabel (CC_Label _) = False -- not strictly true
externallyVisibleCLabel (CCS_Label _) = False -- not strictly true
\end{code}
......
......@@ -101,7 +101,7 @@ import IdInfo
import qualified Demand ( Demand )
import NewDemand ( Demand, StrictSig, topSig, isBottomingSig )
import Name ( Name, OccName,
mkSysLocalName, mkLocalName,
mkSystemName, mkInternalName,
getOccName, getSrcLoc
)
import OccName ( EncodedFS, UserFS, mkWorkerOcc )
......@@ -165,8 +165,8 @@ mkVanillaGlobal :: Name -> Type -> IdInfo -> Id
-- for SysLocal, we assume the base name is already encoded, to avoid
-- re-encoding the same string over and over again.
mkSysLocal fs uniq ty = mkLocalId (mkSysLocalName uniq fs) ty
mkUserLocal occ uniq ty loc = mkLocalId (mkLocalName uniq occ loc) ty
mkSysLocal fs uniq ty = mkLocalId (mkSystemName uniq fs) ty
mkUserLocal occ uniq ty loc = mkLocalId (mkInternalName uniq occ loc) ty
mkVanillaGlobal = mkGlobalId VanillaGlobal
\end{code}
......@@ -180,11 +180,11 @@ mkWildId :: Type -> Id
mkWildId ty = mkSysLocal FSLIT("wild") (mkBuiltinUnique 1) ty
mkWorkerId :: Unique -> Id -> Type -> Id
-- A worker gets a local name. CoreTidy will globalise it if necessary.
-- A worker gets a local name. CoreTidy will externalise it if necessary.
mkWorkerId uniq unwrkr ty
= mkLocalId wkr_name ty
where
wkr_name = mkLocalName uniq (mkWorkerOcc (getOccName unwrkr)) (getSrcLoc unwrkr)
wkr_name = mkInternalName uniq (mkWorkerOcc (getOccName unwrkr)) (getSrcLoc unwrkr)
-- "Template locals" typically used in unfoldings
mkTemplateLocals :: [Type] -> [Id]
......
......@@ -10,19 +10,19 @@ module Name (
-- The Name type
Name, -- Abstract
mkLocalName, mkSysLocalName, mkFCallName,
mkInternalName, mkSystemName, mkFCallName,
mkIPName,
mkGlobalName, mkKnownKeyGlobal, mkWiredInName,
mkExternalName, mkKnownKeyExternalName, mkWiredInName,
nameUnique, setNameUnique,
nameOccName, nameModule, nameModule_maybe,
setNameOcc, nameRdrName, setNameModuleAndLoc,
toRdrName, hashName,
globaliseName, localiseName,
externaliseName, localiseName,
nameSrcLoc,
isSystemName, isLocalName, isGlobalName, isExternallyVisibleName,
isSystemName, isInternalName, isExternalName,
isTyVarName, isDllName,
nameIsLocalOrFrom, isHomePackageName,
......@@ -64,12 +64,12 @@ data Name = Name {
-- the SrcLoc in a Name all that often.
data NameSort
= Global Module -- (a) TyCon, Class, their derived Ids, dfun Id
= External Module -- (a) TyCon, Class, their derived Ids, dfun Id
-- (b) Imported Id
-- (c) Top-level Id in the original source, even if
-- locally defined
| Local -- A user-defined Id or TyVar
| Internal -- A user-defined Id or TyVar
-- defined in the module being compiled
| System -- A system-defined Id or TyVar. Typically the
......@@ -78,16 +78,16 @@ data NameSort
Notes about the NameSorts:
1. Initially, top-level Ids (including locally-defined ones) get Global names,
and all other local Ids get Local names
1. Initially, top-level Ids (including locally-defined ones) get External names,
and all other local Ids get Internal names
2. Things with a @Global@ name are given C static labels, so they finally
2. Things with a External name are given C static labels, so they finally
appear in the .o file's symbol table. They appear in the symbol table
in the form M.n. If originally-local things have this property they
must be made @Global@ first.
must be made @External@ first.
3. In the tidy-core phase, a Global that is not visible to an importer
is changed to Local, and a Local that is visible is changed to Global
3. In the tidy-core phase, a External that is not visible to an importer
is changed to Internal, and a Internal that is visible is changed to External
4. A System Name differs in the following ways:
a) has unique attached when printing dumps
......@@ -109,31 +109,30 @@ nameUnique name = n_uniq name
nameOccName name = n_occ name
nameSrcLoc name = n_loc name
nameModule (Name { n_sort = Global mod }) = mod
nameModule (Name { n_sort = External mod }) = mod
nameModule name = pprPanic "nameModule" (ppr name)
nameModule_maybe (Name { n_sort = Global mod }) = Just mod
nameModule_maybe (Name { n_sort = External mod }) = Just mod
nameModule_maybe name = Nothing
\end{code}
\begin{code}
nameIsLocalOrFrom :: Module -> Name -> Bool
isLocalName :: Name -> Bool -- Not globals
isGlobalName :: Name -> Bool
isSystemName :: Name -> Bool
isExternallyVisibleName :: Name -> Bool
isHomePackageName :: Name -> Bool
nameIsLocalOrFrom :: Module -> Name -> Bool
isInternalName :: Name -> Bool
isExternalName :: Name -> Bool
isSystemName :: Name -> Bool
isHomePackageName :: Name -> Bool
isGlobalName (Name {n_sort = Global _}) = True
isGlobalName other = False
isExternalName (Name {n_sort = External _}) = True
isExternalName other = False
isLocalName name = not (isGlobalName name)
isInternalName name = not (isExternalName name)
nameIsLocalOrFrom from (Name {n_sort = Global mod}) = mod == from
nameIsLocalOrFrom from other = True
nameIsLocalOrFrom from (Name {n_sort = External mod}) = mod == from
nameIsLocalOrFrom from other = True
isHomePackageName (Name {n_sort = Global mod}) = isHomeModule mod
isHomePackageName other = True -- Local and system names
isHomePackageName (Name {n_sort = External mod}) = isHomeModule mod
isHomePackageName other = True -- Internal and system names
isDllName :: Name -> Bool -- Does this name refer to something in a different DLL?
isDllName nm = not opt_Static && not (isHomePackageName nm)
......@@ -141,11 +140,6 @@ isDllName nm = not opt_Static && not (isHomePackageName nm)
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
isExternallyVisibleName name = isGlobalName name
isSystemName (Name {n_sort = System}) = True
isSystemName other = False
\end{code}
......@@ -158,8 +152,8 @@ isSystemName other = False
%************************************************************************
\begin{code}
mkLocalName :: Unique -> OccName -> SrcLoc -> Name
mkLocalName uniq occ loc = Name { n_uniq = uniq, n_sort = Local, n_occ = occ, n_loc = loc }
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
......@@ -169,32 +163,32 @@ mkLocalName uniq occ loc = Name { n_uniq = uniq, n_sort = Local, n_occ = occ, n_
-- * for interface files we tidyCore first, which puts the uniques
-- into the print name (see setNameVisibility below)
mkGlobalName :: Unique -> Module -> OccName -> SrcLoc -> Name
mkGlobalName uniq mod occ loc = Name { n_uniq = uniq, n_sort = Global mod,
mkExternalName :: Unique -> Module -> OccName -> SrcLoc -> Name
mkExternalName uniq mod occ loc = Name { n_uniq = uniq, n_sort = External mod,
n_occ = occ, n_loc = loc }
mkKnownKeyGlobal :: RdrName -> Unique -> Name
mkKnownKeyGlobal rdr_name uniq
= mkGlobalName uniq (mkVanillaModule (rdrNameModule rdr_name))
mkKnownKeyExternalName :: RdrName -> Unique -> Name
mkKnownKeyExternalName rdr_name uniq
= mkExternalName uniq (mkVanillaModule (rdrNameModule rdr_name))
(rdrNameOcc rdr_name)
builtinSrcLoc
mkWiredInName :: Module -> OccName -> Unique -> Name
mkWiredInName mod occ uniq = mkGlobalName uniq mod occ builtinSrcLoc
mkWiredInName mod occ uniq = mkExternalName uniq mod occ builtinSrcLoc
mkSysLocalName :: Unique -> EncodedFS -> Name
mkSysLocalName uniq fs = Name { n_uniq = uniq, n_sort = System,
mkSystemName :: Unique -> EncodedFS -> Name
mkSystemName uniq fs = Name { n_uniq = uniq, n_sort = System,
n_occ = mkVarOcc fs, n_loc = noSrcLoc }
mkFCallName :: Unique -> EncodedString -> Name
-- The encoded string completely describes the ccall
mkFCallName uniq str = Name { n_uniq = uniq, n_sort = Local,
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 = Local,
n_sort = Internal,
n_occ = occ,
n_loc = noSrcLoc }
\end{code}
......@@ -208,16 +202,16 @@ setNameUnique name uniq = name {n_uniq = uniq}
setNameOcc :: Name -> OccName -> Name
setNameOcc name occ = name {n_occ = occ}
globaliseName :: Name -> Module -> Name
globaliseName n mod = n { n_sort = Global mod }
externaliseName :: Name -> Module -> Name
externaliseName n mod = n { n_sort = External mod }
localiseName :: Name -> Name
localiseName n = n { n_sort = Local }
localiseName n = n { n_sort = Internal }
setNameModuleAndLoc :: Name -> Module -> SrcLoc -> Name
setNameModuleAndLoc name mod loc = name {n_sort = set (n_sort name), n_loc = loc}
where
set (Global _) = Global mod
set (External _) = External mod
\end{code}
......@@ -233,10 +227,10 @@ hashName name = iBox (u2i (nameUnique name))
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_occ = occ, n_sort = Global mod }) = mkRdrOrig (moduleName mod) occ
nameRdrName (Name { n_occ = occ }) = mkRdrUnqual occ
-- Makes a qualified name for top-level (External) names,
-- whether locally defined or not and an unqualified name just for Internals
nameRdrName (Name { n_occ = occ, n_sort = External mod }) = mkRdrOrig (moduleName mod) occ
nameRdrName (Name { n_occ = occ }) = mkRdrUnqual occ
\end{code}
......@@ -280,7 +274,7 @@ instance Binary Name where
-- we must print these as RdrNames, because that's how they will be read in
put_ bh Name {n_sort = sort, n_uniq = uniq, n_occ = occ} =
case sort of
Global mod
External mod
| this_mod == mod -> put_ bh (mkRdrUnqual occ)
| otherwise -> put_ bh (mkRdrOrig (moduleName mod) occ)
where (this_mod,_,_,_) = getUserData bh
......@@ -298,17 +292,17 @@ instance Binary Name where
\begin{code}
instance Outputable Name where
-- When printing interfaces, all Locals have been given nice print-names
-- When printing interfaces, all Internals have been given nice print-names
ppr name = pprName name
pprName name@(Name {n_sort = sort, n_uniq = uniq, n_occ = occ})
= getPprStyle $ \ sty ->
case sort of
Global mod -> pprGlobal sty name uniq mod occ
System -> pprSysLocal sty uniq occ
Local -> pprLocal sty uniq occ
External mod -> pprExternal sty name uniq mod occ
System -> pprSystem sty uniq occ
Internal -> pprInternal sty uniq occ
pprGlobal sty name uniq mod occ
pprExternal sty name uniq mod occ
| codeStyle sty = ppr (moduleName mod) <> char '_' <> pprOccName occ
| debugStyle sty = ppr (moduleName mod) <> dot <> pprOccName occ <>
......@@ -317,14 +311,14 @@ pprGlobal sty name uniq mod occ
| unqualStyle sty name = pprOccName occ
| otherwise = ppr (moduleName mod) <> dot <> pprOccName occ
pprLocal sty uniq occ
pprInternal sty uniq occ
| codeStyle sty = pprUnique uniq
| debugStyle sty = pprOccName occ <>
text "{-" <> pprUnique uniq <> text "-}"
| otherwise = pprOccName occ -- User and Iface styles
-- Like Local, except that we only omit the unique in Iface style
pprSysLocal sty uniq occ
-- Like Internal, except that we only omit the unique in Iface style
pprSystem sty uniq occ
| codeStyle sty = pprUnique uniq
| ifaceStyle sty = pprOccName occ -- The tidy phase has ensured
-- that OccNames are enough
......
......@@ -41,7 +41,7 @@ import {-# SOURCE #-} IdInfo( GlobalIdDetails, notGlobalId,
import Name ( Name, OccName, NamedThing(..),
setNameUnique, setNameOcc, nameUnique,
mkSysLocalName
mkSystemName
)
import Unique ( Unique, Uniquable(..), mkUniqueGrimily, getKey )
import FastTypes
......@@ -195,7 +195,7 @@ mkSysTyVar uniq kind = Var { varName = name
, varInfo = pprPanic "mkSysTyVar" (ppr name)
}
where
name = mkSysLocalName uniq FSLIT("t")
name = mkSystemName uniq FSLIT("t")
newMutTyVar :: Name -> Kind -> TyVarDetails -> IO TyVar
newMutTyVar name kind details
......
......@@ -44,7 +44,7 @@ import VarEnv
import VarSet ( varSetElems )
import Literal ( Literal )
import Maybes ( catMaybes, maybeToBool, seqMaybe )
import Name ( isLocalName, NamedThing(..) )
import Name ( isInternalName, NamedThing(..) )
#ifdef DEBUG
import PprAbsC ( pprAmode )
#endif
......@@ -259,7 +259,7 @@ getCAddrModeAndInfo id
case maybe_cg_id_info of
-- Nothing => not in the environment, so should be imported
Nothing | isLocalName name -> cgLookupPanic id
Nothing | isInternalName name -> cgLookupPanic id
| otherwise -> returnFC (id, global_amode, mkLFImported id)
Just (MkCgIdInfo id' volatile_loc stable_loc lf_info)
......
%
% (c) The GRASP/AQUA Project, Glasgow University, 1992-1998
%
% $Id: CgClosure.lhs,v 1.55 2002/02/14 11:56:03 njn Exp $
% $Id: CgClosure.lhs,v 1.56 2002/03/14 15:27:17 simonpj Exp $
%
\section[CgClosure]{Code generation for closures}
......@@ -46,7 +46,7 @@ import ClosureInfo -- lots and lots of stuff
import CmdLineOpts ( opt_GranMacros, opt_SccProfilingOn, opt_DoTickyProfiling )
import CostCentre
import Id ( Id, idName, idType, idPrimRep )
import Name ( Name, isLocalName )
import Name ( Name, isInternalName )
import Module ( Module, pprModule )
import ListSetOps ( minusList )
import PrimRep ( PrimRep(..) )
......@@ -449,7 +449,7 @@ closureCodeBody binder_info closure_info cc all_args body
-- give the module name even for *local* things. We print
-- just "x (M)" rather that "M.x" to distinguish them from the global kind.
ppr_for_ticky_name mod_name name
| isLocalName name = showSDocDebug (ppr name <+> (parens (ppr mod_name)))
| isInternalName name = showSDocDebug (ppr name <+> (parens (ppr mod_name)))
| otherwise = showSDocDebug (ppr name)
\end{code}
......
%
% (c) The GRASP/AQUA Project, Glasgow University, 1992-1998
%
% $Id: CgTailCall.lhs,v 1.31 2001/10/25 05:07:32 sof Exp $
% $Id: CgTailCall.lhs,v 1.32 2002/03/14 15:27:17 simonpj Exp $
%
%********************************************************
%* *
......@@ -345,7 +345,7 @@ tailCallFun
tailCallFun fun fun_amode lf_info arg_amodes pending_assts
= nodeMustPointToIt lf_info `thenFC` \ node_points ->
-- we use the name of fun', the Id from the environment, rather than
-- fun from the STG tree, in case it is a top-level name that we globalised
-- fun from the STG tree, in case it is a top-level name that we externalised
-- (see cgTopRhsClosure).
getEntryConvention (idName fun) lf_info
(map getAmodeRep arg_amodes) `thenFC` \ entry_conv ->
......
......@@ -40,7 +40,7 @@ import CmdLineOpts ( DynFlags, DynFlag(..),
opt_SccProfilingOn, opt_EnsureSplittableC )
import CostCentre ( CollectedCCs )
import Id ( Id, idName, setIdName )
import Name ( nameSrcLoc, nameOccName, nameUnique, isLocalName, mkGlobalName )
import Name ( nameSrcLoc, nameOccName, nameUnique, isInternalName, mkExternalName )
import OccName ( mkLocalOcc )
import Module ( Module )
import PrimRep ( PrimRep(..) )
......@@ -182,14 +182,14 @@ variable.
cgTopBinding :: (StgBinding,[Id]) -> Code
cgTopBinding (StgNonRec srt_info id rhs, srt)
= absC maybeSplitCode `thenC`
maybeGlobaliseId id `thenFC` \ id' ->
maybeExternaliseId id `thenFC` \ id' ->
let
srt_label = mkSRTLabel (idName id')
in
mkSRT srt_label srt [] `thenC`
setSRTLabel srt_label (
cgTopRhs id' rhs srt_info `thenFC` \ (id, info) ->
addBindC id info -- Add the un-globalised Id to the envt, so we
addBindC id info -- Add the un-externalised Id to the envt, so we
-- find it when we look up occurrences
)
......@@ -198,7 +198,7 @@ cgTopBinding (StgRec srt_info pairs, srt)
let
(bndrs, rhss) = unzip pairs
in
mapFCs maybeGlobaliseId bndrs `thenFC` \ bndrs'@(id:_) ->
mapFCs maybeExternaliseId bndrs `thenFC` \ bndrs'@(id:_) ->
let
srt_label = mkSRTLabel (idName id)
pairs' = zip bndrs' rhss
......@@ -218,7 +218,7 @@ mkSRT lbl ids these
absC (CSRT lbl (map (mkClosureLabel . idName) ids))
where
-- sigh, better map all the ids against the environment in case they've
-- been globalised (see maybeGlobaliseId below).
-- been externalised (see maybeExternaliseId below).
remap id = case filter (==id) these of
[] -> getCAddrModeAndInfo id
`thenFC` \ (id, _, _) -> returnFC id
......@@ -230,7 +230,7 @@ mkSRT lbl ids these
cgTopRhs :: Id -> StgRhs -> SRT -> FCode (Id, CgIdInfo)
-- The Id is passed along for setting up a binding...
-- It's already been globalised if necessary
-- It's already been externalised if necessary
cgTopRhs bndr (StgRhsCon cc con args) srt
= forkStatics (cgTopRhsCon bndr con args srt)
......@@ -250,17 +250,17 @@ cgTopRhs bndr (StgRhsClosure cc bi fvs upd_flag args body) srt
%* *
%************************************************************************
If we're splitting the object, we need to globalise all the top-level names
(and then make sure we only use the globalised one in any C label we use
If we're splitting the object, we need to externalise all the top-level names
(and then make sure we only use the externalised one in any C label we use
which refers to this name).
\begin{code}
maybeGlobaliseId :: Id -> FCode Id
maybeGlobaliseId id
| opt_EnsureSplittableC, -- Globalise the name for -split-objs
isLocalName name
maybeExternaliseId :: Id -> FCode Id
maybeExternaliseId id
| opt_EnsureSplittableC, -- Externalise the name for -split-objs
isInternalName name
= moduleName `thenFC` \ mod ->
returnFC (setIdName id (mkGlobalName uniq mod new_occ (nameSrcLoc name)))
returnFC (setIdName id (mkExternalName uniq mod new_occ (nameSrcLoc name)))
| otherwise
= returnFC id
where
......
......@@ -75,7 +75,7 @@ import HscMain ( initPersistentCompilerState )
#endif
import HscTypes
import Name ( Name, NamedThing(..), nameRdrName, nameModule,
isHomePackageName, isGlobalName )
isHomePackageName, isExternalName )
import NameEnv
import Rename ( mkGlobalContext )
import RdrName ( emptyRdrEnv )
......@@ -253,7 +253,7 @@ cmInfoThing cmstate dflags id
getFixity :: PersistentCompilerState -> Name -> Fixity
getFixity pcs name
| isGlobalName name,
| isExternalName name,
Just iface <- lookupModuleEnv iface_table (nameModule name),
Just fixity <- lookupNameEnv (mi_fixities iface) name
= fixity
......
......@@ -29,8 +29,8 @@ import Id ( idType, idInfo, idName, isExportedId,
import IdInfo {- loads of stuff -}
import NewDemand ( isBottomingSig, topSig )
import BasicTypes ( isNeverActive )
import Name ( getOccName, nameOccName, mkLocalName, mkGlobalName,
localiseName, isGlobalName, nameSrcLoc
import Name ( getOccName, nameOccName, mkInternalName, mkExternalName,
localiseName, isExternalName, nameSrcLoc
)
import NameEnv ( filterNameEnv )
import OccName ( TidyOccEnv, initTidyOccEnv, tidyOccName )
......@@ -157,7 +157,7 @@ tidyCorePgm dflags mod pcs cg_info_env
init_tidy_env = (orig_ns, initTidyOccEnv avoids, emptyVarEnv)
avoids = [getOccName name | bndr <- typeEnvIds env_tc,
let name = idName bndr,
isGlobalName name]
isExternalName name]
-- In computing our "avoids" list, we must include
-- all implicit Ids
-- all things with global names (assigned once and for
......@@ -177,7 +177,7 @@ tidyCorePgm dflags mod pcs cg_info_env
; let final_ids = [ id
| bind <- tidy_binds
, id <- bindersOf bind
, isGlobalName (idName id)]
, isExternalName (idName id)]
-- Dfuns are local Ids that might have
-- changed their unique during tidying
......@@ -518,7 +518,7 @@ tidyTopIdInfo tidy_env is_external idinfo unfold_info arity cg_info
-- This is where we set names to local/global based on whether they really are
-- externally visible (see comment at the top of this module). If the name
-- was previously local, we have to give it a unique occurrence name if
-- we intend to globalise it.
-- we intend to externalise it.
tidyTopName mod ns occ_env external name
| global && internal = (ns, occ_env, localiseName name)
......@@ -529,22 +529,22 @@ tidyTopName mod ns occ_env external name
| local && internal = (ns_w_local, occ_env', new_local_name)
-- Even local, internal names must get a unique occurrence, because
-- if we do -split-objs we globalise the name later, in the code generator
-- if we do -split-objs we externalise the name later, in the code generator
--
-- Similarly, we must make sure it has a system-wide Unique, because
-- the byte-code generator builds a system-wide Name->BCO symbol table
| local && external = case lookupFM ns_names key of
Just orig -> (ns, occ_env', orig)
Nothing -> (ns_w_global, occ_env', new_global_name)
-- If we want to globalise a currently-local name, check
Nothing -> (ns_w_global, occ_env', new_external_name)
-- If we want to externalise a currently-local name, check
-- whether we have already assigned a unique for it.
-- If so, use it; if not, extend the table (ns_w_global).
-- This is needed when *re*-compiling a module in GHCi; we want to
-- use the same name for externally-visible things as we did before.
where
global = isGlobalName name
global = isExternalName name
local = not global
internal = not external
......@@ -556,11 +556,11 @@ tidyTopName mod ns occ_env external name
uniq = uniqFromSupply us1
loc = nameSrcLoc name
new_local_name = mkLocalName uniq occ' loc
new_global_name = mkGlobalName uniq mod occ' loc
new_local_name = mkInternalName uniq occ' loc
new_external_name = mkExternalName uniq mod occ' loc
ns_w_local = ns { nsUniqs = us2 }
ns_w_global = ns { nsUniqs = us2, nsNames = addToFM ns_names key new_global_name }
ns_w_global = ns { nsUniqs = us2, nsNames = addToFM ns_names key new_external_name }
------------ Worker --------------
......
......@@ -19,7 +19,7 @@ import DsUtils ( EquationInfo(..), MatchResult(..), EqnSet,
import Id ( idType )
import DataCon ( DataCon, dataConTyCon, dataConArgTys,
dataConSourceArity, dataConFieldLabels )
import Name ( Name, mkLocalName, getOccName, isDataSymOcc, getName, mkVarOcc )
import Name ( Name, mkInternalName, getOccName, isDataSymOcc, getName, mkVarOcc )
import TcType ( mkTyVarTys )
import TysPrim ( charPrimTy )
import TysWiredIn
......@@ -375,7 +375,7 @@ make_row_vars used_lits (EqnInfo _ _ pats _ ) =
(VarPatIn new_var:takeList (tail pats) (repeat new_wild_pat),[(new_var,used_lits)])
where new_var = hash_x
hash_x = mkLocalName unboundKey {- doesn't matter much -}
hash_x = mkInternalName unboundKey {- doesn't matter much -}
(mkVarOcc SLIT("#x"))
noSrcLoc
......
......@@ -16,7 +16,7 @@ module ByteCodeLink ( UnlinkedBCO, UnlinkedBCOExpr, assembleBCO,
#include "HsVersions.h"
import Outputable
import Name ( Name, getName, nameModule, toRdrName, isGlobalName )
import Name ( Name, getName, nameModule, toRdrName, isExternalName )
import RdrName ( rdrNameOcc, rdrNameModule )
import OccName ( occNameString )
import FiniteMap ( FiniteMap, addListToFM, filterFM,
......@@ -103,7 +103,7 @@ linkSomeBCOs toplevs_only ie ce_in ul_bcos
in mapM (linkBCO ie ce_out) ul_bcos )
let ce_all_additions = zip nms hvals
ce_top_additions = filter (isGlobalName.fst) ce_all_additions
ce_top_additions = filter (isExternalName.fst) ce_all_additions
ce_additions = if toplevs_only then ce_top_additions
else ce_all_additions
ce_out = -- make sure we're not inserting duplicate names into the
......@@ -153,7 +153,7 @@ data HValue = HValue -- dummy type, actually a pointer to some Real Code.
-- the command line).
filterNameMap :: [ModuleName] -> FiniteMap Name a -> FiniteMap Name a
filterNameMap mods env
= filterFM (\n _ -> isGlobalName n
= filterFM (\n _ -> isExternalName n
&& moduleName (nameModule n) `elem` mods) env
\end{code}
......@@ -603,7 +603,7 @@ lookupCE ce (Left nm)
= case lookupFM ce nm of
Just aa -> return aa
Nothing
-> ASSERT2(isGlobalName nm, ppr nm)
-> ASSERT2(isExternalName nm, ppr nm)
do let sym_to_find = nameToCLabel nm "closure"
m <- lookupSymbol sym_to_find
case m of
......
......@@ -238,7 +238,7 @@ Source code:
instance Foo [Bool] where ...
These might both be dFooList
- The CoreTidy phase globalises the name, and ensures the occurrence name is
- The CoreTidy phase externalises the name, and ensures the occurrence name is
unique (this isn't special to dict funs). So we'd get dFooList and dFooList1.
- We can take this relaxed approach (changing the occurrence name later)
......
......@@ -27,7 +27,7 @@ import PrimOp ( PrimOp(..) )
import ForeignCall ( CCallConv(..), ForeignCall(..), CCallSpec(..), CCallTarget(..), DNCallSpec(..) )
import TysWiredIn ( mkTupleTy, tupleCon )
import PrimRep ( PrimRep(..) )
import Name ( nameModule, nameOccName, isGlobalName, isLocalName, NamedThing(getName) )
import Name ( nameModule, nameOccName, isExternalName, isInternalName, NamedThing(getName) )
import Subst ( substTyWith )
import Module ( Module, PackageName, ModuleName, moduleName,
......@@ -157,7 +157,7 @@ importsVars env vs = foldR (importsVar env) vs
importsVar env v = importsName env (idName v). importsType env (idType v)
importsName env n
| isLocalName n = importsNone
| isInternalName n = importsNone
| ilxEnvModule env == nameModule n = importsNone
| isHomeModule (nameModule n) = addModuleImpInfo (moduleName (nameModule n))
-- See HACK below
......@@ -187,7 +187,7 @@ importsTypeArgs2 env tys = foldR (importsType2 env) tys
importsDataCon env dcon = importsTyCon env (dataConTyCon dcon)
importsTyCon env tc | (not (isDataTyCon tc) ||
isLocalName (getName tc) ||
isInternalName (getName tc) ||
ilxEnvModule env == nameModule (getName tc)) = importsNone
importsTyCon env tc | otherwise = importsName env (getName tc) . addTyConImpInfo tc .
foldR (importsTyConDataCon env) (tyConDataCons tc)
......@@ -210,7 +210,7 @@ importsTyConDataConType2 _ _ = panic "IlxGen.lhs: importsTyConDataConType2 ty"
importsTyConDataConTypeArgs2 env tys = foldR (importsTyConDataConType2 env) tys
importsTyConDataConTypeTyCon env tc | (not (isDataTyCon tc) ||
isLocalName (getName tc) ||
isInternalName (getName tc) ||
ilxEnvModule env == nameModule (getName tc)) = importsNone