[project @ 2002-09-06 14:35:42 by simonmar]
[ghc-hetmet.git] / ghc / compiler / main / BinIface.hs
index 799ce15..cb8a570 100644 (file)
@@ -7,6 +7,8 @@
 
 module BinIface ( writeBinIface ) where
 
+#include "HsVersions.h"
+
 import HscTypes
 import BasicTypes
 import NewDemand
@@ -28,14 +30,12 @@ import CmdLineOpts  ( opt_IgnoreIfacePragmas, opt_HiVersion )
 import StringBuffer    ( hGetStringBuffer )
 import Panic
 import SrcLoc
-
 import Binary
 
-import IOExts          ( readIORef )
-import Monad           ( when )
-import Exception       ( throwDyn )
+import DATA_IOREF      ( readIORef )
+import EXCEPTION       ( throwDyn )
 
-#include "HsVersions.h"
+import Monad           ( when )
 
 -- BasicTypes
 {-! for IPName derive: Binary !-}
@@ -248,7 +248,7 @@ instance Binary ModIface where
        put_ bh (vers_module (mi_version iface))
        put_ bh (mi_orphan iface)
        -- no: mi_boot
-       put_ bh (map importVersionNameToOccName (mi_usages iface))
+       lazyPut bh (map importVersionNameToOccName (mi_usages iface))
        put_ bh (vers_exports (mi_version iface),
                 map exportItemToRdrExportItem (mi_exports iface))
        put_ bh (declsToVersionedDecls (dcl_tycl (mi_decls iface))
@@ -260,7 +260,7 @@ instance Binary ModIface where
        lazyPut bh (vers_rules (mi_version iface), dcl_rules (mi_decls iface))
        lazyPut bh (deprecsToIfaceDeprecs (mi_deprecs iface))
 
-  -- Read in an a ParsedIface, not a ModIface.  See above.
+  -- Read in as a ParsedIface, not a ModIface.  See above.
   get bh = error "Binary.get: ModIface"
 
 declsToVersionedDecls :: [RenamedTyClDecl] -> NameEnv Version
@@ -323,7 +323,7 @@ instance Binary ParsedIface where
        put_ bh pkg_name
        put_ bh module_ver
        put_ bh orphan
-       put_ bh usages
+       lazyPut bh usages
        put_ bh exports
         put_ bh tycl_decls
        put_ bh fixities
@@ -344,13 +344,13 @@ instance Binary ParsedIface where
        pkg_name    <- get bh
        module_ver  <- get bh
        orphan      <- get bh
-       usages      <- get bh
-       exports     <- get bh
-        tycl_decls  <- get bh
-       fixities    <- get bh
-       insts       <- get bh
-       rules       <- lazyGet bh
-       deprecs     <- lazyGet bh
+       usages      <- {-# SCC "bin_usages" #-} lazyGet bh
+       exports     <- {-# SCC "bin_exports" #-} get bh
+        tycl_decls  <- {-# SCC "bin_tycldecls" #-} get bh
+       fixities    <- {-# SCC "bin_fixities" #-} get bh
+       insts       <- {-# SCC "bin_insts" #-} get bh
+       rules       <- {-# SCC "bin_rules" #-} lazyGet bh
+       deprecs     <- {-# SCC "bin_deprecs" #-} lazyGet bh
        return (ParsedIface {
                 pi_mod = module_name,
                 pi_pkg = pkg_name,
@@ -575,7 +575,9 @@ instance Binary DmdResult where
            h <- getByte bh
            case h of
              0 -> do return TopRes
-             1 -> do return RetCPR
+             1 -> do return RetCPR     -- Really use RetCPR even if -fcpr-off
+                                       -- The wrapper was generated for CPR in 
+                                       -- the imported module!
              _ -> do return BotRes
 
 instance Binary StrictSig where
@@ -613,6 +615,17 @@ instance (Binary name) => Binary (HsTupCon name) where
          ac <- get bh
          return (HsTupCon aa ab ac)
 
+instance (Binary name) => Binary (HsTyOp name) where
+    put_ bh HsArrow    = putByte bh 0
+    put_ bh (HsTyOp n) = do putByte bh 1
+                           put_ bh n
+
+    get bh = do h <- getByte bh
+               case h of
+                 0 -> return HsArrow
+                 1 -> do a <- get bh
+                         return (HsTyOp a)
+
 instance (Binary name) => Binary (HsType name) where
     put_ bh (HsForAllTy aa ab ac) = do
            putByte bh 0