[project @ 1998-12-02 13:17:09 by simonm]
[ghc-hetmet.git] / ghc / compiler / reader / PrefixToHs.lhs
index acc8627..ee4c224 100644 (file)
@@ -1,5 +1,5 @@
 %
-% (c) The GRASP/AQUA Project, Glasgow University, 1992-1996
+% (c) The GRASP/AQUA Project, Glasgow University, 1992-1998
 %
 \section[PrefixToHS]{Support routines for converting ``prefix form'' to Haskell abstract syntax}
 
@@ -14,7 +14,9 @@ module PrefixToHs (
        cvBinds,
        cvMonoBindsAndSigs,
        cvMatches,
-       cvOtherDecls
+       cvOtherDecls,
+       cvForeignDecls -- HACK
+
     ) where
 
 #include "HsVersions.h"
@@ -22,7 +24,6 @@ module PrefixToHs (
 import PrefixSyn       -- and various syntaxen.
 import HsSyn
 import RdrHsSyn
-import HsPragmas       ( noGenPragmas, noClassOpPragmas )
 
 import BasicTypes      ( RecFlag(..) )
 import SrcLoc          ( mkSrcLoc )
@@ -37,20 +38,19 @@ import Util         ( mapAndUnzip, panic, assertPanic )
 
 We make a point not to throw any user-pragma ``sigs'' at
 these conversion functions:
+
 \begin{code}
 cvValSig, cvClassOpSig, cvInstDeclSig :: SigConverter
 
-cvValSig (RdrTySig vars poly_ty src_loc)
-  = [ Sig v poly_ty src_loc | v <- vars ]
+cvValSig      sig = sig
 
-cvClassOpSig (RdrTySig vars poly_ty src_loc)
-  = [ ClassOpSig v Nothing poly_ty src_loc | v <- vars ]
+cvInstDeclSig sig = sig
 
-cvInstDeclSig (RdrSpecValSig        sigs) = sigs
-cvInstDeclSig (RdrInlineValSig      sig)  = [ sig ]
-cvInstDeclSig (RdrMagicUnfoldingSig sig)  = [ sig ]
+cvClassOpSig (Sig var poly_ty src_loc) = ClassOpSig var Nothing poly_ty src_loc
+cvClassOpSig sig                      = sig
 \end{code}
 
+
 %************************************************************************
 %*                                                                     *
 \subsection[cvBinds-etc]{Converting to @HsBinds@, @MonoBinds@, etc.}
@@ -89,12 +89,8 @@ cvMonoBindsAndSigs sf sig_cvtr fb
     mangle_bind acc (RdrAndBindings fb1 fb2)
       = mangle_bind (mangle_bind acc fb1) fb2
 
-    mangle_bind (b_acc, s_acc) sig@(RdrTySig _ _ _)
-      = (b_acc, s_acc ++ sig_cvtr sig)
-
-    mangle_bind (b_acc, s_acc) (RdrSpecValSig       sig) = (b_acc, sig ++ s_acc)
-    mangle_bind (b_acc, s_acc) (RdrInlineValSig      sig) = (b_acc, sig : s_acc)
-    mangle_bind (b_acc, s_acc) (RdrMagicUnfoldingSig sig) = (b_acc, sig : s_acc)
+    mangle_bind (b_acc, s_acc) (RdrSig sig)
+      = (b_acc, sig_cvtr sig : s_acc)
 
     mangle_bind (b_acc, s_acc)
                (RdrPatternBinding lousy_srcline [patbinding])
@@ -179,7 +175,9 @@ cvMatch sf is_case rdr_match
          RdrMatch_Guards  ln b c gd_exps d -> (c,d, map (cvGRHS sf ln) gd_exps)
 
 cvGRHS :: SrcFile -> SrcLine -> ([RdrNameStmt], RdrNameHsExpr) -> RdrNameGRHS
-cvGRHS sf sl (g, e) = GRHS g e (mkSrcLoc sf sl)
+cvGRHS sf sl (g, e) = GRHS (g ++ [ExprStmt e locn]) locn
+                   where
+                     locn = mkSrcLoc sf sl
 \end{code}
 
 %************************************************************************
@@ -202,4 +200,12 @@ cvOtherDecls b
     go acc (RdrDefaultDecl d)     = DefD d  : acc
     go acc other                 = acc
        -- Ignore value bindings
+
+cvForeignDecls :: RdrBinding -> [RdrNameHsDecl]
+cvForeignDecls b = go [] b
+ where
+    go acc (RdrAndBindings b1 b2) = go (go acc b1) b2
+    go acc (RdrForeignDecl d)     = ForD d  : acc
+    go acc other                 = acc
 \end{code}