import DataCon ( DataCon, dataConId )
import Id ( Id, idType, idName, mkWildId, mkVanillaId )
import Const ( Literal(..) )
-import Module ( Module )
+import Module ( Module, moduleUserString )
import Name ( mkGlobalName, nameModule, nameOccName, getOccString,
mkForeignExportOcc, isLocalName,
NamedThing(..), Provenance(..), ExportFlag(..)
)
import Unique
import Outputable
+
+#if __GLASGOW_HASKELL__ >= 404
+import GlaExts ( fromInt )
+#endif
\end{code}
Desugaring of @foreign@ declarations is naturally split up into
ExtName fs _ -> fs
Dynamic -> panic "dsFExport: Dynamic - shouldn't ever happen."
- (h_stub, c_stub) = fexportEntry c_nm f_helper_glob
+ (h_stub, c_stub) = fexportEntry (moduleUserString mod)
+ c_nm f_helper_glob
wrapper_arg_tys the_result_ty cconv isDyn
in
returnDs (NonRec f_helper_glob the_body, h_stub, c_stub)
using the hugs/ghc rts invocation API.
\begin{code}
-fexportEntry :: FAST_STRING
+fexportEntry :: String
+ -> FAST_STRING
-> Id
-> [Type]
-> Maybe Type
-> CallConv
-> Bool
-> (SDoc, SDoc)
-fexportEntry c_nm helper args res cc isDyn = (header_bits, c_bits)
+fexportEntry mod_nm c_nm helper args res cc isDyn = (header_bits, c_bits)
where
-- name of the (Haskell) helper function generated by the desugarer.
h_nm = ppr helper <> text "_closure"
returnResult =
text "rts_checkSchedStatus" <>
- parens (doubleQuotes (ptext c_nm) <> comma <> text "rc") <> semi $$
+ parens (doubleQuotes (text mod_nm <> char '.' <> ptext c_nm) <> comma <> text "rc") <> semi $$
(case res of
Nothing -> text "return"
Just _ -> text "return" <> parens (res_name)) <> semi