consDataCon,
doubleDataCon,
doubleTy,
- isDoubleTy,
doubleTyCon,
falseDataCon, falseDataConId,
floatDataCon,
floatTy,
- isFloatTy,
floatTyCon,
intDataCon,
intTy,
intTyCon,
- isIntTy,
integerTy,
integerTyCon,
smallIntegerDataCon,
largeIntegerDataCon,
- isIntegerTy,
listTyCon,
wordTy,
wordTyCon,
- isFFIArgumentTy, -- :: DynFlags -> Bool -> Type -> Bool
+ isFFIArgumentTy, -- :: DynFlags -> Safety -> Type -> Bool
isFFIImportResultTy, -- :: DynFlags -> Type -> Bool
isFFIExportResultTy, -- :: Type -> Bool
isFFIExternalTy, -- :: Type -> Bool
isFFIDynArgumentTy, -- :: Type -> Bool
isFFIDynResultTy, -- :: Type -> Bool
isFFILabelTy, -- :: Type -> Bool
- isAddrTy, -- :: Type -> Bool
- isForeignPtrTy -- :: Type -> Bool
-
) where
#include "HsVersions.h"
import TysPrim
-- others:
+import ForeignCall ( Safety, playSafe )
import Constants ( mAX_TUPLE_SIZE )
import Module ( mkPrelModule )
import Name ( Name, nameRdrName, nameUnique, nameOccName,
nameModule, mkWiredInName )
import OccName ( mkOccFS, tcName, dataName, mkWorkerOcc, mkGenOcc1, mkGenOcc2 )
import RdrName ( rdrNameOcc )
-import DataCon ( DataCon, StrictnessMark(..), mkDataCon, dataConId )
+import DataCon ( DataCon, mkDataCon, dataConId )
import Var ( TyVar, tyVarKind )
import TyCon ( TyCon, AlgTyConFlavour(..), tyConDataCons,
mkTupleTyCon, isUnLiftedTyCon, mkAlgTyCon
)
-import BasicTypes ( Arity, RecFlag(..), Boxity(..), isBoxed )
+import BasicTypes ( Arity, RecFlag(..), Boxity(..), isBoxed, StrictnessMark(..) )
import Type ( Type, mkTyConTy, mkTyConApp, mkTyVarTys,
mkArrowKinds, liftedTypeKind, unliftedTypeKind,
- splitTyConApp_maybe, repType,
+ splitTyConApp_maybe,
TauType, ThetaType )
import Unique ( incrUnique, mkTupleTyConUnique, mkTupleDataConUnique )
import PrelNames
intTyCon = pcNonRecDataTyCon intTyConName [] [] [intDataCon]
intDataCon = pcDataCon intDataConName [] [] [intPrimTy] intTyCon
-
-isIntTy :: Type -> Bool
-isIntTy = isTyCon intTyConKey
\end{code}
\begin{code}
-
wordTy = mkTyConTy wordTyCon
wordTyCon = pcNonRecDataTyCon wordTyConName [] [] [wordDataCon]
addrTyCon = pcNonRecDataTyCon addrTyConName [] [] [addrDataCon]
addrDataCon = pcDataCon addrDataConName [] [] [addrPrimTy] addrTyCon
-
-isAddrTy :: Type -> Bool
-isAddrTy = isTyCon addrTyConKey
\end{code}
\begin{code}
floatTyCon = pcNonRecDataTyCon floatTyConName [] [] [floatDataCon]
floatDataCon = pcDataCon floatDataConName [] [] [floatPrimTy] floatTyCon
-
-isFloatTy :: Type -> Bool
-isFloatTy = isTyCon floatTyConKey
\end{code}
\begin{code}
doubleTy = mkTyConTy doubleTyCon
-isDoubleTy :: Type -> Bool
-isDoubleTy = isTyCon doubleTyConKey
-
doubleTyCon = pcNonRecDataTyCon doubleTyConName [] [] [doubleDataCon]
doubleDataCon = pcDataCon doubleDataConName [] [] [doublePrimTy] doubleTyCon
\end{code}
foreignObjDataCon
= pcDataCon foreignObjDataConName
[] [] [foreignObjPrimTy] foreignObjTyCon
-
-isForeignObjTy :: Type -> Bool
-isForeignObjTy = isTyCon foreignObjTyConKey
\end{code}
\begin{code}
foreignPtrDataCon
= pcDataCon foreignPtrDataConName
alpha_tyvar [] [foreignObjPrimTy] foreignPtrTyCon
-
-isForeignPtrTy :: Type -> Bool
-isForeignPtrTy = isTyCon foreignPtrTyConKey
\end{code}
%************************************************************************
[] [] [intPrimTy] integerTyCon
largeIntegerDataCon = pcDataCon largeIntegerDataConName
[] [] [intPrimTy, byteArrayPrimTy] integerTyCon
-
-
-isIntegerTy :: Type -> Bool
-isIntegerTy = isTyCon integerTyConKey
\end{code}
being the )
\begin{code}
-isFFIArgumentTy :: DynFlags -> Bool -> Type -> Bool
+isFFIArgumentTy :: DynFlags -> Safety -> Type -> Bool
-- Checks for valid argument type for a 'foreign import'
-isFFIArgumentTy dflags is_safe ty
- = checkRepTyCon (legalOutgoingTyCon dflags is_safe) ty
+isFFIArgumentTy dflags safety ty
+ = checkRepTyCon (legalOutgoingTyCon dflags safety) ty
isFFIExternalTy :: Type -> Bool
-- Types that are allowed as arguments of a 'foreign export'
isFFILabelTy = checkRepTyCon (\tc -> tc == ptrTyCon || tc == funPtrTyCon || tc == addrTyCon)
checkRepTyCon :: (TyCon -> Bool) -> Type -> Bool
- -- look through newtypes
-checkRepTyCon check_tc ty = checkTyCon check_tc (repType ty)
-
-checkTyCon :: (TyCon -> Bool) -> Type -> Bool
-checkTyCon check_tc ty = case splitTyConApp_maybe ty of
+ -- Look through newtypes
+checkRepTyCon check_tc ty = case splitTyConApp_maybe ty of
Just (tycon, _) -> check_tc tycon
Nothing -> False
-
-isTyCon :: Unique -> Type -> Bool
-isTyCon uniq ty = checkTyCon (\tc -> uniq == getUnique tc) ty
\end{code}
----------------------------------------------
| tc == unitTyCon = True
| otherwise = boxedMarshalableTyCon tc
-legalOutgoingTyCon :: DynFlags -> Bool -> TyCon -> Bool
+legalOutgoingTyCon :: DynFlags -> Safety -> TyCon -> Bool
-- Checks validity of types going from Haskell -> external world
--- The boolean is true for a 'safe' call (when we don't want to
--- pass Haskell pointers to the world)
-legalOutgoingTyCon dflags be_safe tc
- | be_safe && getUnique tc `elem` [byteArrayTyConKey, mutableByteArrayTyConKey]
+legalOutgoingTyCon dflags safety tc
+ | playSafe safety && getUnique tc `elem` [byteArrayTyConKey, mutableByteArrayTyConKey]
= False
| otherwise
= marshalableTyCon dflags tc