X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=blobdiff_plain;f=compiler%2FdeSugar%2FDsForeign.lhs;h=2c2d7f2cd730aebe5366f37e3e9b64aaa24564f5;hp=4d0a148e1598f2ba80de82a371f92275b3be457e;hb=34c8d0312071f7d0f4d221a997d3408c653ef9e5;hpb=cb8fb4dc68b503474bd65c0a669d9018a3ce96fe diff --git a/compiler/deSugar/DsForeign.lhs b/compiler/deSugar/DsForeign.lhs index 4d0a148..2c2d7f2 100644 --- a/compiler/deSugar/DsForeign.lhs +++ b/compiler/deSugar/DsForeign.lhs @@ -525,7 +525,7 @@ mkFExportCBits c_nm maybe_target arg_htys res_hty is_IO_res_ty cc the_cfun = case maybe_target of Nothing -> text "(StgClosure*)deRefStablePtr(the_stableptr)" - Just hs_fn -> char '&' <> ppr hs_fn <> text "_closure" + Just hs_fn -> char '&' <> ppr hs_fn <> text (closureSuffix hs_fn) cap = text "cap" <> comma @@ -550,9 +550,8 @@ mkFExportCBits c_nm maybe_target arg_htys res_hty is_IO_res_ty cc extern_decl = case maybe_target of Nothing -> empty - Just hs_fn -> text "extern StgClosure " <> ppr hs_fn <> text "_closure" <> semi + Just hs_fn -> text "extern StgClosure " <> ppr hs_fn <> text (closureSuffix hs_fn) <> semi - -- finally, the whole darn thing c_bits = space $$ @@ -590,6 +589,10 @@ mkFExportCBits c_nm maybe_target arg_htys res_hty is_IO_res_ty cc , rbrace ] +closureSuffix :: Id -> String +closureSuffix hs_fn = + if depth==0 then "_closure" else "_"++(show depth)++"closure" + where depth = getNameDepth (Var.varName hs_fn) foreignExportInitialiser :: Id -> SDoc foreignExportInitialiser hs_fn = @@ -606,11 +609,10 @@ foreignExportInitialiser hs_fn = <> text "() __attribute__((constructor));" , text "static void stginit_export_" <> ppr hs_fn <> text "()" , braces (text "getStablePtr" - <> parens (text "(StgPtr) &" <> ppr hs_fn <> text "_closure") + <> parens (text "(StgPtr) &" <> ppr hs_fn <> text (closureSuffix hs_fn)) <> semi) ] - mkHObj :: Type -> SDoc mkHObj t = text "rts_mk" <> text (showFFIType t)