+rep_inline :: Located Name -> InlineSpec -> SrcSpan
+ -> DsM [(SrcSpan, Core TH.DecQ)]
+rep_inline nm ispec loc
+ = do { nm1 <- lookupLOcc nm
+ ; (_, ispec1) <- rep_InlineSpec ispec
+ ; pragma <- repPragInl nm1 ispec1
+ ; return [(loc, pragma)]
+ }
+
+rep_specialise :: Located Name -> LHsType Name -> InlineSpec -> SrcSpan
+ -> DsM [(SrcSpan, Core TH.DecQ)]
+rep_specialise nm ty ispec loc
+ = do { nm1 <- lookupLOcc nm
+ ; ty1 <- repLTy ty
+ ; (hasSpec, ispec1) <- rep_InlineSpec ispec
+ ; pragma <- if hasSpec
+ then repPragSpecInl nm1 ty1 ispec1
+ else repPragSpec nm1 ty1
+ ; return [(loc, pragma)]
+ }
+
+-- extract all the information needed to build a TH.InlineSpec
+--
+rep_InlineSpec :: InlineSpec -> DsM (Bool, Core TH.InlineSpecQ)
+rep_InlineSpec (Inline (InlinePragma activation match) inline)
+ | Nothing <- activation1
+ = liftM ((,) False) $ repInlineSpecNoPhase inline1 match1
+ | Just (flag, phase) <- activation1
+ = liftM ((,) True) $ repInlineSpecPhase inline1 match1 flag phase
+ | otherwise = {- unreachable, but shuts up -W -} panic "rep_InlineSpec"
+ where
+ match1 = coreBool (rep_RuleMatchInfo match)
+ activation1 = rep_Activation activation
+ inline1 = coreBool inline
+
+ rep_RuleMatchInfo FunLike = False
+ rep_RuleMatchInfo ConLike = True
+
+ rep_Activation NeverActive = Nothing
+ rep_Activation AlwaysActive = Nothing
+ rep_Activation (ActiveBefore phase) = Just (coreBool False,
+ MkC $ mkIntExprInt phase)
+ rep_Activation (ActiveAfter phase) = Just (coreBool True,
+ MkC $ mkIntExprInt phase)