%
% (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}
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 )
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}
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 )
-- 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}
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]
-- 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,
-- 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
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
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)
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}
%************************************************************************
\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
-- * 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}
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}
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}
-- 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
\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 <>
| 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
import Name ( Name, OccName, NamedThing(..),
setNameUnique, setNameOcc, nameUnique,
- mkSysLocalName
+ mkSystemName
)
import Unique ( Unique, Uniquable(..), mkUniqueGrimily, getKey )
import FastTypes
, 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
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
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}
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(..) )
-- 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 $
%
%********************************************************
%* *
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 ->
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(..) )
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
)
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
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
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)
%* *
%************************************************************************
-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
#endif
import HscTypes
import Name ( Name, NamedThing(..), nameRdrName, nameModule,
- isHomePackageName, isGlobalName )
+ isHomePackageName, isExternalName )
import NameEnv
import Rename ( mkGlobalContext )
import RdrName ( emptyRdrEnv )
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
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 )
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
; 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
-- 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)
| 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
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 --------------
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
(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
#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,
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
-- 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}
= 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
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)
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,
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
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)
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
importsTyConDataConTypeTyCon env tc | otherwise = importsName env (getName tc)
pushLit env (MachLabel l) = trace "WARNING: Cannot compile MachLabel to ILX in IlxGen.lhs" (text "// MachLabel!!! Not valid in ILX!!")
pprIlxTopVar env v
- | isGlobalName n = (nameReference env n) <> pprId (nameModule n) <> text "::" <> singleQuotes (ppr (nameModule n) <> text "_" <> ppr (nameOccName n))
+ | isExternalName n = (nameReference env n) <> pprId (nameModule n) <> text "::" <> singleQuotes (ppr (nameModule n) <> text "_" <> ppr (nameOccName n))
| otherwise = pprId (nameOccName n)
where
n = idName v
hscOptionQual = text ".i_"
nameReference env n
- | isLocalName n = empty
+ | isInternalName n = empty
| ilxEnvModule env == nameModule n = text ""
| isHomeModule (nameModule n) = moduleNameReference (moduleName (nameModule n))
-- HACK: no Vanilla modules should be around, but they are!! This
import Literal ( Literal(..) )
import Id ( Id, isDataConId_maybe, isId, idName, isDeadBinder, idPrimRep
, isPrimOpId_maybe )
-import Name ( NamedThing(..), getOccString, isGlobalName, isLocalName
+import Name ( NamedThing(..), getOccString, isExternalName, isInternalName
, nameModule )
import PrimRep ( PrimRep(..) )
import DataCon ( DataCon, dataConRepArity, dataConRepArgTys, dataConId )
\begin{code}
javaVar :: Id -> Expr
-javaVar v | isGlobalName (idName v) = mkNew (javaIdType v) []
+javaVar v | isExternalName (idName v) = mkNew (javaIdType v) []
| otherwise = Var (javaName v)
javaLit :: Literal.Literal -> Expr
-- using the same string as the Id.
javaName :: Id -> Name
javaName n
- | isGlobalName (idName n) = error "useing javaName on global"
+ | isExternalName (idName n) = error "useing javaName on global"
| otherwise = Name (getOccString n)
(primRepToType (idPrimRep n))
javaIdTypeName :: Id -> TypeName
javaIdTypeName n
- | isLocalName n' = renameForKeywords n'
+ | isInternalName n' = renameForKeywords n'
| otherwise = moduleString (nameModule n') ++ "." ++ renameForKeywords n'
where
n' = getName n
import Type ( Type )
import Id ( Id, idName, setGlobalIdDetails )
import IdInfo ( GlobalIdDetails(VanillaGlobal) )
-import Name ( isLocalName )
+import Name ( isInternalName )
import NameEnv ( lookupNameEnv )
import Module ( lookupModuleEnv )
import RdrName ( rdrEnvElts )
Nothing -> return (pcs, []);
Just pcs ->
let do_lookup n
- | isLocalName n = lookupNameEnv (ic_type_env ic) n
+ | isInternalName n = lookupNameEnv (ic_type_env ic) n
| otherwise = lookupType hst (pcs_PTE pcs) n
maybe_ty_things = map do_lookup names
import CoreFVs ( ruleLhsFreeNames )
import CoreUnfold ( neverUnfold, unfoldingTemplate )
import PprCore ( pprIdCoreRule )
-import Name ( getName, nameModule, toRdrName, isGlobalName,
+import Name ( getName, nameModule, toRdrName, isExternalName,
nameIsLocalOrFrom, Name, NamedThing(..) )
import NameEnv
import NameSet
ids = [id | id <- typeEnvIds type_env, want_sig id]
want_sig id | opt_PprStyle_Debug = True
| otherwise = isLocalId id &&
- isGlobalName (idName id) &&
+ isExternalName (idName id) &&
not (id `elem` dfun_ids)
-- isLocalId ignores data constructors, records selectors etc
- -- The isGlobalName ignores local dictionary and method bindings
+ -- The isExternalName ignores local dictionary and method bindings
-- that the type checker has invented. User-defined things have
-- Global names.
)
import BasicTypes ( Boxity(..), Arity )
import UniqFM ( UniqFM, listToUFM )
-import Name ( Name, mkLocalName, mkKnownKeyGlobal, nameRdrName )
+import Name ( Name, mkInternalName, mkKnownKeyExternalName, nameRdrName )
import RdrName ( rdrNameOcc )
import SrcLoc ( builtinSrcLoc, noSrcLoc )
import Util ( nOfThem )
This *local* name is used by the interactive stuff
\begin{code}
-itName uniq = mkLocalName uniq (mkOccFS varName FSLIT("it")) noSrcLoc
+itName uniq = mkInternalName uniq (mkOccFS varName FSLIT("it")) noSrcLoc
\end{code}
\begin{code}
-- mkUnboundName makes a place-holder Name; it shouldn't be looked at except possibly
-- during compiler debugging.
mkUnboundName :: RdrName -> Name
-mkUnboundName rdr_name = mkLocalName unboundKey (rdrNameOcc rdr_name) builtinSrcLoc
+mkUnboundName rdr_name = mkInternalName unboundKey (rdrNameOcc rdr_name) builtinSrcLoc
isUnboundName :: Name -> Bool
isUnboundName name = name `hasKey` unboundKey
All these are original names; hence mkOrig
\begin{code}
-varQual mod str uq = mkKnownKeyGlobal (varQual_RDR mod str) uq
-dataQual mod str uq = mkKnownKeyGlobal (dataQual_RDR mod str) uq
-tcQual mod str uq = mkKnownKeyGlobal (tcQual_RDR mod str) uq
-clsQual mod str uq = mkKnownKeyGlobal (clsQual_RDR mod str) uq
+varQual mod str uq = mkKnownKeyExternalName (varQual_RDR mod str) uq
+dataQual mod str uq = mkKnownKeyExternalName (dataQual_RDR mod str) uq
+tcQual mod str uq = mkKnownKeyExternalName (tcQual_RDR mod str) uq
+clsQual mod str uq = mkKnownKeyExternalName (clsQual_RDR mod str) uq
-kindQual str uq = mkLocalName uq (mkKindOccFS tcName str) builtinSrcLoc
+kindQual str uq = mkInternalName uq (mkKindOccFS tcName str) builtinSrcLoc
-- Kinds are not z-encoded in interface file, hence mkKindOccFS
-- And they don't come from any particular module; indeed we always
-- want to print them unqualified. Hence the LocalName
#include "HsVersions.h"
import Var ( TyVar, mkTyVar )
-import Name ( Name, mkLocalName )
+import Name ( Name, mkInternalName )
import OccName ( mkVarOcc )
import PrimRep ( PrimRep(..) )
import TyCon ( TyCon, ArgVrcs, mkPrimTyCon, mkLiftedPrimTyCon )
\begin{code}
tyVarList :: Kind -> [TyVar]
-tyVarList kind = [ mkTyVar (mkLocalName (mkAlphaTyVarUnique u)
+tyVarList kind = [ mkTyVar (mkInternalName (mkAlphaTyVarUnique u)
(mkVarOcc (mkFastString name))
noSrcLoc) kind
| u <- [2..],
moduleNameUserString, moduleName,
moduleEnvElts
)
-import Name ( Name, nameModule, isGlobalName )
+import Name ( Name, nameModule, isExternalName )
import NameEnv
import NameSet
import RdrName ( foldRdrEnv, isQual )
-- simplification), and retain them all in the TypeEnv so they are
-- available from the command line.
--
- -- isGlobalName separates the user-defined top-level names from those
+ -- isExternalName separates the user-defined top-level names from those
-- introduced by the type checker.
dont_discard :: Name -> Bool
- dont_discard | ghci_mode == Interactive = isGlobalName
+ dont_discard | ghci_mode == Interactive = isExternalName
| otherwise = (`elemNameSet` exported_names)
exported_names = availsToNameSet export_avails
import RnMonad
import Name ( Name,
getSrcLoc, nameIsLocalOrFrom,
- mkLocalName, mkGlobalName,
+ mkInternalName, mkExternalName,
mkIPName, nameOccName, nameModule_maybe,
setNameModuleAndLoc
)
Nothing -> let
(us', us1) = splitUniqSupply (nsUniqs name_supply)
uniq = uniqFromSupply us1
- new_name = mkGlobalName uniq mod occ loc
+ new_name = mkExternalName uniq mod occ loc
new_cache = addToFM cache key new_name
in
setNameSupplyRn (name_supply {nsUniqs = us', nsNames = new_cache}) `thenRn_`
(us', us1) = splitUniqSupply (nsUniqs name_supply)
uniq = uniqFromSupply us1
mod = mkVanillaModule mod_name
- name = mkGlobalName uniq mod occ noSrcLoc
+ name = mkExternalName uniq mod occ noSrcLoc
new_cache = addToFM cache key name
newIPName rdr_name_ip
let
(us', us1) = splitUniqSupply (nsUniqs name_supply)
uniqs = uniqsFromSupply us1
- names = [ mkLocalName uniq (rdrNameOcc rdr_name) loc
+ names = [ mkInternalName uniq (rdrNameOcc rdr_name) loc
| ((rdr_name,loc), uniq) <- rdr_names_w_loc `zip` uniqs
]
in
let
(us', us1) = splitUniqSupply (nsUniqs name_supply)
uniq = uniqFromSupply us1
- name = mkLocalName uniq (rdrNameOcc rdr_name) loc
+ name = mkInternalName uniq (rdrNameOcc rdr_name) loc
in
setNameSupplyRn (name_supply {nsUniqs = us'}) `thenRn_`
let
import TysPrim ( charPrimTyCon, addrPrimTyCon, intPrimTyCon,
floatPrimTyCon, doublePrimTyCon )
import TysWiredIn ( intTyCon )
-import Name ( NamedThing(..), mkSysLocalName, nameSrcLoc )
+import Name ( NamedThing(..), mkSystemName, nameSrcLoc )
import NameSet
import UniqFM ( isNullUFM )
import UniqSet ( emptyUniqSet )
if opt_IgnoreAsserts then
getUniqRn `thenRn` \ uniq ->
let
- vname = mkSysLocalName uniq FSLIT("v")
+ vname = mkSystemName uniq FSLIT("v")
expr = HsLam ignorePredMatch
loc = nameSrcLoc vname
ignorePredMatch = mkSimpleMatch [WildPatIn, VarPatIn vname] (HsVar vname) placeHolderType loc
import PrelNames ( gHC_PRIM_Name, gHC_PRIM )
import Name ( Name {-instance NamedThing-},
- nameModule, isLocalName, nameIsLocalOrFrom
+ nameModule, isInternalName, nameIsLocalOrFrom
)
import NameEnv
import NameSet
\begin{code}
loadHomeInterface :: SDoc -> Name -> RnM d ModIface
loadHomeInterface doc_str name
- = ASSERT2( not (isLocalName name), ppr name <+> parens doc_str )
+ = ASSERT2( not (isInternalName name), ppr name <+> parens doc_str )
loadInterface doc_str (moduleName (nameModule name)) ImportBySystem
loadOrphanModules :: [ModuleName] -> RnM d ()
import TyCon ( visibleDataCons, isSynTyCon, getSynTyConDefn, tyConClass_maybe, tyConName )
import Class ( className )
import Name ( Name {-instance NamedThing-}, nameOccName,
- nameModule, isLocalName, NamedThing(..)
+ nameModule, isInternalName, NamedThing(..)
)
import NameEnv ( elemNameEnv, delFromNameEnv, lookupNameEnv )
import NameSet
iSlurp = slurped_names,
iVSlurp = vslurp })
avail
- = ASSERT2( not (isLocalName (availName avail)), ppr avail )
+ = ASSERT2( not (isInternalName (availName avail)), ppr avail )
ifaces { iDecls = (new_decls_map, n_slurped+1),
iSlurp = new_slurped_names,
iVSlurp = updateVSlurp vslurp (availName avail) }
import MkId ( seqId )
import Name ( Name, OccName, NamedThing(..),
nameOccName, nameRdrName,
- decode, mkLocalName, mkKnownKeyGlobal
+ decode, mkInternalName
)
import NameEnv ( NameEnv, lookupNameEnv, emptyNameEnv,
extendNameEnvList )
import VarEnv
import DataCon ( dataConWrapId )
import Maybes ( maybeToBool )
-import Name ( getOccName, isExternallyVisibleName, isDllName )
+import Name ( getOccName, isExternalName, isDllName )
import OccName ( occNameUserString )
import BasicTypes ( TopLevelFlag(..), isNotTopLevel, Arity )
import CmdLineOpts ( DynFlags, opt_RuntimeTypes )
-- Find how the given Id is used.
-- Externally visible things may be used any old how
lookupFVInfo fvs id
- | isExternallyVisibleName (idName id) = noBinderInfo
+ | isExternalName (idName id) = noBinderInfo
| otherwise = case lookupVarEnv fvs id of
Nothing -> noBinderInfo
Just (_,_,info) -> info
import TyCon ( TyCon, DataConDetails )
import Class ( Class, ClassOpItem )
import Name ( Name, NamedThing(..),
- getSrcLoc, mkLocalName, isLocalName, nameIsLocalOrFrom
+ getSrcLoc, mkInternalName, isInternalName, nameIsLocalOrFrom
)
import NameEnv ( NameEnv, lookupNameEnv, nameEnvElts, elemNameEnv,
extendNameEnvList, emptyNameEnv, plusNameEnv )
tcTyVars = gtv_var
})}
where
- lookup name | isLocalName name = Nothing
- | otherwise = lookupType hst pte name
+ lookup name | isInternalName name = Nothing
+ | otherwise = lookupType hst pte name
tcEnvClasses env = typeEnvClasses (tcGEnv env)
newLocalName :: Name -> NF_TcM Name
newLocalName name -- Make a clone
= tcGetUnique `thenNF_Tc` \ uniq ->
- returnNF_Tc (mkLocalName uniq (getOccName name) (getSrcLoc name))
+ returnNF_Tc (mkInternalName uniq (getOccName name) (getSrcLoc name))
\end{code}
Make a name for the dict fun for an instance decl.
It's a *local* name for the moment. The CoreTidy pass
-will globalise it.
+will externalise it.
\begin{code}
newDFunName :: Class -> [Type] -> SrcLoc -> NF_TcM Name
newDFunName clas (ty:_) loc
= tcGetUnique `thenNF_Tc` \ uniq ->
- returnNF_Tc (mkLocalName uniq (mkDFunOcc dfun_string) loc)
+ returnNF_Tc (mkInternalName uniq (mkDFunOcc dfun_string) loc)
where
-- Any string that is somewhat unique will do
dfun_string = occNameString (getOccName clas) ++ occNameString (getDFunTyKey ty)
import Module ( Module )
import Type ( typePrimRep )
import OccName ( mkForeignExportOcc )
-import Name ( NamedThing(..), mkGlobalName )
+import Name ( NamedThing(..), mkExternalName )
import TcType ( Type, tcSplitFunTys, tcSplitTyConApp_maybe,
tcSplitForAllTys,
isFFIArgumentTy, isFFIImportResultTy,
tcGetUnique `thenNF_Tc` \ uniq ->
let
- gnm = mkGlobalName uniq mod (mkForeignExportOcc (getOccName nm)) src_loc
+ gnm = mkExternalName uniq mod (mkForeignExportOcc (getOccName nm)) src_loc
id = setIdLocalExported (mkLocalId gnm sig_ty)
bind = VarMonoBind id rhs
in
import ForeignCall ( Safety(..) )
import FunDeps ( grow )
import PprType ( pprPred, pprSourceType, pprTheta, pprClassPred )
-import Name ( Name, NamedThing(..), setNameUnique, mkSysLocalName,
- mkLocalName, mkDerivedTyConOcc
+import Name ( Name, NamedThing(..), setNameUnique, mkSystemName,
+ mkInternalName, mkDerivedTyConOcc
)
import VarSet
import BasicTypes ( Boxity(Boxed) )
newTyVar :: Kind -> NF_TcM TcTyVar
newTyVar kind
= tcGetUnique `thenNF_Tc` \ uniq ->
- tcNewMutTyVar (mkSysLocalName uniq FSLIT("t")) kind VanillaTv
+ tcNewMutTyVar (mkSystemName uniq FSLIT("t")) kind VanillaTv
newTyVarTy :: Kind -> NF_TcM TcType
newTyVarTy kind
newHoleTyVarTy :: NF_TcM TcType
= tcGetUnique `thenNF_Tc` \ uniq ->
- tcNewMutTyVar (mkSysLocalName uniq FSLIT("h")) openTypeKind HoleTv `thenNF_Tc` \ tv ->
+ tcNewMutTyVar (mkSystemName uniq FSLIT("h")) openTypeKind HoleTv `thenNF_Tc` \ tv ->
returnNF_Tc (TyVarTy tv)
newTyVarTys :: Int -> Kind -> NF_TcM [TcType]
newKindVar :: NF_TcM TcKind
newKindVar
= tcGetUnique `thenNF_Tc` \ uniq ->
- tcNewMutTyVar (mkSysLocalName uniq FSLIT("k")) superKind VanillaTv `thenNF_Tc` \ kv ->
+ tcNewMutTyVar (mkSystemName uniq FSLIT("k")) superKind VanillaTv `thenNF_Tc` \ kv ->
returnNF_Tc (TyVarTy kv)
newKindVars :: Int -> NF_TcM [TcKind]
newBoxityVar :: NF_TcM TcKind
newBoxityVar
= tcGetUnique `thenNF_Tc` \ uniq ->
- tcNewMutTyVar (mkSysLocalName uniq FSLIT("bx")) superBoxity VanillaTv `thenNF_Tc` \ kv ->
+ tcNewMutTyVar (mkSystemName uniq FSLIT("bx")) superBoxity VanillaTv `thenNF_Tc` \ kv ->
returnNF_Tc (TyVarTy kv)
\end{code}
-- that two different tyvars will print the same way
-- in an error message. -dppr-debug will show up the difference
-- Better watch out for this. If worst comes to worst, just
- -- use mkSysLocalName.
+ -- use mkSystemName.
in
tcNewMutTyVar name (tyVarKind tyvar) tv_details
-- I dread to think what will happen if this gets out into an
-- interface file. Catastrophe likely. Major sigh.
- tc_name = mkLocalName (getUnique tv) (mkDerivedTyConOcc (getOccName tv)) noSrcLoc
+ tc_name = mkInternalName (getUnique tv) (mkDerivedTyConOcc (getOccName tv)) noSrcLoc
-- zonkTcTyVarToTyVar is applied to the *binding* occurrence
-- of a type variable, at the *end* of type checking. It changes
-- others:
import CmdLineOpts ( DynFlags, DynFlag( Opt_GlasgowExts ), dopt )
-import Name ( Name, NamedThing(..), mkLocalName, getSrcLoc )
+import Name ( Name, NamedThing(..), mkInternalName, getSrcLoc )
import OccName ( OccName, mkDictOcc )
import NameSet
import PrelNames -- Lots (e.g. in isFFIArgumentTy)
predHasFDs (ClassP cls _) = classHasFDs cls
mkPredName :: Unique -> SrcLoc -> SourceType -> Name
-mkPredName uniq loc (ClassP cls tys) = mkLocalName uniq (mkDictOcc (getOccName cls)) loc
-mkPredName uniq loc (IParam ip ty) = mkLocalName uniq (getOccName (ipNameName ip)) loc
+mkPredName uniq loc (ClassP cls tys) = mkInternalName uniq (mkDictOcc (getOccName cls)) loc
+mkPredName uniq loc (IParam ip ty) = mkInternalName uniq (getOccName (ipNameName ip)) loc
\end{code}
import TyCon ( TyCon, tyConTyVars, tyConDataCons_maybe,
tyConGenInfo, isNewTyCon, newTyConRep, isBoxedTupleTyCon
)
-import Name ( Name, mkSysLocalName )
+import Name ( Name, mkSystemName )
import CoreSyn ( mkLams, Expr(..), CoreExpr, AltCon(..),
mkConApp, Alt, mkTyApps, mkVarApps )
import CoreUtils ( exprArity )
-------------------
genericNames :: [Name]
-genericNames = [mkSysLocalName (mkBuiltinUnique i) (_PK_ ('g' : show i)) | i <- [1..]]
+genericNames = [mkSystemName (mkBuiltinUnique i) (_PK_ ('g' : show i)) | i <- [1..]]
(g1:g2:g3:_) = genericNames
mk_hs_lam pats body = HsPar (HsLam (mkSimpleMatch pats body placeHolderType builtinSrcLoc))
import VarEnv
import VarSet
-import Name ( NamedThing(..), mkLocalName, tidyOccName )
+import Name ( NamedThing(..), mkInternalName, tidyOccName )
import Class ( classTyCon )
import TyCon ( TyCon, isRecursiveTyCon, isPrimTyCon,
isUnboxedTupleTyCon, isUnLiftedTyCon,
where
subst' = extendVarEnv subst tyvar tyvar'
tyvar' = setTyVarName tyvar name'
- name' = mkLocalName (getUnique name) occ' noSrcLoc
+ name' = mkInternalName (getUnique name) occ' noSrcLoc
-- Note: make a *user* tyvar, so it printes nicely
-- Could extract src loc, but no need.
where