X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2FhsSyn%2FConvert.lhs;h=91d1b903f5dfc1db7719b3dac5ecbb9e4b749335;hb=18603f72fc20954b785a2bca81bed6c5571481f6;hp=b87c18c56dfd60c332bc83486a8b4a597a6d92f0;hpb=74fadd40c435b13da51695f0ec490e03ccce56e4;p=ghc-hetmet.git diff --git a/compiler/hsSyn/Convert.lhs b/compiler/hsSyn/Convert.lhs index b87c18c..91d1b90 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,22 @@ 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 } 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 @@ -568,10 +571,16 @@ if it isn't a literal string allCharLs :: [TH.Exp] -> Maybe String -- Note [Converting strings] -allCharLs (LitE (CharL c) : xs) - | Just cs <- allCharLs xs = Just (c:cs) -allCharLs [] = Just [] -allCharLs _ = Nothing +-- NB: only fire up this setup for a non-empty list, else +-- there's a danger of returning "" for [] :: [Int]! +allCharLs xs + = case xs of + LitE (CharL c) : ys -> go [c] ys + _ -> Nothing + where + go cs [] = Just (reverse cs) + go cs (LitE (CharL c) : ys) = go (c:cs) ys + go _ _ = Nothing cvtLit :: Lit -> CvtM HsLit cvtLit (IntPrimL i) = do { force i; return $ HsIntPrim i }