[project @ 2003-08-20 12:55:14 by simonmar]
[ghc-hetmet.git] / ghc / compiler / hsSyn / Convert.lhs
index db6c7ad..ddc11ad 100644 (file)
@@ -33,8 +33,10 @@ import TyCon ( DataConDetails(..) )
 import Type    ( Type )
 import BasicTypes( Boxity(..), RecFlag(Recursive), 
                   NewOrData(..), StrictnessMark(..) )
-import ForeignCall ( Safety(..), CCallConv(..), CCallTarget(..) )
-import HsDecls ( CImportSpec(..), ForeignImport(..), ForeignDecl(..) )
+import ForeignCall ( Safety(..), CCallConv(..), CCallTarget(..),
+                     CExportSpec(..)) 
+import HsDecls ( CImportSpec(..), ForeignImport(..), ForeignExport(..),
+                 ForeignDecl(..) )
 import FastString( FastString, mkFastString, nilFS )
 import Char    ( ord, isAscii, isAlphaNum, isAlpha )
 import List    ( partition )
@@ -120,6 +122,13 @@ cvt_top (ForeignD (ImportF callconv safety from nm typ))
                         Threadsafe -> PlaySafe True
           parsed = parse_ccall_impent nm from
 
+cvt_top (ForeignD (ExportF callconv as nm typ))
+ = let e = CExport (CExportStatic (mkFastString as) callconv')
+   in Left $ ForD (ForeignExport (vName nm) (cvtType typ) e False loc0)
+    where callconv' = case callconv of
+                          CCall -> CCallConv
+                          StdCall -> StdCallConv
+
 parse_ccall_impent :: String -> String -> Maybe (FastString, CImportSpec)
 parse_ccall_impent nm s
  = case lex_ccall_impent s of
@@ -237,13 +246,12 @@ cvtdd (FromThenToR x y z) = (FromThenTo (cvt x) (cvt y) (cvt z))
 
 
 cvtstmts :: [Meta.Stmt] -> [Hs.Stmt RdrName]
-cvtstmts [] = [] -- this is probably an error as every [stmt] should end with ResultStmt
-cvtstmts [NoBindS e]      = [ResultStmt (cvt e) loc0]      -- when its the last element use ResultStmt
-cvtstmts (NoBindS e : ss) = ExprStmt (cvt e) void loc0     : cvtstmts ss
+cvtstmts []                   = [] -- this is probably an error as every [stmt] should end with ResultStmt
+cvtstmts [NoBindS e]           = [ResultStmt (cvt e) loc0]      -- when its the last element use ResultStmt
+cvtstmts (NoBindS e : ss)      = ExprStmt (cvt e) void loc0     : cvtstmts ss
 cvtstmts (Meta.BindS p e : ss) = BindStmt (cvtp p) (cvt e) loc0 : cvtstmts ss
 cvtstmts (Meta.LetS ds : ss)   = LetStmt (cvtdecs ds)      : cvtstmts ss
-cvtstmts (Meta.ParS dss : ss)  = ParStmt(map cvtstmts dss)      : cvtstmts ss
-
+cvtstmts (Meta.ParS dss : ss)  = ParStmt [(cvtstmts ds, undefined) | ds <- dss] : cvtstmts ss
 
 cvtm :: Meta.Match -> Hs.Match RdrName
 cvtm (Meta.Match p body wheres)