X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=blobdiff_plain;f=compiler%2FhsSyn%2FConvert.lhs;h=2a4fa724b43f3fffb20480d621ad95f7818e6084;hp=56ec2d763d44a46bbcc29904c82106633b5d9fb1;hb=127d259f77deda6f03c2213c3dacba0354b37322;hpb=fb02349ca1daf3eaedeff076bf7cedb5923b82f7 diff --git a/compiler/hsSyn/Convert.lhs b/compiler/hsSyn/Convert.lhs index 56ec2d7..2a4fa72 100644 --- a/compiler/hsSyn/Convert.lhs +++ b/compiler/hsSyn/Convert.lhs @@ -19,6 +19,7 @@ import qualified OccName import OccName import SrcLoc import Type +import Coercion import TysWiredIn import BasicTypes as Hs import ForeignCall @@ -394,20 +395,23 @@ cvtPragmaD (SpecialiseP nm ty opt_ispec) ; ty' <- cvtType ty ; return $ SpecSig nm' ty' (cvtInlineSpec opt_ispec) } -cvtInlineSpec :: Maybe TH.InlineSpec -> Hs.InlineSpec +cvtInlineSpec :: Maybe TH.InlineSpec -> Hs.InlinePragma cvtInlineSpec Nothing - = defaultInlineSpec + = defaultInlinePragma cvtInlineSpec (Just (TH.InlineSpec inline conlike opt_activation)) - = mkInlineSpec opt_activation' matchinfo inline + = InlinePragma { inl_act = opt_activation', inl_rule = matchinfo + , inl_inline = inline, inl_sat = Nothing } where matchinfo = cvtRuleMatchInfo conlike - opt_activation' = fmap cvtActivation opt_activation + opt_activation' = cvtActivation opt_activation cvtRuleMatchInfo False = FunLike cvtRuleMatchInfo True = ConLike - cvtActivation (False, phase) = ActiveBefore phase - cvtActivation (True , phase) = ActiveAfter phase + cvtActivation Nothing | inline = AlwaysActive + | otherwise = NeverActive + cvtActivation (Just (False, phase)) = ActiveBefore phase + cvtActivation (Just (True , phase)) = ActiveAfter phase --------------------------------------------------- -- Declarations @@ -637,7 +641,7 @@ cvtTvs tvs = mapM cvt_tv tvs cvt_tv :: TH.TyVarBndr -> CvtM (LHsTyVarBndr RdrName) cvt_tv (TH.PlainTV nm) = do { nm' <- tName nm - ; returnL $ UserTyVar nm' + ; returnL $ UserTyVar nm' placeHolderKind } cvt_tv (TH.KindedTV nm ki) = do { nm' <- tName nm @@ -840,14 +844,7 @@ isBuiltInOcc ctxt_ns occ mk_uniq_occ :: OccName.NameSpace -> String -> Int# -> OccName.OccName mk_uniq_occ ns occ uniq = OccName.mkOccName ns (occ ++ '[' : shows (mk_uniq uniq) "]") - -- The idea here is to make a name that - -- a) the user could not possibly write, and - -- b) cannot clash with another NameU - -- Previously I generated an Exact RdrName with mkInternalName. - -- This works fine for local binders, but does not work at all for - -- top-level binders, which must have External Names, since they are - -- rapidly baked into data constructors and the like. Baling out - -- and generating an unqualified RdrName here is the simple solution + -- See Note [Unique OccNames from Template Haskell] -- The packing and unpacking is rather turgid :-( mk_occ :: OccName.NameSpace -> String -> OccName.OccName @@ -868,3 +865,17 @@ mk_uniq :: Int# -> Unique mk_uniq u = mkUniqueGrimily (I# u) \end{code} +Note [Unique OccNames from Template Haskell] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +The idea here is to make a name that + a) the user could not possibly write (it has a "[" + and letters or digits from the unique) + b) cannot clash with another NameU +Previously I generated an Exact RdrName with mkInternalName. This +works fine for local binders, but does not work at all for top-level +binders, which must have External Names, since they are rapidly baked +into data constructors and the like. Baling out and generating an +unqualified RdrName here is the simple solution + +See also Note [Suppressing uniques in OccNames] in OccName, which +suppresses the unique when opt_SuppressUniques is on.