2 -- (c) The University of Glasgow 2002-2006
4 -- Binary interface file support.
6 module BinIface ( writeBinIface, readBinIface, v_IgnoreHiWay ) where
8 #include "HsVersions.h"
41 import Control.Exception
44 -- ---------------------------------------------------------------------------
45 -- Reading and writing binary interface files
47 readBinIface :: FilePath -> TcRnIf a b ModIface
48 readBinIface hi_path = do
50 (new_nc, iface) <- ioToIOEnv $ readBinIface_ hi_path nc
54 readBinIface_ :: FilePath -> NameCache -> IO (NameCache, ModIface)
55 readBinIface_ hi_path nc = do
56 bh <- Binary.readBinMem hi_path
58 -- Read the magic number to check that this really is a GHC .hi file
59 -- (This magic number does not change when we change
60 -- GHC interface file format)
62 when (magic /= binaryInterfaceMagic) $
63 throwDyn (ProgramError (
64 "magic number mismatch: old/corrupt interface file?"))
66 -- Get the dictionary pointer. We won't attempt to actually
67 -- read the dictionary until we've done the version checks below,
68 -- just in case this isn't a valid interface. In retrospect the
69 -- version should have come before the dictionary pointer, but this
70 -- is the way it was done originally, and we can't change it now.
71 dict_p <- Binary.get bh -- Get the dictionary ptr
73 -- Check the interface file version and ways.
75 let our_ver = show opt_HiVersion
76 when (check_ver /= our_ver) $
77 -- This will be caught by readIface which will emit an error
78 -- msg containing the iface module name.
79 throwDyn (ProgramError (
80 "mismatched interface file versions: expected "
81 ++ our_ver ++ ", found " ++ check_ver))
84 ignore_way <- readIORef v_IgnoreHiWay
85 way_descr <- getWayDescr
86 when (not ignore_way && check_way /= way_descr) $
87 -- This will be caught by readIface
88 -- which will emit an error msg containing the iface module name.
89 throwDyn (ProgramError (
90 "mismatched interface file ways: expected "
91 ++ way_descr ++ ", found " ++ check_way))
93 -- Read the dictionary
94 -- The next word in the file is a pointer to where the dictionary is
95 -- (probably at the end of the file)
96 data_p <- tellBin bh -- Remember where we are now
98 dict <- getDictionary bh
99 seekBin bh data_p -- Back to where we were before
101 -- Initialise the user-data field of bh
102 ud <- newReadState dict
103 bh <- return (setUserData bh ud)
105 symtab_p <- Binary.get bh -- Get the symtab ptr
106 data_p <- tellBin bh -- Remember where we are now
108 (nc', symtab) <- getSymbolTable bh nc
109 seekBin bh data_p -- Back to where we were before
110 let ud = getUserData bh
111 bh <- return $! setUserData bh ud{ud_symtab = symtab}
116 writeBinIface :: DynFlags -> FilePath -> ModIface -> IO ()
117 writeBinIface dflags hi_path mod_iface = do
118 bh <- openBinMem initBinMemSize
119 put_ bh binaryInterfaceMagic
121 -- Remember where the dictionary pointer will go
122 dict_p_p <- tellBin bh
123 put_ bh dict_p_p -- Placeholder for ptr to dictionary
125 -- The version and way descriptor go next
126 put_ bh (show opt_HiVersion)
127 way_descr <- getWayDescr
130 -- Remember where the symbol table pointer will go
131 symtab_p_p <- tellBin bh
134 -- Make some intial state
137 -- Put the main thing,
138 bh <- return $ setUserData bh ud
141 -- Write the symtab pointer at the fornt of the file
142 symtab_p <- tellBin bh -- This is where the symtab will start
143 putAt bh symtab_p_p symtab_p -- Fill in the placeholder
144 seekBin bh symtab_p -- Seek back to the end of the file
146 -- Write the symbol table itself
147 symtab_next <- readFastMutInt (ud_symtab_next ud)
148 symtab_map <- readIORef (ud_symtab_map ud)
149 putSymbolTable bh symtab_next symtab_map
150 debugTraceMsg dflags 3 (text "writeBinIface:" <+> int symtab_next
153 -- NB. write the dictionary after the symbol table, because
154 -- writing the symbol table may create more dictionary entries.
156 -- Write the dictionary pointer at the fornt of the file
157 dict_p <- tellBin bh -- This is where the dictionary will start
158 putAt bh dict_p_p dict_p -- Fill in the placeholder
159 seekBin bh dict_p -- Seek back to the end of the file
161 -- Write the dictionary itself
162 dict_next <- readFastMutInt (ud_dict_next ud)
163 dict_map <- readIORef (ud_dict_map ud)
164 putDictionary bh dict_next dict_map
165 debugTraceMsg dflags 3 (text "writeBinIface:" <+> int dict_next
166 <+> text "dict entries")
168 -- And send the result to the file
169 writeBinMem bh hi_path
171 initBinMemSize = (1024*1024) :: Int
173 -- The *host* architecture version:
174 #include "MachDeps.h"
176 #if WORD_SIZE_IN_BITS == 32
177 binaryInterfaceMagic = 0x1face :: Word32
178 #elif WORD_SIZE_IN_BITS == 64
179 binaryInterfaceMagic = 0x1face64 :: Word32
182 -- -----------------------------------------------------------------------------
185 putSymbolTable :: BinHandle -> Int -> UniqFM (Int,Name) -> IO ()
186 putSymbolTable bh next_off symtab = do
188 let names = elems (array (0,next_off-1) (eltsUFM symtab))
189 mapM_ (\n -> serialiseName bh n symtab) names
191 getSymbolTable :: BinHandle -> NameCache -> IO (NameCache, Array Int Name)
192 getSymbolTable bh namecache = do
194 od_names <- sequence (replicate sz (get bh))
196 arr = listArray (0,sz-1) names
197 (namecache', names) =
198 mapAccumR (fromOnDiskName arr) namecache od_names
200 return (namecache', arr)
202 type OnDiskName = (PackageId, ModuleName, OccName)
209 fromOnDiskName arr nc (pid, mod_name, occ) =
211 mod = mkModule pid mod_name
214 case lookupOrigNameCache cache mod occ of
215 Just name -> (nc, name)
219 uniq = uniqFromSupply us
220 name = mkExternalName uniq mod occ noSrcSpan
221 new_cache = extendNameCache cache mod occ name
223 case splitUniqSupply us of { (us',_) ->
224 ( nc{ nsUniqs = us', nsNames = new_cache }, name )
227 serialiseName :: BinHandle -> Name -> UniqFM (Int,Name) -> IO ()
228 serialiseName bh name symtab = do
229 let mod = nameModule name
230 put_ bh (modulePackageId mod, moduleName mod, nameOccName name)
232 -- -----------------------------------------------------------------------------
233 -- All the binary instances
236 {-! for IPName derive: Binary !-}
237 {-! for Fixity derive: Binary !-}
238 {-! for FixityDirection derive: Binary !-}
239 {-! for Boxity derive: Binary !-}
240 {-! for StrictnessMark derive: Binary !-}
241 {-! for Activation derive: Binary !-}
244 {-! for Demand derive: Binary !-}
245 {-! for Demands derive: Binary !-}
246 {-! for DmdResult derive: Binary !-}
247 {-! for StrictSig derive: Binary !-}
250 {-! for DefMeth derive: Binary !-}
253 {-! for HsPred derive: Binary !-}
254 {-! for HsType derive: Binary !-}
255 {-! for TupCon derive: Binary !-}
256 {-! for HsTyVarBndr derive: Binary !-}
259 {-! for UfExpr derive: Binary !-}
260 {-! for UfConAlt derive: Binary !-}
261 {-! for UfBinding derive: Binary !-}
262 {-! for UfBinder derive: Binary !-}
263 {-! for HsIdInfo derive: Binary !-}
264 {-! for UfNote derive: Binary !-}
267 {-! for ConDetails derive: Binary !-}
268 {-! for BangType derive: Binary !-}
271 {-! for IsCafCC derive: Binary !-}
272 {-! for IsDupdCC derive: Binary !-}
273 {-! for CostCentre derive: Binary !-}
277 -- ---------------------------------------------------------------------------
278 -- Reading a binary interface into ParsedIface
280 instance Binary ModIface where
284 mi_mod_vers = mod_vers,
286 mi_finsts = hasFamInsts,
289 mi_exports = exports,
290 mi_exp_vers = exp_vers,
291 mi_fixities = fixities,
292 mi_deprecs = deprecs,
295 mi_fam_insts = fam_insts,
297 mi_rule_vers = rule_vers,
298 mi_vect_info = vect_info }) = do
322 hasFamInsts <- get bh
324 usages <- {-# SCC "bin_usages" #-} lazyGet bh
325 exports <- {-# SCC "bin_exports" #-} get bh
327 fixities <- {-# SCC "bin_fixities" #-} get bh
328 deprecs <- {-# SCC "bin_deprecs" #-} lazyGet bh
329 decls <- {-# SCC "bin_tycldecls" #-} get bh
330 insts <- {-# SCC "bin_insts" #-} get bh
331 fam_insts <- {-# SCC "bin_fam_insts" #-} get bh
332 rules <- {-# SCC "bin_rules" #-} lazyGet bh
336 mi_module = mod_name,
338 mi_mod_vers = mod_vers,
340 mi_finsts = hasFamInsts,
343 mi_exports = exports,
344 mi_exp_vers = exp_vers,
345 mi_fixities = fixities,
346 mi_deprecs = deprecs,
348 mi_globals = Nothing,
350 mi_fam_insts = fam_insts,
352 mi_rule_vers = rule_vers,
353 mi_vect_info = vect_info,
354 -- And build the cached values
355 mi_dep_fn = mkIfaceDepCache deprecs,
356 mi_fix_fn = mkIfaceFixCache fixities,
357 mi_ver_fn = mkIfaceVerCache decls })
359 GLOBAL_VAR(v_IgnoreHiWay, False, Bool)
361 getWayDescr :: IO String
363 tag <- readIORef v_Build_tag
364 if cGhcUnregisterised == "YES" then return ('u':tag) else return tag
365 -- if this is an unregisterised build, make sure our interfaces
366 -- can't be used by a registerised build.
368 -------------------------------------------------------------------------
369 -- Types from: HscTypes
370 -------------------------------------------------------------------------
372 instance Binary Dependencies where
373 put_ bh deps = do put_ bh (dep_mods deps)
374 put_ bh (dep_pkgs deps)
375 put_ bh (dep_orphs deps)
376 put_ bh (dep_finsts deps)
378 get bh = do ms <- get bh
382 return (Deps { dep_mods = ms, dep_pkgs = ps, dep_orphs = os,
385 instance (Binary name) => Binary (GenAvailInfo name) where
386 put_ bh (Avail aa) = do
389 put_ bh (AvailTC ab ac) = do
400 return (AvailTC ab ac)
402 instance Binary Usage where
404 put_ bh (usg_name usg)
405 put_ bh (usg_mod usg)
406 put_ bh (usg_exports usg)
407 put_ bh (usg_entities usg)
408 put_ bh (usg_rules usg)
416 return (Usage { usg_name = nm, usg_mod = mod,
417 usg_exports = exps, usg_entities = ents,
420 instance Binary a => Binary (Deprecs a) where
421 put_ bh NoDeprecs = putByte bh 0
422 put_ bh (DeprecAll t) = do
425 put_ bh (DeprecSome ts) = do
432 0 -> return NoDeprecs
434 return (DeprecAll aa)
436 return (DeprecSome aa)
438 -------------------------------------------------------------------------
439 -- Types from: BasicTypes
440 -------------------------------------------------------------------------
442 instance Binary Activation where
443 put_ bh NeverActive = do
445 put_ bh AlwaysActive = do
447 put_ bh (ActiveBefore aa) = do
450 put_ bh (ActiveAfter ab) = do
456 0 -> do return NeverActive
457 1 -> do return AlwaysActive
459 return (ActiveBefore aa)
461 return (ActiveAfter ab)
463 instance Binary StrictnessMark where
464 put_ bh MarkedStrict = do
466 put_ bh MarkedUnboxed = do
468 put_ bh NotMarkedStrict = do
473 0 -> do return MarkedStrict
474 1 -> do return MarkedUnboxed
475 _ -> do return NotMarkedStrict
477 instance Binary Boxity where
486 _ -> do return Unboxed
488 instance Binary TupCon where
489 put_ bh (TupCon ab ac) = do
495 return (TupCon ab ac)
497 instance Binary RecFlag where
498 put_ bh Recursive = do
500 put_ bh NonRecursive = do
505 0 -> do return Recursive
506 _ -> do return NonRecursive
508 instance Binary DefMeth where
509 put_ bh NoDefMeth = putByte bh 0
510 put_ bh DefMeth = putByte bh 1
511 put_ bh GenDefMeth = putByte bh 2
515 0 -> return NoDefMeth
517 _ -> return GenDefMeth
519 instance Binary FixityDirection where
529 0 -> do return InfixL
530 1 -> do return InfixR
531 _ -> do return InfixN
533 instance Binary Fixity where
534 put_ bh (Fixity aa ab) = do
540 return (Fixity aa ab)
542 instance (Binary name) => Binary (IPName name) where
543 put_ bh (IPName aa) = put_ bh aa
544 get bh = do aa <- get bh
547 -------------------------------------------------------------------------
548 -- Types from: Demand
549 -------------------------------------------------------------------------
551 instance Binary DmdType where
552 -- Ignore DmdEnv when spitting out the DmdType
553 put bh (DmdType _ ds dr) = do p <- put bh ds; put bh dr; return (castBin p)
554 get bh = do ds <- get bh; dr <- get bh; return (DmdType emptyVarEnv ds dr)
556 instance Binary Demand where
561 put_ bh (Call aa) = do
564 put_ bh (Eval ab) = do
567 put_ bh (Defer ac) = do
570 put_ bh (Box ad) = do
590 instance Binary Demands where
591 put_ bh (Poly aa) = do
594 put_ bh (Prod ab) = do
605 instance Binary DmdResult where
615 0 -> do return TopRes
616 1 -> do return RetCPR -- Really use RetCPR even if -fcpr-off
617 -- The wrapper was generated for CPR in
618 -- the imported module!
619 _ -> do return BotRes
621 instance Binary StrictSig where
622 put_ bh (StrictSig aa) = do
626 return (StrictSig aa)
629 -------------------------------------------------------------------------
630 -- Types from: CostCentre
631 -------------------------------------------------------------------------
633 instance Binary IsCafCC where
636 put_ bh NotCafCC = do
642 _ -> do return NotCafCC
644 instance Binary IsDupdCC where
645 put_ bh OriginalCC = do
652 0 -> do return OriginalCC
653 _ -> do return DupdCC
655 instance Binary CostCentre where
656 put_ bh NoCostCentre = do
658 put_ bh (NormalCC aa ab ac ad) = do
664 put_ bh (AllCafsCC ae) = do
670 0 -> do return NoCostCentre
675 return (NormalCC aa ab ac ad)
677 return (AllCafsCC ae)
679 -------------------------------------------------------------------------
680 -- IfaceTypes and friends
681 -------------------------------------------------------------------------
683 instance Binary IfaceBndr where
684 put_ bh (IfaceIdBndr aa) = do
687 put_ bh (IfaceTvBndr ab) = do
694 return (IfaceIdBndr aa)
696 return (IfaceTvBndr ab)
698 instance Binary IfaceLetBndr where
699 put_ bh (IfLetBndr a b c) = do
703 get bh = do a <- get bh
706 return (IfLetBndr a b c)
708 instance Binary IfaceType where
709 put_ bh (IfaceForAllTy aa ab) = do
713 put_ bh (IfaceTyVar ad) = do
716 put_ bh (IfaceAppTy ae af) = do
720 put_ bh (IfaceFunTy ag ah) = do
724 put_ bh (IfacePredTy aq) = do
728 -- Simple compression for common cases of TyConApp
729 put_ bh (IfaceTyConApp IfaceIntTc []) = putByte bh 6
730 put_ bh (IfaceTyConApp IfaceCharTc []) = putByte bh 7
731 put_ bh (IfaceTyConApp IfaceBoolTc []) = putByte bh 8
732 put_ bh (IfaceTyConApp IfaceListTc [ty]) = do { putByte bh 9; put_ bh ty }
733 -- Unit tuple and pairs
734 put_ bh (IfaceTyConApp (IfaceTupTc Boxed 0) []) = putByte bh 10
735 put_ bh (IfaceTyConApp (IfaceTupTc Boxed 2) [t1,t2]) = do { putByte bh 11; put_ bh t1; put_ bh t2 }
737 put_ bh (IfaceTyConApp IfaceLiftedTypeKindTc []) = putByte bh 12
738 put_ bh (IfaceTyConApp IfaceOpenTypeKindTc []) = putByte bh 13
739 put_ bh (IfaceTyConApp IfaceUnliftedTypeKindTc []) = putByte bh 14
740 put_ bh (IfaceTyConApp IfaceUbxTupleKindTc []) = putByte bh 15
741 put_ bh (IfaceTyConApp IfaceArgTypeKindTc []) = putByte bh 16
745 put_ bh (IfaceTyConApp (IfaceTc tc) tys) = do { putByte bh 18; put_ bh tc; put_ bh tys }
746 put_ bh (IfaceTyConApp tc tys) = do { putByte bh 19; put_ bh tc; put_ bh tys }
753 return (IfaceForAllTy aa ab)
755 return (IfaceTyVar ad)
758 return (IfaceAppTy ae af)
761 return (IfaceFunTy ag ah)
763 return (IfacePredTy ap)
765 -- Now the special cases for TyConApp
766 6 -> return (IfaceTyConApp IfaceIntTc [])
767 7 -> return (IfaceTyConApp IfaceCharTc [])
768 8 -> return (IfaceTyConApp IfaceBoolTc [])
769 9 -> do { ty <- get bh; return (IfaceTyConApp IfaceListTc [ty]) }
770 10 -> return (IfaceTyConApp (IfaceTupTc Boxed 0) [])
771 11 -> do { t1 <- get bh; t2 <- get bh; return (IfaceTyConApp (IfaceTupTc Boxed 2) [t1,t2]) }
772 12 -> return (IfaceTyConApp IfaceLiftedTypeKindTc [])
773 13 -> return (IfaceTyConApp IfaceOpenTypeKindTc [])
774 14 -> return (IfaceTyConApp IfaceUnliftedTypeKindTc [])
775 15 -> return (IfaceTyConApp IfaceUbxTupleKindTc [])
776 16 -> return (IfaceTyConApp IfaceArgTypeKindTc [])
778 18 -> do { tc <- get bh; tys <- get bh; return (IfaceTyConApp (IfaceTc tc) tys) }
779 _ -> do { tc <- get bh; tys <- get bh; return (IfaceTyConApp tc tys) }
781 instance Binary IfaceTyCon where
782 -- Int,Char,Bool can't show up here because they can't not be saturated
784 put_ bh IfaceIntTc = putByte bh 1
785 put_ bh IfaceBoolTc = putByte bh 2
786 put_ bh IfaceCharTc = putByte bh 3
787 put_ bh IfaceListTc = putByte bh 4
788 put_ bh IfacePArrTc = putByte bh 5
789 put_ bh IfaceLiftedTypeKindTc = putByte bh 6
790 put_ bh IfaceOpenTypeKindTc = putByte bh 7
791 put_ bh IfaceUnliftedTypeKindTc = putByte bh 8
792 put_ bh IfaceUbxTupleKindTc = putByte bh 9
793 put_ bh IfaceArgTypeKindTc = putByte bh 10
794 put_ bh (IfaceTupTc bx ar) = do { putByte bh 11; put_ bh bx; put_ bh ar }
795 put_ bh (IfaceTc ext) = do { putByte bh 12; put_ bh ext }
800 1 -> return IfaceIntTc
801 2 -> return IfaceBoolTc
802 3 -> return IfaceCharTc
803 4 -> return IfaceListTc
804 5 -> return IfacePArrTc
805 6 -> return IfaceLiftedTypeKindTc
806 7 -> return IfaceOpenTypeKindTc
807 8 -> return IfaceUnliftedTypeKindTc
808 9 -> return IfaceUbxTupleKindTc
809 10 -> return IfaceArgTypeKindTc
810 11 -> do { bx <- get bh; ar <- get bh; return (IfaceTupTc bx ar) }
811 _ -> do { ext <- get bh; return (IfaceTc ext) }
813 instance Binary IfacePredType where
814 put_ bh (IfaceClassP aa ab) = do
818 put_ bh (IfaceIParam ac ad) = do
822 put_ bh (IfaceEqPred ac ad) = do
831 return (IfaceClassP aa ab)
834 return (IfaceIParam ac ad)
837 return (IfaceEqPred ac ad)
839 -------------------------------------------------------------------------
840 -- IfaceExpr and friends
841 -------------------------------------------------------------------------
843 instance Binary IfaceExpr where
844 put_ bh (IfaceLcl aa) = do
847 put_ bh (IfaceType ab) = do
850 put_ bh (IfaceTuple ac ad) = do
854 put_ bh (IfaceLam ae af) = do
858 put_ bh (IfaceApp ag ah) = do
863 put_ bh (IfaceCase ai aj al ak) = do
870 put_ bh (IfaceLet al am) = do
874 put_ bh (IfaceNote an ao) = do
878 put_ bh (IfaceLit ap) = do
881 put_ bh (IfaceFCall as at) = do
885 put_ bh (IfaceExt aa) = do
888 put_ bh (IfaceCast ie ico) = do
892 put_ bh (IfaceTick m ix) = do
902 return (IfaceType ab)
905 return (IfaceTuple ac ad)
908 return (IfaceLam ae af)
911 return (IfaceApp ag ah)
918 return (IfaceCase ai aj al ak)
921 return (IfaceLet al am)
924 return (IfaceNote an ao)
929 return (IfaceFCall as at)
930 10 -> do aa <- get bh
932 11 -> do ie <- get bh
934 return (IfaceCast ie ico)
937 return (IfaceTick m ix)
939 instance Binary IfaceConAlt where
940 put_ bh IfaceDefault = do
942 put_ bh (IfaceDataAlt aa) = do
945 put_ bh (IfaceTupleAlt ab) = do
948 put_ bh (IfaceLitAlt ac) = do
954 0 -> do return IfaceDefault
956 return (IfaceDataAlt aa)
958 return (IfaceTupleAlt ab)
960 return (IfaceLitAlt ac)
962 instance Binary IfaceBinding where
963 put_ bh (IfaceNonRec aa ab) = do
967 put_ bh (IfaceRec ac) = do
975 return (IfaceNonRec aa ab)
979 instance Binary IfaceIdInfo where
980 put_ bh NoInfo = putByte bh 0
981 put_ bh (HasInfo i) = do
983 lazyPut bh i -- NB lazyPut
989 _ -> do info <- lazyGet bh -- NB lazyGet
990 return (HasInfo info)
992 instance Binary IfaceInfoItem where
993 put_ bh (HsArity aa) = do
996 put_ bh (HsStrictness ab) = do
999 put_ bh (HsUnfold ad) = do
1002 put_ bh (HsInline ad) = do
1005 put_ bh HsNoCafRefs = do
1007 put_ bh (HsWorker ae af) = do
1014 0 -> do aa <- get bh
1016 1 -> do ab <- get bh
1017 return (HsStrictness ab)
1018 2 -> do ad <- get bh
1019 return (HsUnfold ad)
1020 3 -> do ad <- get bh
1021 return (HsInline ad)
1022 4 -> do return HsNoCafRefs
1023 _ -> do ae <- get bh
1025 return (HsWorker ae af)
1027 instance Binary IfaceNote where
1028 put_ bh (IfaceSCC aa) = do
1031 put_ bh IfaceInlineMe = do
1033 put_ bh (IfaceCoreNote s) = do
1039 0 -> do aa <- get bh
1040 return (IfaceSCC aa)
1041 3 -> do return IfaceInlineMe
1042 4 -> do ac <- get bh
1043 return (IfaceCoreNote ac)
1045 -------------------------------------------------------------------------
1046 -- IfaceDecl and friends
1047 -------------------------------------------------------------------------
1049 -- A bit of magic going on here: there's no need to store the OccName
1050 -- for a decl on the disk, since we can infer the namespace from the
1051 -- context; however it is useful to have the OccName in the IfaceDecl
1052 -- to avoid re-building it in various places. So we build the OccName
1053 -- when de-serialising.
1055 instance Binary IfaceDecl where
1056 put_ bh (IfaceId name ty idinfo) = do
1058 put_ bh (occNameFS name)
1061 put_ bh (IfaceForeign ae af) =
1062 error "Binary.put_(IfaceDecl): IfaceForeign"
1063 put_ bh (IfaceData a1 a2 a3 a4 a5 a6 a7 a8) = do
1065 put_ bh (occNameFS a1)
1073 put_ bh (IfaceSyn a1 a2 a3 a4 a5) = do
1075 put_ bh (occNameFS a1)
1080 put_ bh (IfaceClass a1 a2 a3 a4 a5 a6 a7) = do
1083 put_ bh (occNameFS a2)
1092 0 -> do name <- get bh
1095 occ <- return $! mkOccNameFS varName name
1096 return (IfaceId occ ty idinfo)
1097 1 -> error "Binary.get(TyClDecl): ForeignType"
1107 occ <- return $! mkOccNameFS tcName a1
1108 return (IfaceData occ a2 a3 a4 a5 a6 a7 a8)
1115 occ <- return $! mkOccNameFS tcName a1
1116 return (IfaceSyn occ a2 a3 a4 a5)
1125 occ <- return $! mkOccNameFS clsName a2
1126 return (IfaceClass a1 occ a3 a4 a5 a6 a7)
1128 instance Binary IfaceInst where
1129 put_ bh (IfaceInst cls tys dfun flag orph) = do
1135 get bh = do cls <- get bh
1140 return (IfaceInst cls tys dfun flag orph)
1142 instance Binary IfaceFamInst where
1143 put_ bh (IfaceFamInst fam tys tycon) = do
1147 get bh = do fam <- get bh
1150 return (IfaceFamInst fam tys tycon)
1152 instance Binary OverlapFlag where
1153 put_ bh NoOverlap = putByte bh 0
1154 put_ bh OverlapOk = putByte bh 1
1155 put_ bh Incoherent = putByte bh 2
1156 get bh = do h <- getByte bh
1158 0 -> return NoOverlap
1159 1 -> return OverlapOk
1160 2 -> return Incoherent
1162 instance Binary IfaceConDecls where
1163 put_ bh IfAbstractTyCon = putByte bh 0
1164 put_ bh IfOpenDataTyCon = putByte bh 1
1165 put_ bh (IfDataTyCon cs) = do { putByte bh 2
1167 put_ bh (IfNewTyCon c) = do { putByte bh 3
1172 0 -> return IfAbstractTyCon
1173 1 -> return IfOpenDataTyCon
1174 2 -> do cs <- get bh
1175 return (IfDataTyCon cs)
1176 _ -> do aa <- get bh
1177 return (IfNewTyCon aa)
1179 instance Binary IfaceConDecl where
1180 put_ bh (IfCon a1 a2 a3 a4 a5 a6 a7 a8 a9) = do
1190 get bh = do a1 <- get bh
1199 return (IfCon a1 a2 a3 a4 a5 a6 a7 a8 a9)
1201 instance Binary IfaceClassOp where
1202 put_ bh (IfaceClassOp n def ty) = do
1203 put_ bh (occNameFS n)
1210 occ <- return $! mkOccNameFS varName n
1211 return (IfaceClassOp occ def ty)
1213 instance Binary IfaceRule where
1214 put_ bh (IfaceRule a1 a2 a3 a4 a5 a6 a7) = do
1230 return (IfaceRule a1 a2 a3 a4 a5 a6 a7)
1232 instance Binary IfaceVectInfo where
1233 put_ bh (IfaceVectInfo a1 a2 a3) = do
1241 return (IfaceVectInfo a1 a2 a3)