diff options
Diffstat (limited to 'compiler/main/Annotations.hs')
-rw-r--r-- | compiler/main/Annotations.hs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/compiler/main/Annotations.hs b/compiler/main/Annotations.hs index 277c059b11..7de1a9914b 100644 --- a/compiler/main/Annotations.hs +++ b/compiler/main/Annotations.hs @@ -16,6 +16,7 @@ module Annotations ( deserializeAnns ) where +import Binary import Module ( Module ) import Name import Outputable @@ -23,6 +24,7 @@ import Serialized import UniqFM import Unique +import Control.Monad import Data.Maybe import Data.Typeable import Data.Word ( Word8 ) @@ -64,6 +66,19 @@ instance Outputable name => Outputable (AnnTarget name) where ppr (NamedTarget nm) = text "Named target" <+> ppr nm ppr (ModuleTarget mod) = text "Module target" <+> ppr mod +instance Binary name => Binary (AnnTarget name) where + put_ bh (NamedTarget a) = do + putByte bh 0 + put_ bh a + put_ bh (ModuleTarget a) = do + putByte bh 1 + put_ bh a + get bh = do + h <- getByte bh + case h of + 0 -> liftM NamedTarget $ get bh + _ -> liftM ModuleTarget $ get bh + instance Outputable Annotation where ppr ann = ppr (ann_target ann) |