summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
10ffe4f)
In all cases the namespace is known from the context, so this saves 1
byte per variable binding/occurrence (a few percent per iface file).
isWiredInName, mkIPName,
mkExternalName, mkInternalName )
import NameSet ( NameSet, emptyNameSet, addListToNameSet )
isWiredInName, mkIPName,
mkExternalName, mkInternalName )
import NameSet ( NameSet, emptyNameSet, addListToNameSet )
-import OccName ( OccName, isTupleOcc_maybe, tcName, dataName, mapOccEnv,
+import OccName ( OccName, isTupleOcc_maybe, tcName, dataName, mapOccEnv, occNameFS,
lookupOccEnv, unitOccEnv, extendOccEnv, extendOccEnvList )
import PrelNames ( gHC_PRIM, pREL_TUP )
import Module ( Module, emptyModuleEnv,
lookupModuleEnv, extendModuleEnv_C )
lookupOccEnv, unitOccEnv, extendOccEnv, extendOccEnvList )
import PrelNames ( gHC_PRIM, pREL_TUP )
import Module ( Module, emptyModuleEnv,
lookupModuleEnv, extendModuleEnv_C )
+import UniqFM ( lookupUFM, addListToUFM )
+import FastString ( FastString )
import UniqSupply ( UniqSupply, splitUniqSupply, uniqFromSupply, uniqsFromSupply )
import FiniteMap ( emptyFM, lookupFM, addToFM )
import BasicTypes ( IPName(..), mapIPName )
import UniqSupply ( UniqSupply, splitUniqSupply, uniqFromSupply, uniqsFromSupply )
import FiniteMap ( emptyFM, lookupFM, addToFM )
import BasicTypes ( IPName(..), mapIPName )
%************************************************************************
\begin{code}
%************************************************************************
\begin{code}
-tcIfaceLclId :: OccName -> IfL Id
+tcIfaceLclId :: FastString -> IfL Id
tcIfaceLclId occ
= do { lcl <- getLclEnv
tcIfaceLclId occ
= do { lcl <- getLclEnv
- ; case (lookupOccEnv (if_id_env lcl) occ) of
+ ; case (lookupUFM (if_id_env lcl) occ) of
Just ty_var -> return ty_var
Nothing -> failIfM (text "Iface id out of scope: " <+> ppr occ)
}
Just ty_var -> return ty_var
Nothing -> failIfM (text "Iface id out of scope: " <+> ppr occ)
}
extendIfaceIdEnv :: [Id] -> IfL a -> IfL a
extendIfaceIdEnv ids thing_inside
= do { env <- getLclEnv
extendIfaceIdEnv :: [Id] -> IfL a -> IfL a
extendIfaceIdEnv ids thing_inside
= do { env <- getLclEnv
- ; let { id_env' = extendOccEnvList (if_id_env env) pairs
- ; pairs = [(getOccName id, id) | id <- ids] }
+ ; let { id_env' = addListToUFM (if_id_env env) pairs
+ ; pairs = [(occNameFS (getOccName id), id) | id <- ids] }
; setLclEnv (env { if_id_env = id_env' }) thing_inside }
; setLclEnv (env { if_id_env = id_env' }) thing_inside }
-tcIfaceTyVar :: OccName -> IfL TyVar
+tcIfaceTyVar :: FastString -> IfL TyVar
tcIfaceTyVar occ
= do { lcl <- getLclEnv
tcIfaceTyVar occ
= do { lcl <- getLclEnv
- ; case (lookupOccEnv (if_tv_env lcl) occ) of
+ ; case (lookupUFM (if_tv_env lcl) occ) of
Just ty_var -> return ty_var
Nothing -> failIfM (text "Iface type variable out of scope: " <+> ppr occ)
}
Just ty_var -> return ty_var
Nothing -> failIfM (text "Iface type variable out of scope: " <+> ppr occ)
}
extendIfaceTyVarEnv :: [TyVar] -> IfL a -> IfL a
extendIfaceTyVarEnv tyvars thing_inside
= do { env <- getLclEnv
extendIfaceTyVarEnv :: [TyVar] -> IfL a -> IfL a
extendIfaceTyVarEnv tyvars thing_inside
= do { env <- getLclEnv
- ; let { tv_env' = extendOccEnvList (if_tv_env env) pairs
- ; pairs = [(getOccName tv, tv) | tv <- tyvars] }
+ ; let { tv_env' = addListToUFM (if_tv_env env) pairs
+ ; pairs = [(occNameFS (getOccName tv), tv) | tv <- tyvars] }
; setLclEnv (env { if_tv_env = tv_env' }) thing_inside }
\end{code}
; setLclEnv (env { if_tv_env = tv_env' }) thing_inside }
\end{code}
import DataCon ( dataConName, dataConSig, dataConFieldLabels, dataConStrictMarks,
dataConTyCon, dataConIsInfix, isVanillaDataCon )
import Class ( FunDep, DefMeth, classExtraBigSig, classTyCon )
import DataCon ( dataConName, dataConSig, dataConFieldLabels, dataConStrictMarks,
dataConTyCon, dataConIsInfix, isVanillaDataCon )
import Class ( FunDep, DefMeth, classExtraBigSig, classTyCon )
-import OccName ( OccName, OccEnv, emptyOccEnv,
- lookupOccEnv, extendOccEnv, parenSymOcc,
+import OccName ( OccName, parenSymOcc, occNameFS,
OccSet, unionOccSets, unitOccSet )
OccSet, unionOccSets, unitOccSet )
+import UniqFM ( UniqFM, emptyUFM, addToUFM, lookupUFM )
import Name ( Name, NamedThing(..), nameOccName, isExternalName )
import CostCentre ( CostCentre, pprCostCentreCore )
import Literal ( Literal )
import Name ( Name, NamedThing(..), nameOccName, isExternalName )
import CostCentre ( CostCentre, pprCostCentreCore )
import Literal ( Literal )
| IfaceClass { ifCtxt :: IfaceContext, -- Context...
ifName :: OccName, -- Name of the class
ifTyVars :: [IfaceTvBndr], -- Type variables
| IfaceClass { ifCtxt :: IfaceContext, -- Context...
ifName :: OccName, -- Name of the class
ifTyVars :: [IfaceTvBndr], -- Type variables
- ifFDs :: [FunDep OccName], -- Functional dependencies
+ ifFDs :: [FunDep FastString], -- Functional dependencies
ifSigs :: [IfaceClassOp], -- Method signatures
ifRec :: RecFlag, -- Is newtype/datatype associated with the class recursive?
ifVrcs :: ArgVrcs -- ... and what are its argument variances ...
ifSigs :: [IfaceClassOp], -- Method signatures
ifRec :: RecFlag, -- Is newtype/datatype associated with the class recursive?
ifVrcs :: ArgVrcs -- ... and what are its argument variances ...
--------------------------------
data IfaceExpr
--------------------------------
data IfaceExpr
| IfaceExt IfaceExtName
| IfaceType IfaceType
| IfaceTuple Boxity [IfaceExpr] -- Saturated; type arguments omitted
| IfaceLam IfaceBndr IfaceExpr
| IfaceApp IfaceExpr IfaceExpr
| IfaceExt IfaceExtName
| IfaceType IfaceType
| IfaceTuple Boxity [IfaceExpr] -- Saturated; type arguments omitted
| IfaceLam IfaceBndr IfaceExpr
| IfaceApp IfaceExpr IfaceExpr
- | IfaceCase IfaceExpr OccName IfaceType [IfaceAlt]
+ | IfaceCase IfaceExpr FastString IfaceType [IfaceAlt]
| IfaceLet IfaceBinding IfaceExpr
| IfaceNote IfaceNote IfaceExpr
| IfaceLit Literal
| IfaceLet IfaceBinding IfaceExpr
| IfaceNote IfaceNote IfaceExpr
| IfaceLit Literal
| IfaceInlineMe
| IfaceCoreNote String
| IfaceInlineMe
| IfaceCoreNote String
-type IfaceAlt = (IfaceConAlt, [OccName], IfaceExpr)
+type IfaceAlt = (IfaceConAlt, [FastString], IfaceExpr)
-- Note: OccName, not IfaceBndr (and same with the case binder)
-- We reconstruct the kind/type of the thing from the context
-- thus saving bulk in interface files
-- Note: OccName, not IfaceBndr (and same with the case binder)
-- We reconstruct the kind/type of the thing from the context
-- thus saving bulk in interface files
(sel_tyvars, rho_ty) = splitForAllTys (idType sel_id)
op_ty = funResultTy rho_ty
(sel_tyvars, rho_ty) = splitForAllTys (idType sel_id)
op_ty = funResultTy rho_ty
- toIfaceFD (tvs1, tvs2) = (map getOccName tvs1, map getOccName tvs2)
+ toIfaceFD (tvs1, tvs2) = (map (occNameFS.getOccName) tvs1, map (occNameFS.getOccName) tvs2)
tyThingToIfaceDecl ext (ATyCon tycon)
| isSynTyCon tycon
tyThingToIfaceDecl ext (ATyCon tycon)
| isSynTyCon tycon
toIfaceExpr ext (Type ty) = IfaceType (toIfaceType ext ty)
toIfaceExpr ext (Lam x b) = IfaceLam (toIfaceBndr ext x) (toIfaceExpr ext b)
toIfaceExpr ext (App f a) = toIfaceApp ext f [a]
toIfaceExpr ext (Type ty) = IfaceType (toIfaceType ext ty)
toIfaceExpr ext (Lam x b) = IfaceLam (toIfaceBndr ext x) (toIfaceExpr ext b)
toIfaceExpr ext (App f a) = toIfaceApp ext f [a]
-toIfaceExpr ext (Case s x ty as) = IfaceCase (toIfaceExpr ext s) (getOccName x) (toIfaceType ext ty) (map (toIfaceAlt ext) as)
+toIfaceExpr ext (Case s x ty as) = IfaceCase (toIfaceExpr ext s) (occNameFS (getOccName x)) (toIfaceType ext ty) (map (toIfaceAlt ext) as)
toIfaceExpr ext (Let b e) = IfaceLet (toIfaceBind ext b) (toIfaceExpr ext e)
toIfaceExpr ext (Note n e) = IfaceNote (toIfaceNote ext n) (toIfaceExpr ext e)
toIfaceExpr ext (Let b e) = IfaceLet (toIfaceBind ext b) (toIfaceExpr ext e)
toIfaceExpr ext (Note n e) = IfaceNote (toIfaceNote ext n) (toIfaceExpr ext e)
toIfaceBind ext (Rec prs) = IfaceRec [(toIfaceIdBndr ext b, toIfaceExpr ext r) | (b,r) <- prs]
---------------------
toIfaceBind ext (Rec prs) = IfaceRec [(toIfaceIdBndr ext b, toIfaceExpr ext r) | (b,r) <- prs]
---------------------
-toIfaceAlt ext (c,bs,r) = (toIfaceCon c, map getOccName bs, toIfaceExpr ext r)
+toIfaceAlt ext (c,bs,r) = (toIfaceCon c, map (occNameFS.getOccName) bs, toIfaceExpr ext r)
---------------------
toIfaceCon (DataAlt dc) | isTupleTyCon tc = IfaceTupleAlt (tupleTyConBoxity tc)
---------------------
toIfaceCon (DataAlt dc) | isTupleTyCon tc = IfaceTupleAlt (tupleTyConBoxity tc)
| Just fcall <- isFCallId_maybe v = IfaceFCall fcall (toIfaceType ext (idType v))
-- Foreign calls have special syntax
| isExternalName name = IfaceExt (ext name)
| Just fcall <- isFCallId_maybe v = IfaceFCall fcall (toIfaceType ext (idType v))
-- Foreign calls have special syntax
| isExternalName name = IfaceExt (ext name)
- | otherwise = IfaceLcl (nameOccName name)
+ | otherwise = IfaceLcl (occNameFS (nameOccName name))
where
name = idName v
\end{code}
where
name = idName v
\end{code}
\begin{code}
------------------------------------
\begin{code}
------------------------------------
-type EqEnv = OccEnv OccName -- Tracks the mapping from L-variables to R-variables
+type EqEnv = UniqFM FastString -- Tracks the mapping from L-variables to R-variables
-eqIfOcc :: EqEnv -> OccName -> OccName -> IfaceEq
-eqIfOcc env n1 n2 = case lookupOccEnv env n1 of
+eqIfOcc :: EqEnv -> FastString -> FastString -> IfaceEq
+eqIfOcc env n1 n2 = case lookupUFM env n1 of
Just n1 -> bool (n1 == n2)
Nothing -> bool (n1 == n2)
Just n1 -> bool (n1 == n2)
Nothing -> bool (n1 == n2)
-extendEqEnv :: EqEnv -> OccName -> OccName -> EqEnv
+extendEqEnv :: EqEnv -> FastString -> FastString -> EqEnv
extendEqEnv env n1 n2 | n1 == n2 = env
extendEqEnv env n1 n2 | n1 == n2 = env
- | otherwise = extendOccEnv env n1 n2
+ | otherwise = addToUFM env n1 n2
-emptyEqEnv = emptyOccEnv
------------------------------------
type ExtEnv bndr = EqEnv -> bndr -> bndr -> (EqEnv -> IfaceEq) -> IfaceEq
------------------------------------
type ExtEnv bndr = EqEnv -> bndr -> bndr -> (EqEnv -> IfaceEq) -> IfaceEq
-eq_ifNakedBndr :: ExtEnv OccName
+eq_ifNakedBndr :: ExtEnv FastString
eq_ifBndr :: ExtEnv IfaceBndr
eq_ifTvBndr :: ExtEnv IfaceTvBndr
eq_ifIdBndr :: ExtEnv IfaceIdBndr
eq_ifBndr :: ExtEnv IfaceBndr
eq_ifTvBndr :: ExtEnv IfaceTvBndr
eq_ifIdBndr :: ExtEnv IfaceIdBndr
eq_ifBndrs :: ExtEnv [IfaceBndr]
eq_ifIdBndrs :: ExtEnv [IfaceIdBndr]
eq_ifTvBndrs :: ExtEnv [IfaceTvBndr]
eq_ifBndrs :: ExtEnv [IfaceBndr]
eq_ifIdBndrs :: ExtEnv [IfaceIdBndr]
eq_ifTvBndrs :: ExtEnv [IfaceTvBndr]
-eq_ifNakedBndrs :: ExtEnv [OccName]
+eq_ifNakedBndrs :: ExtEnv [FastString]
eq_ifBndrs = eq_bndrs_with eq_ifBndr
eq_ifIdBndrs = eq_bndrs_with eq_ifIdBndr
eq_ifTvBndrs = eq_bndrs_with eq_ifTvBndr
eq_ifBndrs = eq_bndrs_with eq_ifBndr
eq_ifIdBndrs = eq_bndrs_with eq_ifIdBndr
eq_ifTvBndrs = eq_bndrs_with eq_ifTvBndr
import TyCon ( TyCon, isTupleTyCon, tyConArity, tupleTyConBoxity, tyConName )
import Var ( isId, tyVarKind, idType )
import TysWiredIn ( listTyConName, parrTyConName, tupleTyCon, intTyConName, charTyConName, boolTyConName )
import TyCon ( TyCon, isTupleTyCon, tyConArity, tupleTyConBoxity, tyConName )
import Var ( isId, tyVarKind, idType )
import TysWiredIn ( listTyConName, parrTyConName, tupleTyCon, intTyConName, charTyConName, boolTyConName )
-import OccName ( OccName, parenSymOcc )
+import OccName ( OccName, parenSymOcc, occNameFS )
import Name ( Name, getName, getOccName, nameModule, nameOccName,
wiredInNameTyThing_maybe )
import Module ( Module )
import Name ( Name, getName, getOccName, nameModule, nameOccName,
wiredInNameTyThing_maybe )
import Module ( Module )
\begin{code}
data IfaceBndr -- Local (non-top-level) binders
\begin{code}
data IfaceBndr -- Local (non-top-level) binders
- = IfaceIdBndr IfaceIdBndr
- | IfaceTvBndr IfaceTvBndr
+ = IfaceIdBndr {-# UNPACK #-} !IfaceIdBndr
+ | IfaceTvBndr {-# UNPACK #-} !IfaceTvBndr
-type IfaceIdBndr = (OccName, IfaceType) -- OccName, because always local
-type IfaceTvBndr = (OccName, IfaceKind)
+type IfaceIdBndr = (FastString, IfaceType)
+type IfaceTvBndr = (FastString, IfaceKind)
-------------------------------
type IfaceKind = Kind -- Re-use the Kind type, but no KindVars in it
data IfaceType
-------------------------------
type IfaceKind = Kind -- Re-use the Kind type, but no KindVars in it
data IfaceType
- = IfaceTyVar OccName -- Type variable only, not tycon
+ = IfaceTyVar FastString -- Type variable only, not tycon
| IfaceAppTy IfaceType IfaceType
| IfaceForAllTy IfaceTvBndr IfaceType
| IfacePredTy IfacePredType
| IfaceAppTy IfaceType IfaceType
| IfaceForAllTy IfaceTvBndr IfaceType
| IfacePredTy IfacePredType
\begin{code}
----------------
\begin{code}
----------------
-toIfaceTvBndr tyvar = (getOccName tyvar, tyVarKind tyvar)
-toIfaceIdBndr ext id = (getOccName id, toIfaceType ext (idType id))
+toIfaceTvBndr tyvar = (occNameFS (getOccName tyvar), tyVarKind tyvar)
+toIfaceIdBndr ext id = (occNameFS (getOccName id), toIfaceType ext (idType id))
toIfaceTvBndrs tyvars = map toIfaceTvBndr tyvars
toIfaceBndr ext var
toIfaceTvBndrs tyvars = map toIfaceTvBndr tyvars
toIfaceBndr ext var
---------------------
toIfaceType :: (Name -> IfaceExtName) -> Type -> IfaceType
-- Synonyms are retained in the interface type
---------------------
toIfaceType :: (Name -> IfaceExtName) -> Type -> IfaceType
-- Synonyms are retained in the interface type
-toIfaceType ext (TyVarTy tv) = IfaceTyVar (getOccName tv)
+toIfaceType ext (TyVarTy tv) = IfaceTyVar (occNameFS (getOccName tv))
toIfaceType ext (AppTy t1 t2) = IfaceAppTy (toIfaceType ext t1) (toIfaceType ext t2)
toIfaceType ext (FunTy t1 t2) = IfaceFunTy (toIfaceType ext t1) (toIfaceType ext t2)
toIfaceType ext (TyConApp tc tys) = IfaceTyConApp (toIfaceTyCon ext tc) (toIfaceTypes ext tys)
toIfaceType ext (AppTy t1 t2) = IfaceAppTy (toIfaceType ext t1) (toIfaceType ext t2)
toIfaceType ext (FunTy t1 t2) = IfaceFunTy (toIfaceType ext t1) (toIfaceType ext t2)
toIfaceType ext (TyConApp tc tys) = IfaceTyConApp (toIfaceTyCon ext tc) (toIfaceTypes ext tys)
import Name ( Name, nameModule, nameIsLocalOrFrom, isWiredInName,
wiredInNameTyThing_maybe, nameParent )
import NameEnv
import Name ( Name, nameModule, nameIsLocalOrFrom, isWiredInName,
wiredInNameTyThing_maybe, nameParent )
import NameEnv
-import OccName ( OccName )
+import OccName ( OccName, mkVarOccFS, mkTyVarOcc )
+import FastString ( FastString )
import Module ( Module, lookupModuleEnv )
import UniqSupply ( initUs_ )
import Outputable
import ErrUtils ( Message )
import Maybes ( MaybeErr(..) )
import SrcLoc ( noSrcLoc )
import Module ( Module, lookupModuleEnv )
import UniqSupply ( initUs_ )
import Outputable
import ErrUtils ( Message )
import Maybes ( MaybeErr(..) )
import SrcLoc ( noSrcLoc )
-import Util ( zipWithEqual, dropList, equalLength )
+import Util ( zipWithEqual, equalLength, splitAtList )
import DynFlags ( DynFlag(..), isOneShot )
\end{code}
import DynFlags ( DynFlag(..), isOneShot )
\end{code}
tcIfaceExpr (IfaceCase scrut case_bndr ty alts)
= tcIfaceExpr scrut `thenM` \ scrut' ->
tcIfaceExpr (IfaceCase scrut case_bndr ty alts)
= tcIfaceExpr scrut `thenM` \ scrut' ->
- newIfaceName case_bndr `thenM` \ case_bndr_name ->
+ newIfaceName (mkVarOccFS case_bndr) `thenM` \ case_bndr_name ->
let
scrut_ty = exprType scrut'
case_bndr' = mkLocalId case_bndr_name scrut_ty
let
scrut_ty = exprType scrut'
case_bndr' = mkLocalId case_bndr_name scrut_ty
-- A case alternative is made quite a bit more complicated
-- by the fact that we omit type annotations because we can
-- work them out. True enough, but its not that easy!
-- A case alternative is made quite a bit more complicated
-- by the fact that we omit type annotations because we can
-- work them out. True enough, but its not that easy!
-tcIfaceAlt (tycon, inst_tys) (IfaceDataAlt data_occ, arg_occs, rhs)
+tcIfaceAlt (tycon, inst_tys) (IfaceDataAlt data_occ, arg_strs, rhs)
= do { let tycon_mod = nameModule (tyConName tycon)
; con <- tcIfaceDataCon (ExtPkg tycon_mod data_occ)
; ASSERT2( con `elem` tyConDataCons tycon,
ppr con $$ ppr tycon $$ ppr (tyConDataCons tycon) )
if isVanillaDataCon con then
= do { let tycon_mod = nameModule (tyConName tycon)
; con <- tcIfaceDataCon (ExtPkg tycon_mod data_occ)
; ASSERT2( con `elem` tyConDataCons tycon,
ppr con $$ ppr tycon $$ ppr (tyConDataCons tycon) )
if isVanillaDataCon con then
- tcVanillaAlt con inst_tys arg_occs rhs
+ tcVanillaAlt con inst_tys arg_strs rhs
else
do { -- General case
else
do { -- General case
- arg_names <- newIfaceNames arg_occs
+ let (tyvar_strs, id_strs) = splitAtList (dataConTyVars con) arg_strs
+ ; tyvar_names <- mapM (newIfaceName . mkTyVarOcc) tyvar_strs
+ ; id_names <- mapM (newIfaceName . mkVarOccFS) id_strs
; let tyvars = [ mkTyVar name (tyVarKind tv)
; let tyvars = [ mkTyVar name (tyVarKind tv)
- | (name,tv) <- arg_names `zip` dataConTyVars con]
+ | (name,tv) <- tyvar_names `zip` dataConTyVars con ]
arg_tys = dataConInstArgTys con (mkTyVarTys tyvars)
arg_tys = dataConInstArgTys con (mkTyVarTys tyvars)
- id_names = dropList tyvars arg_names
arg_ids = ASSERT2( equalLength id_names arg_tys,
arg_ids = ASSERT2( equalLength id_names arg_tys,
- ppr (con, arg_names, rhs) $$ ppr tyvars $$ ppr arg_tys )
+ ppr (con, tyvar_names++id_names, rhs) $$ ppr tyvars $$ ppr arg_tys )
zipWith mkLocalId id_names arg_tys
Just refine = coreRefineTys con tyvars (mkTyConApp tycon inst_tys)
zipWith mkLocalId id_names arg_tys
Just refine = coreRefineTys con tyvars (mkTyConApp tycon inst_tys)
do { let [data_con] = tyConDataCons tycon
; tcVanillaAlt data_con inst_tys arg_occs rhs }
do { let [data_con] = tyConDataCons tycon
; tcVanillaAlt data_con inst_tys arg_occs rhs }
-tcVanillaAlt data_con inst_tys arg_occs rhs
- = do { arg_names <- newIfaceNames arg_occs
+tcVanillaAlt data_con inst_tys arg_strs rhs
+ = do { arg_names <- newIfaceNames (map mkVarOccFS arg_strs)
; let arg_tys = dataConInstArgTys data_con inst_tys
; let arg_ids = ASSERT2( equalLength arg_names arg_tys,
; let arg_tys = dataConInstArgTys data_con inst_tys
; let arg_ids = ASSERT2( equalLength arg_names arg_tys,
- ppr data_con <+> ppr inst_tys <+> ppr arg_occs $$ ppr rhs )
+ ppr data_con <+> ppr inst_tys <+> ppr arg_strs $$ ppr rhs )
zipWith mkLocalId arg_names arg_tys
; rhs' <- extendIfaceIdEnv arg_ids (tcIfaceExpr rhs)
; returnM (DataAlt data_con, arg_ids, rhs') }
zipWith mkLocalId arg_names arg_tys
; rhs' <- extendIfaceIdEnv arg_ids (tcIfaceExpr rhs)
; returnM (DataAlt data_con, arg_ids, rhs') }
thing_inside (b':bs')
-----------------------
thing_inside (b':bs')
-----------------------
-bindIfaceId :: (OccName, IfaceType) -> (Id -> IfL a) -> IfL a
+bindIfaceId :: IfaceIdBndr -> (Id -> IfL a) -> IfL a
bindIfaceId (occ, ty) thing_inside
bindIfaceId (occ, ty) thing_inside
- = do { name <- newIfaceName occ
+ = do { name <- newIfaceName (mkVarOccFS occ)
; ty' <- tcIfaceType ty
; let { id = mkLocalId name ty' }
; extendIfaceIdEnv [id] (thing_inside id) }
; ty' <- tcIfaceType ty
; let { id = mkLocalId name ty' }
; extendIfaceIdEnv [id] (thing_inside id) }
-bindIfaceIds :: [(OccName, IfaceType)] -> ([Id] -> IfL a) -> IfL a
+bindIfaceIds :: [IfaceIdBndr] -> ([Id] -> IfL a) -> IfL a
bindIfaceIds bndrs thing_inside
bindIfaceIds bndrs thing_inside
- = do { names <- newIfaceNames occs
+ = do { names <- newIfaceNames (map mkVarOccFS occs)
; tys' <- mappM tcIfaceType tys
; let { ids = zipWithEqual "tcCoreValBndr" mkLocalId names tys' }
; extendIfaceIdEnv ids (thing_inside ids) }
; tys' <- mappM tcIfaceType tys
; let { ids = zipWithEqual "tcCoreValBndr" mkLocalId names tys' }
; extendIfaceIdEnv ids (thing_inside ids) }
-newExtCoreBndr :: (OccName, IfaceType) -> IfL Id
-newExtCoreBndr (occ, ty)
+newExtCoreBndr :: IfaceIdBndr -> IfL Id
+newExtCoreBndr (var, ty)
= do { mod <- getIfModule
= do { mod <- getIfModule
- ; name <- newGlobalBinder mod occ Nothing noSrcLoc
+ ; name <- newGlobalBinder mod (mkVarOccFS var) Nothing noSrcLoc
; ty' <- tcIfaceType ty
; return (mkLocalId name ty') }
-----------------------
bindIfaceTyVar :: IfaceTvBndr -> (TyVar -> IfL a) -> IfL a
bindIfaceTyVar (occ,kind) thing_inside
; ty' <- tcIfaceType ty
; return (mkLocalId name ty') }
-----------------------
bindIfaceTyVar :: IfaceTvBndr -> (TyVar -> IfL a) -> IfL a
bindIfaceTyVar (occ,kind) thing_inside
- = do { name <- newIfaceName occ
+ = do { name <- newIfaceName (mkTyVarOcc occ)
; let tyvar = mk_iface_tyvar name kind
; extendIfaceTyVarEnv [tyvar] (thing_inside tyvar) }
bindIfaceTyVars :: [IfaceTvBndr] -> ([TyVar] -> IfL a) -> IfL a
bindIfaceTyVars bndrs thing_inside
; let tyvar = mk_iface_tyvar name kind
; extendIfaceTyVarEnv [tyvar] (thing_inside tyvar) }
bindIfaceTyVars :: [IfaceTvBndr] -> ([TyVar] -> IfL a) -> IfL a
bindIfaceTyVars bndrs thing_inside
- = do { names <- newIfaceNames occs
+ = do { names <- newIfaceNames (map mkTyVarOcc occs)
; let tyvars = zipWith mk_iface_tyvar names kinds
; extendIfaceTyVarEnv tyvars (thing_inside tyvars) }
where
; let tyvars = zipWith mk_iface_tyvar names kinds
; extendIfaceTyVarEnv tyvars (thing_inside tyvars) }
where
-- same as the module being compiled, and Iface syntax only
-- has OccNames in binding positions
-- same as the module being compiled, and Iface syntax only
-- has OccNames in binding positions
+qd_occ :: { FastString }
: var_occ { $1 }
| d_occ { $1 }
: var_occ { $1 }
| d_occ { $1 }
aexp :: { IfaceExpr }
: var_occ { IfaceLcl $1 }
aexp :: { IfaceExpr }
: var_occ { IfaceLcl $1 }
- | modid '.' qd_occ { IfaceExt (ExtPkg $1 $3) }
+ | modid '.' qd_occ { IfaceExt (ExtPkg $1 (mkVarOccFS $3)) }
| lit { IfaceLit $1 }
| '(' exp ')' { $2 }
| lit { IfaceLit $1 }
| '(' exp ')' { $2 }
| '(' CHAR '::' aty ')' { MachChar $2 }
| '(' STRING '::' aty ')' { MachStr (mkFastString $2) }
| '(' CHAR '::' aty ')' { MachChar $2 }
| '(' STRING '::' aty ')' { MachStr (mkFastString $2) }
-tv_occ :: { OccName }
- : NAME { mkOccName tvName $1 }
+tv_occ :: { FastString }
+ : NAME { mkFastString $1 }
-var_occ :: { OccName }
- : NAME { mkVarOcc $1 }
+var_occ :: { FastString }
+ : NAME { mkFastString $1 }
-- Data constructor occurrence in an expression;
-- use the varName because that's the worker Id
-- Data constructor occurrence in an expression;
-- use the varName because that's the worker Id
-d_occ :: { OccName }
- : CNAME { mkVarOcc $1 }
+d_occ :: { FastString }
+ : CNAME { mkFastString $1 }
-- are very limited (see the productions for 'ty', so the translation
-- isn't hard
toHsType :: IfaceType -> LHsType RdrName
-- are very limited (see the productions for 'ty', so the translation
-- isn't hard
toHsType :: IfaceType -> LHsType RdrName
-toHsType (IfaceTyVar v) = noLoc $ HsTyVar (mkRdrUnqual v)
+toHsType (IfaceTyVar v) = noLoc $ HsTyVar (mkRdrUnqual (mkTyVarOcc v))
toHsType (IfaceAppTy t1 t2) = noLoc $ HsAppTy (toHsType t1) (toHsType t2)
toHsType (IfaceFunTy t1 t2) = noLoc $ HsFunTy (toHsType t1) (toHsType t2)
toHsType (IfaceTyConApp (IfaceTc tc) ts) = foldl mkHsAppTy (noLoc $ HsTyVar (ifaceExtRdrName tc)) (map toHsType ts)
toHsType (IfaceForAllTy tv t) = add_forall (toHsTvBndr tv) (toHsType t)
toHsTvBndr :: IfaceTvBndr -> LHsTyVarBndr RdrName
toHsType (IfaceAppTy t1 t2) = noLoc $ HsAppTy (toHsType t1) (toHsType t2)
toHsType (IfaceFunTy t1 t2) = noLoc $ HsFunTy (toHsType t1) (toHsType t2)
toHsType (IfaceTyConApp (IfaceTc tc) ts) = foldl mkHsAppTy (noLoc $ HsTyVar (ifaceExtRdrName tc)) (map toHsType ts)
toHsType (IfaceForAllTy tv t) = add_forall (toHsTvBndr tv) (toHsType t)
toHsTvBndr :: IfaceTvBndr -> LHsTyVarBndr RdrName
-toHsTvBndr (tv,k) = noLoc $ KindedTyVar (mkRdrUnqual tv) k
+toHsTvBndr (tv,k) = noLoc $ KindedTyVar (mkRdrUnqual (mkTyVarOcc tv)) k
ifaceExtRdrName :: IfaceExtName -> RdrName
ifaceExtRdrName (ExtPkg mod occ) = mkOrig mod occ
ifaceExtRdrName :: IfaceExtName -> RdrName
ifaceExtRdrName (ExtPkg mod occ) = mkOrig mod occ
import Name ( Name )
import NameEnv
import NameSet ( NameSet, unionNameSets, DefUses )
import Name ( Name )
import NameEnv
import NameSet ( NameSet, unionNameSets, DefUses )
-import OccName ( OccEnv )
import Var ( Id, TyVar )
import VarEnv ( TidyEnv )
import Module
import SrcLoc ( SrcSpan, SrcLoc, Located, srcSpanStart )
import VarSet ( IdSet )
import ErrUtils ( Messages, Message )
import Var ( Id, TyVar )
import VarEnv ( TidyEnv )
import Module
import SrcLoc ( SrcSpan, SrcLoc, Located, srcSpanStart )
import VarSet ( IdSet )
import ErrUtils ( Messages, Message )
+import UniqFM ( UniqFM )
import UniqSupply ( UniqSupply )
import BasicTypes ( IPName )
import Util ( thenCmp )
import UniqSupply ( UniqSupply )
import BasicTypes ( IPName )
import Util ( thenCmp )
-- .hi file, or GHCi state, or ext core
-- plus which bit is currently being examined
-- .hi file, or GHCi state, or ext core
-- plus which bit is currently being examined
- if_tv_env :: OccEnv TyVar, -- Nested tyvar bindings
- if_id_env :: OccEnv Id -- Nested id binding
+ if_tv_env :: UniqFM TyVar, -- Nested tyvar bindings
+ if_id_env :: UniqFM Id -- Nested id binding