( "_scc_", ITscc )
]
+-- IMPORTANT: Keep this in synch with ParseIface.y's var_fs production! (SUP)
ghcExtensionKeywordsFM = listToUFM $
map (\ (x,y) -> (_PK_ x,y))
[ ( "forall", ITforall ),
RdrNameTyClDecl,
RdrNameRuleDecl,
RdrNameRuleBndr,
+ RdrNameDeprecation,
RdrNameHsRecordBinds,
RdrBinding(..),
type RdrNameTyClDecl = TyClDecl RdrName RdrNamePat
type RdrNameRuleBndr = RuleBndr RdrName
type RdrNameRuleDecl = RuleDecl RdrName RdrNamePat
+type RdrNameDeprecation = Deprecation RdrName
type RdrNameHsRecordBinds = HsRecordBinds RdrName RdrNamePat
'label' { ITlabel }
'dynamic' { ITdynamic }
'unsafe' { ITunsafe }
+ 'with' { ITwith }
'__interface' { ITinterface } -- interface keywords
'__export' { IT__export }
-----------------------------------------------------------------------------
-rules_and_deprecs :: { ([RdrNameRuleDecl], [(Maybe FAST_STRING, FAST_STRING)]) }
+rules_and_deprecs :: { ([RdrNameRuleDecl], [RdrNameDeprecation]) }
rules_and_deprecs : {- empty -} { ([], []) }
| rules_and_deprecs rule_or_deprec
{ let
in append2 $1 $2
}
-rule_or_deprec :: { ([RdrNameRuleDecl], [(Maybe FAST_STRING, FAST_STRING)]) }
+rule_or_deprec :: { ([RdrNameRuleDecl], [RdrNameDeprecation]) }
rule_or_deprec : pragma { case $1 of
POk _ (PRules rules) -> (rules,[])
POk _ (PDeprecs deprecs) -> ([],deprecs)
-----------------------------------------------------------------------------
-deprecs :: { [(Maybe FAST_STRING, FAST_STRING)] }
+deprecs :: { [RdrNameDeprecation] }
deprecs : {- empty -} { [] }
| deprecs deprec ';' { $2 : $1 }
-deprec :: { (Maybe FAST_STRING, FAST_STRING) }
-deprec : STRING { (Nothing, $1) }
- | deprec_name STRING { (Just $1, $2) }
+deprec :: { RdrNameDeprecation }
+deprec : STRING { DeprecMod $1 }
+ | deprec_name STRING { DeprecName $1 $2 }
-deprec_name :: { FAST_STRING }
- : var_fs { $1 }
- | tc_fs { $1 }
+deprec_name :: { RdrName }
+ : var_name { $1 }
+ | tc_name { $1 }
-----------------------------------------------------------------------------
| 'label' { SLIT("label") }
| 'dynamic' { SLIT("dynamic") }
| 'unsafe' { SLIT("unsafe") }
+ | 'with' { SLIT("with") }
qvar_fs :: { (EncodedFS, EncodedFS) }
: QVARID { $1 }
| PIdInfo [HsIdInfo RdrName]
| PType RdrNameHsType
| PRules [RdrNameRuleDecl]
- | PDeprecs [(Maybe FAST_STRING, FAST_STRING)]
+ | PDeprecs [RdrNameDeprecation]
mkConDecl name (ex_tvs, ex_ctxt) details loc = ConDecl name ex_tvs ex_ctxt details loc
}
%*********************************************************
\begin{code}
+newImportedGlobalName :: ModuleName -> OccName -> Module -> RnM d Name
newImportedGlobalName mod_name occ mod
= getNameSupplyRn `thenRn` \ (us, inst_ns, cache, ipcache) ->
let
= lookupModuleRn mod_name `thenRn` \ mod ->
newImportedGlobalName mod_name occ mod --(mkVanillaModule mod_name)
+mkImportedGlobalFromRdrName :: RdrName -> RnM d Name
mkImportedGlobalFromRdrName rdr_name
| isQual rdr_name
= mkImportedGlobalName (rdrNameModule rdr_name) (rdrNameOcc rdr_name)
type RenamedSig = Sig Name
type RenamedStmt = Stmt Name RenamedPat
type RenamedFixitySig = FixitySig Name
+type RenamedDeprecation = Deprecation Name
type RenamedClassOpPragmas = ClassOpPragmas Name
type RenamedClassPragmas = ClassPragmas Name
HsType(..), ConDecl(..), IE(..), ConDetails(..), Sig(..),
ForeignDecl(..), ForKind(..), isDynamic,
FixitySig(..), RuleDecl(..),
- isClassOpSig
+ isClassOpSig, Deprecation(..)
)
import BasicTypes ( Version, NewOrData(..), defaultFixity )
import RdrHsSyn ( RdrNameHsDecl, RdrNameInstDecl, RdrNameTyClDecl, RdrNameRuleDecl,
- extractHsTyRdrNames
+ extractHsTyRdrNames, RdrNameDeprecation
)
import RnEnv ( mkImportedGlobalName, newImportedBinder, mkImportedGlobalFromRdrName,
lookupOccRn, lookupImplicitOccRn,
FreeVars, emptyFVs
)
import RnMonad
-import RnHsSyn ( RenamedHsDecl )
+import RnHsSyn ( RenamedHsDecl, RenamedDeprecation )
import ParseIface ( parseIface, IfaceStuff(..) )
import FiniteMap ( FiniteMap, sizeFM, emptyFM, delFromFM, listToFM,
let
rd_decls = pi_decls iface
in
- foldlRn (loadDecl mod) (iDecls ifaces) rd_decls `thenRn` \ new_decls ->
- foldlRn (loadInstDecl mod) (iInsts ifaces) (pi_insts iface) `thenRn` \ new_insts ->
- (if (opt_IgnoreIfacePragmas)
+ foldlRn (loadDecl mod) (iDecls ifaces) rd_decls `thenRn` \ new_decls ->
+ foldlRn (loadInstDecl mod) (iInsts ifaces) (pi_insts iface) `thenRn` \ new_insts ->
+ (if opt_IgnoreIfacePragmas
then returnRn emptyBag
- else foldlRn (loadRule mod) (iRules ifaces) (pi_rules iface)) `thenRn` \ new_rules ->
- foldlRn (loadFixDecl mod_name) (iFixes ifaces) rd_decls `thenRn` \ new_fixities ->
- mapRn (loadExport this_mod_nm) (pi_exports iface) `thenRn` \ avails_s ->
+ else foldlRn (loadRule mod) (iRules ifaces) (pi_rules iface)) `thenRn` \ new_rules ->
+ (if opt_IgnoreIfacePragmas
+ then returnRn emptyNameEnv
+ else foldlRn (loadDeprec mod) (iDeprecs ifaces) (pi_deprecs iface)) `thenRn` \ new_deprecs ->
+ foldlRn (loadFixDecl mod_name) (iFixes ifaces) rd_decls `thenRn` \ new_fixities ->
+ mapRn (loadExport this_mod_nm) (pi_exports iface) `thenRn` \ avails_s ->
let
-- For an explicit user import, add to mod_map info about
-- the things the imported module depends on, extracted
new_ifaces = ifaces { iImpModInfo = mod_map2,
iDecls = new_decls,
iFixes = new_fixities,
+ iInsts = new_insts,
iRules = new_rules,
- iInsts = new_insts }
+ iDeprecs = new_deprecs }
in
setIfacesRn new_ifaces `thenRn_`
returnRn (mod, new_ifaces)
= setModuleRn (moduleName mod) $
mkImportedGlobalFromRdrName var `thenRn` \ var_name ->
returnRn ((unitNameSet var_name, (mod, RuleD decl)) `consBag` rules)
+
+loadDeprec :: Module -> DeprecationEnv -> RdrNameDeprecation -> RnM d DeprecationEnv
+loadDeprec mod deprec_env (DeprecMod txt)
+ = traceRn (text "module deprecation not yet implemented:" <+> ppr mod <> colon <+> ppr txt) `thenRn_`
+ returnRn deprec_env
+loadDeprec mod deprec_env (DeprecName rdr_name txt)
+ = setModuleRn (moduleName mod) $
+ mkImportedGlobalFromRdrName rdr_name `thenRn` \ name ->
+ traceRn (text "loaded deprecation for" <+> ppr name <> colon <+> ppr txt) `thenRn_`
+ returnRn (addToNameEnv deprec_env name (DeprecName name txt))
\end{code}
import HsSyn
import RdrHsSyn
-import RnHsSyn ( RenamedFixitySig )
+import RnHsSyn ( RenamedFixitySig, RenamedDeprecation )
import BasicTypes ( Version )
import SrcLoc ( noSrcLoc )
import ErrUtils ( addShortErrLocLine, addShortWarnLocLine,
-- We keep the whole fixity sig so that we
-- can report line-number info when there is a duplicate
-- fixity declaration
+
+--------------------------------
+type DeprecationEnv = NameEnv RenamedDeprecation
\end{code}
\begin{code}
pi_decls :: [(Version, RdrNameHsDecl)], -- Local definitions
pi_insts :: [RdrNameInstDecl], -- Local instance declarations
pi_rules :: [RdrNameRuleDecl], -- Rules
- pi_deprecs :: [(Maybe FAST_STRING, FAST_STRING)] -- Deprecations, the type is currently only a hack
+ pi_deprecs :: [RdrNameDeprecation] -- Deprecations
}
data InterfaceDetails
-- Each is 'gated' by the names that must be available before
-- this instance decl is needed.
- iRules :: Bag GatedDecl
+ iRules :: Bag GatedDecl,
-- Ditto transformation rules
+
+ iDeprecs :: DeprecationEnv
}
type GatedDecl = (NameSet, (Module, RdrNameHsDecl))
-- and we don't want thereby to try to suck it in!
iVSlurp = [],
iInsts = emptyBag,
- iRules = emptyBag
+ iRules = emptyBag,
+ iDeprecs = emptyNameEnv
}
-- mkUnboundName makes a place-holder Name; it shouldn't be looked at except possibly