- appArg acc (a,c_a) =
- text "rts_apply" <> parens (acc <> comma <> mkHObj a <> parens c_a)
-
- cParamTypes = map showStgType real_args
-
- res_ty_is_unit = res_ty `eqType` unitTy -- Look through any newtypes
-
- cResType | res_ty_is_unit = text "void"
- | otherwise = showStgType res_ty
-
- pprCconv = case cc of
- CCallConv -> empty
- StdCallConv -> text (ccallConvAttribute cc)
-
- declareResult = text "HaskellObj ret;"
-
- mkExtern ty nm = text "extern" <+> ty <+> nm <> semi
-
- return_what | res_ty_is_unit = empty
- | otherwise = parens (unpackHObj res_ty <> parens (text "ret"))
-
- c_args = mkCArgNames 0 args
-
- {-
- If we're generating an entry point for a 'foreign export ccall dynamic',
- then we receive the return address of the C function that wants to
- invoke a Haskell function as any other C function, as second arg.
- This arg is unused within the body of the generated C stub, but
- needed by the Adjustor.c code to get the stack cleanup right.
- -}
- (proto_args, real_args)
- = case cc of
- CCallConv | isDyn -> ( text "a0" : text "original_return_addr"
- : mkCArgNames 1 (tail args)
- , head args : addrTy : tail args)
- other -> (mkCArgNames 0 args, args)