X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2FdeSugar%2FDsForeign.lhs;h=6c58176f254c8168d9d0485403113fcbc436a4f9;hb=ab5b8aa357c685a7c702262903bce04c66f79156;hp=462da0e051e5ab16bc115537cb321ecfbae48eaa;hpb=f1c0fd99f16322fe222c6fcf4626a6162ad0a466;p=ghc-hetmet.git diff --git a/compiler/deSugar/DsForeign.lhs b/compiler/deSugar/DsForeign.lhs index 462da0e..6c58176 100644 --- a/compiler/deSugar/DsForeign.lhs +++ b/compiler/deSugar/DsForeign.lhs @@ -1,9 +1,9 @@ % +% (c) The University of Glasgow 2006 % (c) The AQUA Project, Glasgow University, 1998 % -\section[DsCCall]{Desugaring \tr{foreign} declarations} -Expanding out @foreign import@ and @foreign export@ declarations. +Desugaring foreign declarations (see also DsCCall). \begin{code} module DsForeign ( dsForeigns ) where @@ -13,48 +13,33 @@ import TcRnMonad -- temp import CoreSyn -import DsCCall ( dsCCall, mkFCall, boxResult, unboxArg, resultWrapper ) +import DsCCall import DsMonad -import HsSyn ( ForeignDecl(..), ForeignExport(..), LForeignDecl, - ForeignImport(..), CImportSpec(..) ) -import DataCon ( splitProductType_maybe ) -#ifdef DEBUG -import DataCon ( dataConSourceArity ) -import Type ( isUnLiftedType ) -#endif -import MachOp ( machRepByteWidth, MachRep(..) ) -import SMRep ( argMachRep, typeCgRep ) -import CoreUtils ( exprType, mkInlineMe ) -import Id ( Id, idType, idName, mkSysLocal, setInlinePragma ) -import Literal ( Literal(..), mkStringLit ) -import Module ( moduleNameFS, moduleName ) -import Name ( getOccString, NamedThing(..) ) -import Type ( repType, coreEqType ) -import Coercion ( mkUnsafeCoercion ) -import TcType ( Type, mkFunTys, mkForAllTys, mkTyConApp, - mkFunTy, tcSplitTyConApp_maybe, tcSplitIOType_maybe, - tcSplitForAllTys, tcSplitFunTys, tcTyConAppArgs, - isBoolTy - ) - -import BasicTypes ( Boxity(..) ) -import HscTypes ( ForeignStubs(..) ) -import ForeignCall ( ForeignCall(..), CCallSpec(..), - Safety(..), - CExportSpec(..), CLabelString, - CCallConv(..), ccallConvToInt, - ccallConvAttribute - ) -import TysWiredIn ( unitTy, tupleTyCon ) -import TysPrim ( addrPrimTy, mkStablePtrPrimTy, alphaTy, intPrimTy ) -import PrelNames ( stablePtrTyConName, newStablePtrName, bindIOName, - checkDotnetResName ) -import BasicTypes ( Activation( NeverActive ) ) -import SrcLoc ( Located(..), unLoc ) +import HsSyn +import DataCon +import MachOp +import SMRep +import CoreUtils +import Id +import Literal +import Module +import Name +import Type +import Coercion +import TcType + +import HscTypes +import ForeignCall +import TysWiredIn +import TysPrim +import PrelNames +import BasicTypes +import SrcLoc import Outputable -import Maybe ( fromJust, isNothing ) import FastString + +import Data.Maybe \end{code} Desugaring of @foreign@ declarations is naturally split up into @@ -403,8 +388,10 @@ dsFExportDynamic id cconv -- PlayRisky: the adjustor doesn't allocate in the Haskell heap or do a callback let ccall_adj_ty = exprType ccall_adj ccall_io_adj = mkLams [stbl_value] $ - (pprTrace "DsForeign: why is there an unsafeCoerce here?" (text "") $ - (Cast ccall_adj (mkUnsafeCoercion ccall_adj_ty io_res_ty ))) +#ifdef DEBUG + pprTrace "DsForeign: why is there an unsafeCoerce here?" (text "") $ +#endif + (Cast ccall_adj (mkUnsafeCoercion ccall_adj_ty io_res_ty )) io_app = mkLams tvs $ mkLams [cback] $