@@ -4,6 +4,7 @@ module Idris.IBC where
5import Idris.Core.Evaluate
5import Idris.Core.Evaluate
6import Idris.Core.TT
6import Idris.Core.TT
7+import Idris.Core.Binary
7import Idris.Core.CaseTree
8import Idris.Core.CaseTree
8import Idris.AbsSyntax
9import Idris.AbsSyntax
9import Idris.Imports
10import Idris.Imports
@@ -617,352 +618,6 @@ instance Binary CGInfo where
617 x4 <- get
618 x4 <- get
618 x5 <- get
619 x5 <- get
619 return (CGInfo x1 x2 [] x4 x5)
620 return (CGInfo x1 x2 [] x4 x5)
621−instance Binary FC where
622− put (FC x1 (x2, x3) (x4, x5))
624− put (x2 * 65536 + x3)
625− put (x4 * 65536 + x5)
630− return (FC x1 (x2x3 `div` 65536, x2x3 `mod` 65536) (x4x5 `div` 65536, x4x5 `mod` 65536))
633−instance Binary Name where
636− UN x1 -> do putWord8 0
638− NS x1 x2 -> do putWord8 1
641− MN x1 x2 -> do putWord8 2
644− NErased -> putWord8 3
645− SN x1 -> do putWord8 4
647− SymRef x1 -> do putWord8 5
665− _ -> error "Corrupted binary data for Name"
667−instance Binary T.Text where
672−instance Binary SpecialName where
675− WhereN x1 x2 x3 -> do putWord8 0
679− InstanceN x1 x2 -> do putWord8 1
682− ParentN x1 x2 -> do putWord8 2
685− MethodN x1 -> do putWord8 3
687− CaseN x1 -> do putWord8 4; put x1
688− ElimN x1 -> do putWord8 5; put x1
689− InstanceCtorN x1 -> do putWord8 6; put x1
696− return (WhereN x1 x2 x3)
699− return (InstanceN x1 x2)
702− return (ParentN x1 x2)
710− return (InstanceCtorN x1)
711− _ -> error "Corrupted binary data for SpecialName"
714−instance Binary Const where
717− I x1 -> do putWord8 0
719− BI x1 -> do putWord8 1
721− Fl x1 -> do putWord8 2
723− Ch x1 -> do putWord8 3
725− Str x1 -> do putWord8 4
727− B8 x1 -> putWord8 5 >> put x1
728− B16 x1 -> putWord8 6 >> put x1
729− B32 x1 -> putWord8 7 >> put x1
730− B64 x1 -> putWord8 8 >> put x1
732− (AType (ATInt ITNative)) -> putWord8 9
733− (AType (ATInt ITBig)) -> putWord8 10
734− (AType ATFloat) -> putWord8 11
735− (AType (ATInt ITChar)) -> putWord8 12
736− StrType -> putWord8 13
737− PtrType -> putWord8 14
738− Forgot -> putWord8 15
739− (AType (ATInt (ITFixed ity))) -> putWord8 (fromIntegral (16 + fromEnum ity)) -- 16-19 inclusive
740− (AType (ATInt (ITVec ity count))) -> do
742− putWord8 (fromIntegral . fromEnum $ ity)
743− putWord8 (fromIntegral count)
745− B8V x1 -> putWord8 21 >> put x1
746− B16V x1 -> putWord8 22 >> put x1
747− B32V x1 -> putWord8 23 >> put x1
748− B64V x1 -> putWord8 24 >> put x1
749− BufferType -> putWord8 25
750− ManagedPtrType -> putWord8 26
769− 9 -> return (AType (ATInt ITNative))
770− 10 -> return (AType (ATInt ITBig))
771− 11 -> return (AType ATFloat)
772− 12 -> return (AType (ATInt ITChar))
773− 13 -> return StrType
774− 14 -> return PtrType
777− 16 -> return (AType (ATInt (ITFixed IT8)))
778− 17 -> return (AType (ATInt (ITFixed IT16)))
779− 18 -> return (AType (ATInt (ITFixed IT32)))
780− 19 -> return (AType (ATInt (ITFixed IT64)))
785− return (AType (ATInt (ITVec (toEnum . fromIntegral $ e) (fromIntegral c))))
791− 25 -> return BufferType
792− 26 -> return ManagedPtrType
794− _ -> error "Corrupted binary data for Const"
797−instance Binary Raw where
800− Var x1 -> do putWord8 0
802− RBind x1 x2 x3 -> do putWord8 1
806− RApp x1 x2 -> do putWord8 2
810− RConstant x1 -> do putWord8 4
812− RForce x1 -> do putWord8 5
822− return (RBind x1 x2 x3)
828− return (RConstant x1)
831− _ -> error "Corrupted binary data for Raw"
834−instance (Binary b) => Binary (Binder b) where
837− Lam x1 -> do putWord8 0
839− Pi x1 -> do putWord8 1
841− Let x1 x2 -> do putWord8 2
844− NLet x1 x2 -> do putWord8 3
847− Hole x1 -> do putWord8 4
849− GHole x1 x2 -> do putWord8 5
852− Guess x1 x2 -> do putWord8 6
855− PVar x1 -> do putWord8 7
857− PVTy x1 -> do putWord8 8
876− return (GHole x1 x2)
879− return (Guess x1 x2)
884− _ -> error "Corrupted binary data for Binder"
887−instance Binary NameType where
892− DCon x1 x2 -> do putWord8 2
893− put (x1 * 65536 + x2)
894− TCon x1 x2 -> do putWord8 3
895− put (x1 * 65536 + x2)
902− return (DCon (x1x2 `div` 65536) (x1x2 `mod` 65536))
904− return (TCon (x1x2 `div` 65536) (x1x2 `mod` 65536))
905− _ -> error "Corrupted binary data for NameType"
908−instance {- (Binary n) => -} Binary (TT Name) where
910− = {-# SCC "putTT" #-}
912− P x1 x2 x3 -> do putWord8 0
916− V x1 -> if (x1 >= 0 && x1 < 256)
918− putWord8 (toEnum (x1 + 1))
921− Bind x1 x2 x3 -> do putWord8 2
925− App x1 x2 -> do putWord8 3
928− Constant x1 -> do putWord8 4
930− Proj x1 x2 -> do putWord8 5
932− putWord8 (toEnum (x2 + 1))
933− Erased -> putWord8 6
934− TType x1 -> do putWord8 7
936− Impossible -> putWord8 8
943− return (P x1 x2 Erased)
944− 1 -> do x1 <- getWord8
945− return (V ((fromEnum x1) - 1))
949− return (Bind x1 x2 x3)
954− return (Constant x1)
957− return (Proj x1 ((fromEnum x2)-1))
961− 8 -> return Impossible
964− _ -> error "Corrupted binary data for TT"
966instance Binary SC where
621instance Binary SC where
968 = case x of
623 = case x of