+ -> ForeignImport
+ -> DsM ([Binding], SDoc, SDoc, [FastString])
+dsFImport id (CImport cconv safety header lib spec)
+ = dsCImport id spec cconv safety `thenDs` \(ids, h, c) ->
+ returnDs (ids, h, c, if nullFastString header then [] else [header])
+ -- FIXME: the `lib' field is needed for .NET ILX generation when invoking
+ -- routines that are external to the .NET runtime, but GHC doesn't
+ -- support such calls yet; if `nullFastString lib', the value was not given
+dsFImport id (DNImport spec)
+ = dsFCall id (DNCall spec) `thenDs` \(ids, h, c) ->
+ returnDs (ids, h, c, [])
+
+dsCImport :: Id
+ -> CImportSpec
+ -> CCallConv
+ -> Safety
+ -> DsM ([Binding], SDoc, SDoc)
+dsCImport id (CLabel cid) _ _
+ = ASSERT(fromJust resTy `eqType` addrPrimTy) -- typechecker ensures this
+ returnDs ([(id, rhs)], empty, empty)
+ where
+ (resTy, foRhs) = resultWrapper (idType id)
+ rhs = foRhs (mkLit (MachLabel cid))
+dsCImport id (CFunction target) cconv safety
+ = dsFCall id (CCall (CCallSpec target cconv safety))
+dsCImport id CWrapper cconv _
+ = dsFExportDynamic id cconv
+\end{code}
+
+
+%************************************************************************
+%* *
+\subsection{Foreign calls}
+%* *
+%************************************************************************
+
+\begin{code}
+dsFCall fn_id fcall