dsForeigns fos
= foldlDs combine (ForeignStubs empty empty [] [], []) fos
where
- combine (ForeignStubs acc_h acc_c acc_hdrs acc_feb, acc_f)
- (L loc (ForeignImport id _ spec depr))
+ combine stubs (L loc decl) = putSrcSpanDs loc (combine1 stubs decl)
+
+ combine1 (ForeignStubs acc_h acc_c acc_hdrs acc_feb, acc_f)
+ (ForeignImport id _ spec depr)
= traceIf (text "fi start" <+> ppr id) `thenDs` \ _ ->
dsFImport (unLoc id) spec `thenDs` \ (bs, h, c, mbhd) ->
- warnDepr depr loc `thenDs` \ _ ->
+ warnDepr depr `thenDs` \ _ ->
traceIf (text "fi end" <+> ppr id) `thenDs` \ _ ->
returnDs (ForeignStubs (h $$ acc_h)
(c $$ acc_c)
acc_feb,
bs ++ acc_f)
- combine (ForeignStubs acc_h acc_c acc_hdrs acc_feb, acc_f)
- (L loc (ForeignExport (L _ id) _ (CExport (CExportStatic ext_nm cconv)) depr))
+ combine1 (ForeignStubs acc_h acc_c acc_hdrs acc_feb, acc_f)
+ (ForeignExport (L _ id) _ (CExport (CExportStatic ext_nm cconv)) depr)
= dsFExport id (idType id)
ext_nm cconv False `thenDs` \(h, c, _, _) ->
- warnDepr depr loc `thenDs` \_ ->
+ warnDepr depr `thenDs` \_ ->
returnDs (ForeignStubs (h $$ acc_h) (c $$ acc_c) acc_hdrs (id:acc_feb),
acc_f)
| e `elem` ls = ls
| otherwise = e:ls
- warnDepr False _ = returnDs ()
- warnDepr True loc = dsWarn (loc, msg)
+ warnDepr False = returnDs ()
+ warnDepr True = dsWarn msg
where
msg = ptext SLIT("foreign declaration uses deprecated non-standard syntax")
\end{code}
let
work_arg_ids = [v | Var v <- val_args] -- All guaranteed to be vars
- -- These are the ids we pass to boxResult, which are used to decide
- -- whether to touch# an argument after the call (used to keep
- -- ForeignObj#s live across a 'safe' foreign import).
- maybe_arg_ids | unsafe_call fcall = work_arg_ids
- | otherwise = []
-
forDotnet =
case fcall of
DNCall{} -> True
in
augmentResultDs `thenDs` \ augment ->
topConDs `thenDs` \ topCon ->
- boxResult maybe_arg_ids augment topCon io_res_ty `thenDs` \ (ccall_result_ty, res_wrapper) ->
+ boxResult augment topCon io_res_ty `thenDs` \ (ccall_result_ty, res_wrapper) ->
newUnique `thenDs` \ ccall_uniq ->
newUnique `thenDs` \ work_uniq ->
-- the program.
-- (this is bad for big umbrella modules like Graphics.Rendering.OpenGL)
- -- the only reason for making the mingw32 (anything targetting PE, really) stick
- -- out here is that the GHCi linker isn't capable of handling .ctors sections
- useStaticConstructors
-#if defined(mingw32_HOST_OS)
- = False
-#else
- = True
-#endif
-
initialiser
= case maybe_target of
Nothing -> empty
- Just hs_fn
- | not useStaticConstructors -> empty
- | otherwise ->
+ Just hs_fn ->
vcat
[ text "static void stginit_export_" <> ppr hs_fn
<> text "() __attribute__((constructor));"