@@ -49,7 +49,7 @@ import Prelude hiding ((<>))
4949--
5050-- Finally, it calls the java compiler to produce the bytecode and
5151-- arranges to have it inserted in the bytecode table in constructor functions
52- -- (cConstructors ).
52+ -- (cConstructor ).
5353
5454plugin :: Plugin
5555plugin = defaultPlugin
@@ -82,15 +82,15 @@ plugin = defaultPlugin
8282 dcs <- buildJava guts qqOccs jimports
8383 >>= maybeDumpJava args
8484 >>= buildBytecode args
85+ dflags <- getDynFlags
86+ let cstub =
87+ cConstructor
88+ dflags
89+ (mg_module guts)
90+ (text bctable_header $$ dotClasses dcs)
8591 return guts
8692 { mg_binds = binds
87- , mg_foreign = appendStubC (mg_foreign guts) $
88- CStub
89- ( text bctable_header
90- $$ dotClasses dcs
91- $$ cConstructors
92- )
93- [] []
93+ , mg_foreign = appendStubC (mg_foreign guts) cstub
9494 }
9595
9696 -- The contents of bctable.h
@@ -460,9 +460,10 @@ dotClasses dcs = vcat $
460460
461461-- | Produces the constructor function which inserts the static structures
462462-- generated by 'dotClasses' into the bytecode table.
463- cConstructors :: SDoc
464- cConstructors = vcat
465- [ text " static void hs_inline_java_init(void) __attribute__((constructor));"
466- , text " static void hs_inline_java_init(void)"
467- , text " { inline_java_bctable = inline_java_new_pack(inline_java_bctable, dcs, dc_count); }"
468- ]
463+ cConstructor :: DynFlags -> Module -> SDoc -> CStub
464+ cConstructor dflags this_mod decls =
465+ initializerCStub
466+ (targetPlatform dflags)
467+ (mkInitializerStubLabel this_mod " inline_java_bctable" )
468+ decls
469+ (text " { inline_java_bctable = inline_java_new_pack(inline_java_bctable, dcs, dc_count); }" )
0 commit comments