X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Fcompiler%2Fprelude%2FForeignCall.lhs;h=12b85b1c03f8d7c7d71455ddf02997d47c7506e3;hb=423d477bfecd490de1449c59325c8776f91d7aac;hp=ab04abff255f3e1f299f339dcd61defe84654783;hpb=553e90d9a32ee1b1809430f260c401cc4169c6c7;p=ghc-hetmet.git diff --git a/ghc/compiler/prelude/ForeignCall.lhs b/ghc/compiler/prelude/ForeignCall.lhs index ab04abf..12b85b1 100644 --- a/ghc/compiler/prelude/ForeignCall.lhs +++ b/ghc/compiler/prelude/ForeignCall.lhs @@ -1,5 +1,3 @@ -{-% DrIFT (Automatic class derivations for Haskell) v1.1 %-} -{-% DrIFT (Automatic class derivations for Haskell) v1.1 %-} % % (c) The GRASP/AQUA Project, Glasgow University, 1992-1998 % @@ -10,7 +8,7 @@ module ForeignCall ( ForeignCall(..), Safety(..), playSafe, playThreadSafe, - CExportSpec(..), + CExportSpec(..), CLabelString, isCLabelString, pprCLabelString, CCallSpec(..), CCallTarget(..), isDynamicTarget, CCallConv(..), defaultCCallConv, ccallConvToInt, ccallConvAttribute, @@ -21,8 +19,8 @@ module ForeignCall ( #include "HsVersions.h" -import CStrings ( CLabelString, pprCLabelString ) -import FastString ( FastString ) +import FastString ( FastString, unpackFS ) +import Char ( isAlphaNum ) import Binary import Outputable \end{code} @@ -155,6 +153,22 @@ ccallConvAttribute StdCallConv = "__stdcall" ccallConvAttribute CCallConv = "" \end{code} +\begin{code} +type CLabelString = FastString -- A C label, completely unencoded + +pprCLabelString :: CLabelString -> SDoc +pprCLabelString lbl = ftext lbl + +isCLabelString :: CLabelString -> Bool -- Checks to see if this is a valid C label +isCLabelString lbl + = all ok (unpackFS lbl) + where + ok c = isAlphaNum c || c == '_' || c == '.' + -- The '.' appears in e.g. "foo.so" in the + -- module part of a ExtName. Maybe it should be separate +\end{code} + + Printing into C files: \begin{code}