summaryrefslogtreecommitdiff
path: root/compiler/main/Annotations.hs
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/main/Annotations.hs')
-rw-r--r--compiler/main/Annotations.hs14
1 files changed, 14 insertions, 0 deletions
diff --git a/compiler/main/Annotations.hs b/compiler/main/Annotations.hs
index 277c059b11..ec179d86e2 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
@@ -64,6 +65,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 -> get bh >>= (return . NamedTarget)
+ _ -> get bh >>= (return . ModuleTarget)
+
instance Outputable Annotation where
ppr ann = ppr (ann_target ann)