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
898 return (IfaceType ab)
901 return (IfaceTuple ac ad)
904 return (IfaceLam ae af)
907 return (IfaceApp ag ah)
914 return (IfaceCase ai aj al ak)
917 return (IfaceLet al am)
920 return (IfaceNote an ao)
925 return (IfaceFCall as at)
926 10 -> do aa <- get bh
928 11 -> do ie <- get bh
930 return (IfaceCast ie ico)
932 instance Binary IfaceConAlt where
933 put_ bh IfaceDefault = do
935 put_ bh (IfaceDataAlt aa) = do
938 put_ bh (IfaceTupleAlt ab) = do
941 put_ bh (IfaceLitAlt ac) = do
947 0 -> do return IfaceDefault
949 return (IfaceDataAlt aa)
951 return (IfaceTupleAlt ab)
953 return (IfaceLitAlt ac)
955 instance Binary IfaceBinding where
956 put_ bh (IfaceNonRec aa ab) = do
960 put_ bh (IfaceRec ac) = do
968 return (IfaceNonRec aa ab)
972 instance Binary IfaceIdInfo where
973 put_ bh NoInfo = putByte bh 0
974 put_ bh (HasInfo i) = do
976 lazyPut bh i -- NB lazyPut
982 _ -> do info <- lazyGet bh -- NB lazyGet
983 return (HasInfo info)
985 instance Binary IfaceInfoItem where
986 put_ bh (HsArity aa) = do
989 put_ bh (HsStrictness ab) = do
992 put_ bh (HsUnfold ad) = do
995 put_ bh (HsInline ad) = do
998 put_ bh HsNoCafRefs = do
1000 put_ bh (HsWorker ae af) = do
1007 0 -> do aa <- get bh
1009 1 -> do ab <- get bh
1010 return (HsStrictness ab)
1011 2 -> do ad <- get bh
1012 return (HsUnfold ad)
1013 3 -> do ad <- get bh
1014 return (HsInline ad)
1015 4 -> do return HsNoCafRefs
1016 _ -> do ae <- get bh
1018 return (HsWorker ae af)
1020 instance Binary IfaceNote where
1021 put_ bh (IfaceSCC aa) = do
1024 put_ bh IfaceInlineMe = do
1026 put_ bh (IfaceCoreNote s) = do
1032 0 -> do aa <- get bh
1033 return (IfaceSCC aa)
1034 3 -> do return IfaceInlineMe
1035 4 -> do ac <- get bh
1036 return (IfaceCoreNote ac)
1038 -------------------------------------------------------------------------
1039 -- IfaceDecl and friends
1040 -------------------------------------------------------------------------
1042 -- A bit of magic going on here: there's no need to store the OccName
1043 -- for a decl on the disk, since we can infer the namespace from the
1044 -- context; however it is useful to have the OccName in the IfaceDecl
1045 -- to avoid re-building it in various places. So we build the OccName
1046 -- when de-serialising.
1048 instance Binary IfaceDecl where
1049 put_ bh (IfaceId name ty idinfo) = do
1051 put_ bh (occNameFS name)
1054 put_ bh (IfaceForeign ae af) =
1055 error "Binary.put_(IfaceDecl): IfaceForeign"
1056 put_ bh (IfaceData a1 a2 a3 a4 a5 a6 a7 a8) = do
1058 put_ bh (occNameFS a1)
1066 put_ bh (IfaceSyn a1 a2 a3 a4 a5) = do
1068 put_ bh (occNameFS a1)
1073 put_ bh (IfaceClass a1 a2 a3 a4 a5 a6 a7) = do
1076 put_ bh (occNameFS a2)
1085 0 -> do name <- get bh
1088 occ <- return $! mkOccNameFS varName name
1089 return (IfaceId occ ty idinfo)
1090 1 -> error "Binary.get(TyClDecl): ForeignType"
1100 occ <- return $! mkOccNameFS tcName a1
1101 return (IfaceData occ a2 a3 a4 a5 a6 a7 a8)
1108 occ <- return $! mkOccNameFS tcName a1
1109 return (IfaceSyn occ a2 a3 a4 a5)
1118 occ <- return $! mkOccNameFS clsName a2
1119 return (IfaceClass a1 occ a3 a4 a5 a6 a7)
1121 instance Binary IfaceInst where
1122 put_ bh (IfaceInst cls tys dfun flag orph) = do
1128 get bh = do cls <- get bh
1133 return (IfaceInst cls tys dfun flag orph)
1135 instance Binary IfaceFamInst where
1136 put_ bh (IfaceFamInst fam tys tycon) = do
1140 get bh = do fam <- get bh
1143 return (IfaceFamInst fam tys tycon)
1145 instance Binary OverlapFlag where
1146 put_ bh NoOverlap = putByte bh 0
1147 put_ bh OverlapOk = putByte bh 1
1148 put_ bh Incoherent = putByte bh 2
1149 get bh = do h <- getByte bh
1151 0 -> return NoOverlap
1152 1 -> return OverlapOk
1153 2 -> return Incoherent
1155 instance Binary IfaceConDecls where
1156 put_ bh IfAbstractTyCon = putByte bh 0
1157 put_ bh IfOpenDataTyCon = putByte bh 1
1158 put_ bh (IfDataTyCon cs) = do { putByte bh 2
1160 put_ bh (IfNewTyCon c) = do { putByte bh 3
1165 0 -> return IfAbstractTyCon
1166 1 -> return IfOpenDataTyCon
1167 2 -> do cs <- get bh
1168 return (IfDataTyCon cs)
1169 _ -> do aa <- get bh
1170 return (IfNewTyCon aa)
1172 instance Binary IfaceConDecl where
1173 put_ bh (IfCon a1 a2 a3 a4 a5 a6 a7 a8 a9) = do
1183 get bh = do a1 <- get bh
1192 return (IfCon a1 a2 a3 a4 a5 a6 a7 a8 a9)
1194 instance Binary IfaceClassOp where
1195 put_ bh (IfaceClassOp n def ty) = do
1196 put_ bh (occNameFS n)
1203 occ <- return $! mkOccNameFS varName n
1204 return (IfaceClassOp occ def ty)
1206 instance Binary IfaceRule where
1207 put_ bh (IfaceRule a1 a2 a3 a4 a5 a6 a7) = do
1223 return (IfaceRule a1 a2 a3 a4 a5 a6 a7)
1225 instance Binary IfaceVectInfo where
1226 put_ bh (IfaceVectInfo a1 a2 a3) = do
1234 return (IfaceVectInfo a1 a2 a3)