-parse_ccall_impent :: String -> String -> Maybe (FastString, CImportSpec)
-parse_ccall_impent nm s
- = case lex_ccall_impent s of
- Just ["dynamic"] -> Just (nilFS, CFunction DynamicTarget)
- Just ["wrapper"] -> Just (nilFS, CWrapper)
- Just ("static":ts) -> parse_ccall_impent_static nm ts
- Just ts -> parse_ccall_impent_static nm ts
- Nothing -> Nothing
-
-parse_ccall_impent_static :: String
- -> [String]
- -> Maybe (FastString, CImportSpec)
-parse_ccall_impent_static nm ts
- = let ts' = case ts of
- [ "&", cid] -> [ cid]
- [fname, "&" ] -> [fname ]
- [fname, "&", cid] -> [fname, cid]
- _ -> ts
- in case ts' of
- [ cid] | is_cid cid -> Just (nilFS, mk_cid cid)
- [fname, cid] | is_cid cid -> Just (mkFastString fname, mk_cid cid)
- [ ] -> Just (nilFS, mk_cid nm)
- [fname ] -> Just (mkFastString fname, mk_cid nm)
- _ -> Nothing
- where is_cid :: String -> Bool
- is_cid x = all (/= '.') x && (isAlpha (head x) || head x == '_')
- mk_cid :: String -> CImportSpec
- mk_cid = CFunction . StaticTarget . mkFastString
-
-lex_ccall_impent :: String -> Maybe [String]
-lex_ccall_impent "" = Just []
-lex_ccall_impent ('&':xs) = fmap ("&":) $ lex_ccall_impent xs
-lex_ccall_impent (' ':xs) = lex_ccall_impent xs
-lex_ccall_impent ('\t':xs) = lex_ccall_impent xs
-lex_ccall_impent xs = case span is_valid xs of
- ("", _) -> Nothing
- (t, xs') -> fmap (t:) $ lex_ccall_impent xs'
- where is_valid :: Char -> Bool
- is_valid c = isAscii c && (isAlphaNum c || c `elem` "._")
+------------------------------------------
+-- Pragmas
+------------------------------------------
+
+cvtPragmaD :: Pragma -> CvtM (Sig RdrName)
+cvtPragmaD (InlineP nm ispec)
+ = do { nm' <- vNameL nm
+ ; return $ InlineSig nm' (cvtInlineSpec (Just ispec)) }
+
+cvtPragmaD (SpecialiseP nm ty opt_ispec)
+ = do { nm' <- vNameL nm
+ ; ty' <- cvtType ty
+ ; return $ SpecSig nm' ty' (cvtInlineSpec opt_ispec) }
+
+cvtInlineSpec :: Maybe TH.InlineSpec -> Hs.InlinePragma
+cvtInlineSpec Nothing
+ = defaultInlinePragma
+cvtInlineSpec (Just (TH.InlineSpec inline conlike opt_activation))
+ = InlinePragma { inl_act = opt_activation', inl_rule = matchinfo
+ , inl_inline = inl_spec, inl_sat = Nothing }
+ where
+ matchinfo = cvtRuleMatchInfo conlike
+ opt_activation' = cvtActivation opt_activation
+
+ cvtRuleMatchInfo False = FunLike
+ cvtRuleMatchInfo True = ConLike