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"
40 import Control.Exception
43 -- ---------------------------------------------------------------------------
44 -- Reading and writing binary interface files
46 readBinIface :: FilePath -> TcRnIf a b ModIface
47 readBinIface hi_path = do
49 (new_nc, iface) <- ioToIOEnv $ readBinIface_ hi_path nc
53 readBinIface_ :: FilePath -> NameCache -> IO (NameCache, ModIface)
54 readBinIface_ hi_path nc = do
55 bh <- Binary.readBinMem hi_path
57 -- Read the magic number to check that this really is a GHC .hi file
58 -- (This magic number does not change when we change
59 -- GHC interface file format)
61 when (magic /= binaryInterfaceMagic) $
62 throwDyn (ProgramError (
63 "magic number mismatch: old/corrupt interface file?"))
65 -- Get the dictionary pointer. We won't attempt to actually
66 -- read the dictionary until we've done the version checks below,
67 -- just in case this isn't a valid interface. In retrospect the
68 -- version should have come before the dictionary pointer, but this
69 -- is the way it was done originally, and we can't change it now.
70 dict_p <- Binary.get bh -- Get the dictionary ptr
72 -- Check the interface file version and ways.
74 let our_ver = show opt_HiVersion
75 when (check_ver /= our_ver) $
76 -- This will be caught by readIface which will emit an error
77 -- msg containing the iface module name.
78 throwDyn (ProgramError (
79 "mismatched interface file versions: expected "
80 ++ our_ver ++ ", found " ++ check_ver))
83 ignore_way <- readIORef v_IgnoreHiWay
84 way_descr <- getWayDescr
85 when (not ignore_way && check_way /= way_descr) $
86 -- This will be caught by readIface
87 -- which will emit an error msg containing the iface module name.
88 throwDyn (ProgramError (
89 "mismatched interface file ways: expected "
90 ++ way_descr ++ ", found " ++ check_way))
92 -- Read the dictionary
93 -- The next word in the file is a pointer to where the dictionary is
94 -- (probably at the end of the file)
95 data_p <- tellBin bh -- Remember where we are now
97 dict <- getDictionary bh
98 seekBin bh data_p -- Back to where we were before
100 -- Initialise the user-data field of bh
101 ud <- newReadState dict
102 bh <- return (setUserData bh ud)
104 symtab_p <- Binary.get bh -- Get the symtab ptr
105 data_p <- tellBin bh -- Remember where we are now
107 (nc', symtab) <- getSymbolTable bh nc
108 seekBin bh data_p -- Back to where we were before
109 let ud = getUserData bh
110 bh <- return $! setUserData bh ud{ud_symtab = symtab}
115 writeBinIface :: DynFlags -> FilePath -> ModIface -> IO ()
116 writeBinIface dflags hi_path mod_iface = do
117 bh <- openBinMem initBinMemSize
118 put_ bh binaryInterfaceMagic
120 -- Remember where the dictionary pointer will go
121 dict_p_p <- tellBin bh
122 put_ bh dict_p_p -- Placeholder for ptr to dictionary
124 -- The version and way descriptor go next
125 put_ bh (show opt_HiVersion)
126 way_descr <- getWayDescr
129 -- Remember where the symbol table pointer will go
130 symtab_p_p <- tellBin bh
133 -- Make some intial state
136 -- Put the main thing,
137 bh <- return $ setUserData bh ud
140 -- Write the symtab pointer at the fornt of the file
141 symtab_p <- tellBin bh -- This is where the symtab will start
142 putAt bh symtab_p_p symtab_p -- Fill in the placeholder
143 seekBin bh symtab_p -- Seek back to the end of the file
145 -- Write the symbol table itself
146 symtab_next <- readFastMutInt (ud_symtab_next ud)
147 symtab_map <- readIORef (ud_symtab_map ud)
148 putSymbolTable bh symtab_next symtab_map
149 debugTraceMsg dflags 3 (text "writeBinIface:" <+> int symtab_next
152 -- NB. write the dictionary after the symbol table, because
153 -- writing the symbol table may create more dictionary entries.
155 -- Write the dictionary pointer at the fornt of the file
156 dict_p <- tellBin bh -- This is where the dictionary will start
157 putAt bh dict_p_p dict_p -- Fill in the placeholder
158 seekBin bh dict_p -- Seek back to the end of the file
160 -- Write the dictionary itself
161 dict_next <- readFastMutInt (ud_dict_next ud)
162 dict_map <- readIORef (ud_dict_map ud)
163 putDictionary bh dict_next dict_map
164 debugTraceMsg dflags 3 (text "writeBinIface:" <+> int dict_next
165 <+> text "dict entries")
167 -- And send the result to the file
168 writeBinMem bh hi_path
170 initBinMemSize = (1024*1024) :: Int
172 -- The *host* architecture version:
173 #include "MachDeps.h"
175 #if WORD_SIZE_IN_BITS == 32
176 binaryInterfaceMagic = 0x1face :: Word32
177 #elif WORD_SIZE_IN_BITS == 64
178 binaryInterfaceMagic = 0x1face64 :: Word32
181 -- -----------------------------------------------------------------------------
184 putSymbolTable :: BinHandle -> Int -> UniqFM (Int,Name) -> IO ()
185 putSymbolTable bh next_off symtab = do
187 let names = elems (array (0,next_off-1) (eltsUFM symtab))
188 mapM_ (\n -> serialiseName bh n symtab) names
190 getSymbolTable :: BinHandle -> NameCache -> IO (NameCache, Array Int Name)
191 getSymbolTable bh namecache = do
193 od_names <- sequence (replicate sz (get bh))
195 arr = listArray (0,sz-1) names
196 (namecache', names) =
197 mapAccumR (fromOnDiskName arr) namecache od_names
199 return (namecache', arr)
201 type OnDiskName = (PackageId, ModuleName, OccName)
208 fromOnDiskName arr nc (pid, mod_name, occ) =
210 mod = mkModule pid mod_name
213 case lookupOrigNameCache cache mod occ of
214 Just name -> (nc, name)
218 uniq = uniqFromSupply us
219 name = mkExternalName uniq mod occ noSrcLoc
220 new_cache = extendNameCache cache mod occ name
222 case splitUniqSupply us of { (us',_) ->
223 ( nc{ nsUniqs = us', nsNames = new_cache }, name )
226 serialiseName :: BinHandle -> Name -> UniqFM (Int,Name) -> IO ()
227 serialiseName bh name symtab = do
228 let mod = nameModule name
229 put_ bh (modulePackageId mod, moduleName mod, nameOccName name)
231 -- -----------------------------------------------------------------------------
232 -- All the binary instances
235 {-! for IPName derive: Binary !-}
236 {-! for Fixity derive: Binary !-}
237 {-! for FixityDirection derive: Binary !-}
238 {-! for Boxity derive: Binary !-}
239 {-! for StrictnessMark derive: Binary !-}
240 {-! for Activation derive: Binary !-}
243 {-! for Demand derive: Binary !-}
244 {-! for Demands derive: Binary !-}
245 {-! for DmdResult derive: Binary !-}
246 {-! for StrictSig derive: Binary !-}
249 {-! for DefMeth derive: Binary !-}
252 {-! for HsPred derive: Binary !-}
253 {-! for HsType derive: Binary !-}
254 {-! for TupCon derive: Binary !-}
255 {-! for HsTyVarBndr derive: Binary !-}
258 {-! for UfExpr derive: Binary !-}
259 {-! for UfConAlt derive: Binary !-}
260 {-! for UfBinding derive: Binary !-}
261 {-! for UfBinder derive: Binary !-}
262 {-! for HsIdInfo derive: Binary !-}
263 {-! for UfNote derive: Binary !-}
266 {-! for ConDetails derive: Binary !-}
267 {-! for BangType derive: Binary !-}
270 {-! for IsCafCC derive: Binary !-}
271 {-! for IsDupdCC derive: Binary !-}
272 {-! for CostCentre derive: Binary !-}
276 -- ---------------------------------------------------------------------------
277 -- Reading a binary interface into ParsedIface
279 instance Binary ModIface where
283 mi_mod_vers = mod_vers,
285 mi_finsts = hasFamInsts,
288 mi_exports = exports,
289 mi_exp_vers = exp_vers,
290 mi_fixities = fixities,
291 mi_deprecs = deprecs,
294 mi_fam_insts = fam_insts,
296 mi_rule_vers = rule_vers }) = do
319 hasFamInsts <- get bh
321 usages <- {-# SCC "bin_usages" #-} lazyGet bh
322 exports <- {-# SCC "bin_exports" #-} get bh
324 fixities <- {-# SCC "bin_fixities" #-} get bh
325 deprecs <- {-# SCC "bin_deprecs" #-} lazyGet bh
326 decls <- {-# SCC "bin_tycldecls" #-} get bh
327 insts <- {-# SCC "bin_insts" #-} get bh
328 fam_insts <- {-# SCC "bin_fam_insts" #-} get bh
329 rules <- {-# SCC "bin_rules" #-} lazyGet bh
332 mi_module = mod_name,
334 mi_mod_vers = mod_vers,
336 mi_finsts = hasFamInsts,
339 mi_exports = exports,
340 mi_exp_vers = exp_vers,
341 mi_fixities = fixities,
342 mi_deprecs = deprecs,
344 mi_globals = Nothing,
346 mi_fam_insts = fam_insts,
348 mi_rule_vers = rule_vers,
349 -- And build the cached values
350 mi_dep_fn = mkIfaceDepCache deprecs,
351 mi_fix_fn = mkIfaceFixCache fixities,
352 mi_ver_fn = mkIfaceVerCache decls })
354 GLOBAL_VAR(v_IgnoreHiWay, False, Bool)
356 getWayDescr :: IO String
358 tag <- readIORef v_Build_tag
359 if cGhcUnregisterised == "YES" then return ('u':tag) else return tag
360 -- if this is an unregisterised build, make sure our interfaces
361 -- can't be used by a registerised build.
363 -------------------------------------------------------------------------
364 -- Types from: HscTypes
365 -------------------------------------------------------------------------
367 instance Binary Dependencies where
368 put_ bh deps = do put_ bh (dep_mods deps)
369 put_ bh (dep_pkgs deps)
370 put_ bh (dep_orphs deps)
371 put_ bh (dep_finsts deps)
373 get bh = do ms <- get bh
377 return (Deps { dep_mods = ms, dep_pkgs = ps, dep_orphs = os,
380 instance (Binary name) => Binary (GenAvailInfo name) where
381 put_ bh (Avail aa) = do
384 put_ bh (AvailTC ab ac) = do
395 return (AvailTC ab ac)
397 instance Binary Usage where
399 put_ bh (usg_name usg)
400 put_ bh (usg_mod usg)
401 put_ bh (usg_exports usg)
402 put_ bh (usg_entities usg)
403 put_ bh (usg_rules usg)
411 return (Usage { usg_name = nm, usg_mod = mod,
412 usg_exports = exps, usg_entities = ents,
415 instance Binary a => Binary (Deprecs a) where
416 put_ bh NoDeprecs = putByte bh 0
417 put_ bh (DeprecAll t) = do
420 put_ bh (DeprecSome ts) = do
427 0 -> return NoDeprecs
429 return (DeprecAll aa)
431 return (DeprecSome aa)
433 -------------------------------------------------------------------------
434 -- Types from: BasicTypes
435 -------------------------------------------------------------------------
437 instance Binary Activation where
438 put_ bh NeverActive = do
440 put_ bh AlwaysActive = do
442 put_ bh (ActiveBefore aa) = do
445 put_ bh (ActiveAfter ab) = do
451 0 -> do return NeverActive
452 1 -> do return AlwaysActive
454 return (ActiveBefore aa)
456 return (ActiveAfter ab)
458 instance Binary StrictnessMark where
459 put_ bh MarkedStrict = do
461 put_ bh MarkedUnboxed = do
463 put_ bh NotMarkedStrict = do
468 0 -> do return MarkedStrict
469 1 -> do return MarkedUnboxed
470 _ -> do return NotMarkedStrict
472 instance Binary Boxity where
481 _ -> do return Unboxed
483 instance Binary TupCon where
484 put_ bh (TupCon ab ac) = do
490 return (TupCon ab ac)
492 instance Binary RecFlag where
493 put_ bh Recursive = do
495 put_ bh NonRecursive = do
500 0 -> do return Recursive
501 _ -> do return NonRecursive
503 instance Binary DefMeth where
504 put_ bh NoDefMeth = putByte bh 0
505 put_ bh DefMeth = putByte bh 1
506 put_ bh GenDefMeth = putByte bh 2
510 0 -> return NoDefMeth
512 _ -> return GenDefMeth
514 instance Binary FixityDirection where
524 0 -> do return InfixL
525 1 -> do return InfixR
526 _ -> do return InfixN
528 instance Binary Fixity where
529 put_ bh (Fixity aa ab) = do
535 return (Fixity aa ab)
537 instance (Binary name) => Binary (IPName name) where
538 put_ bh (IPName aa) = put_ bh aa
539 get bh = do aa <- get bh
542 -------------------------------------------------------------------------
543 -- Types from: Demand
544 -------------------------------------------------------------------------
546 instance Binary DmdType where
547 -- Ignore DmdEnv when spitting out the DmdType
548 put bh (DmdType _ ds dr) = do p <- put bh ds; put bh dr; return (castBin p)
549 get bh = do ds <- get bh; dr <- get bh; return (DmdType emptyVarEnv ds dr)
551 instance Binary Demand where
556 put_ bh (Call aa) = do
559 put_ bh (Eval ab) = do
562 put_ bh (Defer ac) = do
565 put_ bh (Box ad) = do
585 instance Binary Demands where
586 put_ bh (Poly aa) = do
589 put_ bh (Prod ab) = do
600 instance Binary DmdResult where
610 0 -> do return TopRes
611 1 -> do return RetCPR -- Really use RetCPR even if -fcpr-off
612 -- The wrapper was generated for CPR in
613 -- the imported module!
614 _ -> do return BotRes
616 instance Binary StrictSig where
617 put_ bh (StrictSig aa) = do
621 return (StrictSig aa)
624 -------------------------------------------------------------------------
625 -- Types from: CostCentre
626 -------------------------------------------------------------------------
628 instance Binary IsCafCC where
631 put_ bh NotCafCC = do
637 _ -> do return NotCafCC
639 instance Binary IsDupdCC where
640 put_ bh OriginalCC = do
647 0 -> do return OriginalCC
648 _ -> do return DupdCC
650 instance Binary CostCentre where
651 put_ bh NoCostCentre = do
653 put_ bh (NormalCC aa ab ac ad) = do
659 put_ bh (AllCafsCC ae) = do
665 0 -> do return NoCostCentre
670 return (NormalCC aa ab ac ad)
672 return (AllCafsCC ae)
674 -------------------------------------------------------------------------
675 -- IfaceTypes and friends
676 -------------------------------------------------------------------------
678 instance Binary IfaceBndr where
679 put_ bh (IfaceIdBndr aa) = do
682 put_ bh (IfaceTvBndr ab) = do
689 return (IfaceIdBndr aa)
691 return (IfaceTvBndr ab)
693 instance Binary IfaceType where
694 put_ bh (IfaceForAllTy aa ab) = do
698 put_ bh (IfaceTyVar ad) = do
701 put_ bh (IfaceAppTy ae af) = do
705 put_ bh (IfaceFunTy ag ah) = do
709 put_ bh (IfacePredTy aq) = do
713 -- Simple compression for common cases of TyConApp
714 put_ bh (IfaceTyConApp IfaceIntTc []) = putByte bh 6
715 put_ bh (IfaceTyConApp IfaceCharTc []) = putByte bh 7
716 put_ bh (IfaceTyConApp IfaceBoolTc []) = putByte bh 8
717 put_ bh (IfaceTyConApp IfaceListTc [ty]) = do { putByte bh 9; put_ bh ty }
718 -- Unit tuple and pairs
719 put_ bh (IfaceTyConApp (IfaceTupTc Boxed 0) []) = putByte bh 10
720 put_ bh (IfaceTyConApp (IfaceTupTc Boxed 2) [t1,t2]) = do { putByte bh 11; put_ bh t1; put_ bh t2 }
722 put_ bh (IfaceTyConApp IfaceLiftedTypeKindTc []) = putByte bh 12
723 put_ bh (IfaceTyConApp IfaceOpenTypeKindTc []) = putByte bh 13
724 put_ bh (IfaceTyConApp IfaceUnliftedTypeKindTc []) = putByte bh 14
725 put_ bh (IfaceTyConApp IfaceUbxTupleKindTc []) = putByte bh 15
726 put_ bh (IfaceTyConApp IfaceArgTypeKindTc []) = putByte bh 16
730 put_ bh (IfaceTyConApp (IfaceTc tc) tys) = do { putByte bh 18; put_ bh tc; put_ bh tys }
731 put_ bh (IfaceTyConApp tc tys) = do { putByte bh 19; put_ bh tc; put_ bh tys }
738 return (IfaceForAllTy aa ab)
740 return (IfaceTyVar ad)
743 return (IfaceAppTy ae af)
746 return (IfaceFunTy ag ah)
748 return (IfacePredTy ap)
750 -- Now the special cases for TyConApp
751 6 -> return (IfaceTyConApp IfaceIntTc [])
752 7 -> return (IfaceTyConApp IfaceCharTc [])
753 8 -> return (IfaceTyConApp IfaceBoolTc [])
754 9 -> do { ty <- get bh; return (IfaceTyConApp IfaceListTc [ty]) }
755 10 -> return (IfaceTyConApp (IfaceTupTc Boxed 0) [])
756 11 -> do { t1 <- get bh; t2 <- get bh; return (IfaceTyConApp (IfaceTupTc Boxed 2) [t1,t2]) }
757 12 -> return (IfaceTyConApp IfaceLiftedTypeKindTc [])
758 13 -> return (IfaceTyConApp IfaceOpenTypeKindTc [])
759 14 -> return (IfaceTyConApp IfaceUnliftedTypeKindTc [])
760 15 -> return (IfaceTyConApp IfaceUbxTupleKindTc [])
761 16 -> return (IfaceTyConApp IfaceArgTypeKindTc [])
763 18 -> do { tc <- get bh; tys <- get bh; return (IfaceTyConApp (IfaceTc tc) tys) }
764 _ -> do { tc <- get bh; tys <- get bh; return (IfaceTyConApp tc tys) }
766 instance Binary IfaceTyCon where
767 -- Int,Char,Bool can't show up here because they can't not be saturated
769 put_ bh IfaceIntTc = putByte bh 1
770 put_ bh IfaceBoolTc = putByte bh 2
771 put_ bh IfaceCharTc = putByte bh 3
772 put_ bh IfaceListTc = putByte bh 4
773 put_ bh IfacePArrTc = putByte bh 5
774 put_ bh IfaceLiftedTypeKindTc = putByte bh 6
775 put_ bh IfaceOpenTypeKindTc = putByte bh 7
776 put_ bh IfaceUnliftedTypeKindTc = putByte bh 8
777 put_ bh IfaceUbxTupleKindTc = putByte bh 9
778 put_ bh IfaceArgTypeKindTc = putByte bh 10
779 put_ bh (IfaceTupTc bx ar) = do { putByte bh 11; put_ bh bx; put_ bh ar }
780 put_ bh (IfaceTc ext) = do { putByte bh 12; put_ bh ext }
785 1 -> return IfaceIntTc
786 2 -> return IfaceBoolTc
787 3 -> return IfaceCharTc
788 4 -> return IfaceListTc
789 5 -> return IfacePArrTc
790 6 -> return IfaceLiftedTypeKindTc
791 7 -> return IfaceOpenTypeKindTc
792 8 -> return IfaceUnliftedTypeKindTc
793 9 -> return IfaceUbxTupleKindTc
794 10 -> return IfaceArgTypeKindTc
795 11 -> do { bx <- get bh; ar <- get bh; return (IfaceTupTc bx ar) }
796 _ -> do { ext <- get bh; return (IfaceTc ext) }
798 instance Binary IfacePredType where
799 put_ bh (IfaceClassP aa ab) = do
803 put_ bh (IfaceIParam ac ad) = do
807 put_ bh (IfaceEqPred ac ad) = do
816 return (IfaceClassP aa ab)
819 return (IfaceIParam ac ad)
822 return (IfaceEqPred ac ad)
824 -------------------------------------------------------------------------
825 -- IfaceExpr and friends
826 -------------------------------------------------------------------------
828 instance Binary IfaceExpr where
829 put_ bh (IfaceLcl aa) = do
832 put_ bh (IfaceType ab) = do
835 put_ bh (IfaceTuple ac ad) = do
839 put_ bh (IfaceLam ae af) = do
843 put_ bh (IfaceApp ag ah) = do
848 put_ bh (IfaceCase ai aj al ak) = do
855 put_ bh (IfaceLet al am) = do
859 put_ bh (IfaceNote an ao) = do
863 put_ bh (IfaceLit ap) = do
866 put_ bh (IfaceFCall as at) = do
870 put_ bh (IfaceExt aa) = do
873 put_ bh (IfaceCast ie ico) = do
883 return (IfaceType ab)
886 return (IfaceTuple ac ad)
889 return (IfaceLam ae af)
892 return (IfaceApp ag ah)
899 return (IfaceCase ai aj al ak)
902 return (IfaceLet al am)
905 return (IfaceNote an ao)
910 return (IfaceFCall as at)
911 10 -> do aa <- get bh
913 11 -> do ie <- get bh
915 return (IfaceCast ie ico)
917 instance Binary IfaceConAlt where
918 put_ bh IfaceDefault = do
920 put_ bh (IfaceDataAlt aa) = do
923 put_ bh (IfaceTupleAlt ab) = do
926 put_ bh (IfaceLitAlt ac) = do
932 0 -> do return IfaceDefault
934 return (IfaceDataAlt aa)
936 return (IfaceTupleAlt ab)
938 return (IfaceLitAlt ac)
940 instance Binary IfaceBinding where
941 put_ bh (IfaceNonRec aa ab) = do
945 put_ bh (IfaceRec ac) = do
953 return (IfaceNonRec aa ab)
957 instance Binary IfaceIdInfo where
958 put_ bh NoInfo = putByte bh 0
959 put_ bh (HasInfo i) = do
961 lazyPut bh i -- NB lazyPut
967 _ -> do info <- lazyGet bh -- NB lazyGet
968 return (HasInfo info)
970 instance Binary IfaceInfoItem where
971 put_ bh (HsArity aa) = do
974 put_ bh (HsStrictness ab) = do
977 put_ bh (HsUnfold ad) = do
980 put_ bh (HsInline ad) = do
983 put_ bh HsNoCafRefs = do
985 put_ bh (HsWorker ae af) = do
995 return (HsStrictness ab)
1000 4 -> do return HsNoCafRefs
1001 _ -> do ae <- get bh
1003 return (HsWorker ae af)
1005 instance Binary IfaceNote where
1006 put_ bh (IfaceSCC aa) = do
1009 put_ bh IfaceInlineMe = do
1011 put_ bh (IfaceCoreNote s) = do
1017 0 -> do aa <- get bh
1018 return (IfaceSCC aa)
1019 3 -> do return IfaceInlineMe
1020 4 -> do ac <- get bh
1021 return (IfaceCoreNote ac)
1023 -------------------------------------------------------------------------
1024 -- IfaceDecl and friends
1025 -------------------------------------------------------------------------
1027 -- A bit of magic going on here: there's no need to store the OccName
1028 -- for a decl on the disk, since we can infer the namespace from the
1029 -- context; however it is useful to have the OccName in the IfaceDecl
1030 -- to avoid re-building it in various places. So we build the OccName
1031 -- when de-serialising.
1033 instance Binary IfaceDecl where
1034 put_ bh (IfaceId name ty idinfo) = do
1036 put_ bh (occNameFS name)
1039 put_ bh (IfaceForeign ae af) =
1040 error "Binary.put_(IfaceDecl): IfaceForeign"
1041 put_ bh (IfaceData a1 a2 a3 a4 a5 a6 a7 a8) = do
1043 put_ bh (occNameFS a1)
1051 put_ bh (IfaceSyn aq ar as at) = do
1053 put_ bh (occNameFS aq)
1057 put_ bh (IfaceClass a1 a2 a3 a4 a5 a6 a7) = do
1060 put_ bh (occNameFS a2)
1069 0 -> do name <- get bh
1072 occ <- return $! mkOccNameFS varName name
1073 return (IfaceId occ ty idinfo)
1074 1 -> error "Binary.get(TyClDecl): ForeignType"
1084 occ <- return $! mkOccNameFS tcName a1
1085 return (IfaceData occ a2 a3 a4 a5 a6 a7 a8)
1091 occ <- return $! mkOccNameFS tcName aq
1092 return (IfaceSyn occ ar as at)
1101 occ <- return $! mkOccNameFS clsName a2
1102 return (IfaceClass a1 occ a3 a4 a5 a6 a7)
1104 instance Binary IfaceInst where
1105 put_ bh (IfaceInst cls tys dfun flag orph) = do
1111 get bh = do cls <- get bh
1116 return (IfaceInst cls tys dfun flag orph)
1118 instance Binary IfaceFamInst where
1119 put_ bh (IfaceFamInst fam tys tycon) = do
1123 get bh = do fam <- get bh
1126 return (IfaceFamInst fam tys tycon)
1128 instance Binary OverlapFlag where
1129 put_ bh NoOverlap = putByte bh 0
1130 put_ bh OverlapOk = putByte bh 1
1131 put_ bh Incoherent = putByte bh 2
1132 get bh = do h <- getByte bh
1134 0 -> return NoOverlap
1135 1 -> return OverlapOk
1136 2 -> return Incoherent
1138 instance Binary IfaceConDecls where
1139 put_ bh IfAbstractTyCon = putByte bh 0
1140 put_ bh IfOpenDataTyCon = putByte bh 1
1141 put_ bh IfOpenNewTyCon = putByte bh 2
1142 put_ bh (IfDataTyCon cs) = do { putByte bh 3
1144 put_ bh (IfNewTyCon c) = do { putByte bh 4
1149 0 -> return IfAbstractTyCon
1150 1 -> return IfOpenDataTyCon
1151 2 -> return IfOpenNewTyCon
1152 3 -> do cs <- get bh
1153 return (IfDataTyCon cs)
1154 _ -> do aa <- get bh
1155 return (IfNewTyCon aa)
1157 instance Binary IfaceConDecl where
1158 put_ bh (IfCon a1 a2 a3 a4 a5 a6 a7 a8 a9) = do
1168 get bh = do a1 <- get bh
1177 return (IfCon a1 a2 a3 a4 a5 a6 a7 a8 a9)
1179 instance Binary IfaceClassOp where
1180 put_ bh (IfaceClassOp n def ty) = do
1181 put_ bh (occNameFS n)
1188 occ <- return $! mkOccNameFS varName n
1189 return (IfaceClassOp occ def ty)
1191 instance Binary IfaceRule where
1192 put_ bh (IfaceRule a1 a2 a3 a4 a5 a6 a7) = do
1208 return (IfaceRule a1 a2 a3 a4 a5 a6 a7)