@@ -22,7 +22,7 @@ import System.Directory
22import Paths_idris
22import Paths_idris
24ibcVersion :: Word8
24ibcVersion :: Word8
25−ibcVersion = 9
25+ibcVersion = 10
27data IBCFile = IBCFile { ver :: Word8,
27data IBCFile = IBCFile { ver :: Word8,
28 sourcefile :: FilePath,
28 sourcefile :: FilePath,
@@ -31,6 +31,7 @@ data IBCFile = IBCFile { ver :: Word8,
31 ibc_fixes :: [FixDecl],
31 ibc_fixes :: [FixDecl],
32 ibc_statics :: [(Name, [Bool])],
32 ibc_statics :: [(Name, [Bool])],
33 ibc_classes :: [(Name, ClassInfo)],
33 ibc_classes :: [(Name, ClassInfo)],
34+ ibc_dsls :: [(Name, DSL)],
34 ibc_datatypes :: [(Name, TypeInfo)],
35 ibc_datatypes :: [(Name, TypeInfo)],
35 ibc_optimise :: [(Name, OptInfo)],
36 ibc_optimise :: [(Name, OptInfo)],
36 ibc_syntax :: [Syntax],
37 ibc_syntax :: [Syntax],
@@ -45,7 +46,7 @@ deriving instance Binary IBCFile
47initIBC :: IBCFile
48initIBC :: IBCFile
48−initIBC = IBCFile ibcVersion "" [] [] [] [] [] [] [] [] [] [] [] [] [] []
49+initIBC = IBCFile ibcVersion "" [] [] [] [] [] [] [] [] [] [] [] [] [] [] []
50loadIBC :: FilePath -> Idris ()
51loadIBC :: FilePath -> Idris ()
51loadIBC fp = do iLOG $ "Loading ibc " ++ fp
52loadIBC fp = do iLOG $ "Loading ibc " ++ fp
@@ -84,6 +85,10 @@ ibc i (IBCClass n) f
84 = case lookupCtxt Nothing n (idris_classes i) of
85 = case lookupCtxt Nothing n (idris_classes i) of
85 [v] -> return f { ibc_classes = (n,v): ibc_classes f }
86 [v] -> return f { ibc_classes = (n,v): ibc_classes f }
86 _ -> fail "IBC write failed"
87 _ -> fail "IBC write failed"
89+ = case lookupCtxt Nothing n (idris_dsls i) of
90+ [v] -> return f { ibc_dsls = (n,v): ibc_dsls f }
91+ _ -> fail "IBC write failed"
87ibc i (IBCData n) f
92ibc i (IBCData n) f
88 = case lookupCtxt Nothing n (idris_datatypes i) of
93 = case lookupCtxt Nothing n (idris_datatypes i) of
89 [v] -> return f { ibc_datatypes = (n,v): ibc_datatypes f }
94 [v] -> return f { ibc_datatypes = (n,v): ibc_datatypes f }
@@ -116,6 +121,7 @@ process i fn
116 pFixes (ibc_fixes i)
121 pFixes (ibc_fixes i)
117 pStatics (ibc_statics i)
122 pStatics (ibc_statics i)
118 pClasses (ibc_classes i)
123 pClasses (ibc_classes i)
119 pDatatypes (ibc_datatypes i)
125 pDatatypes (ibc_datatypes i)
120 pOptimise (ibc_optimise i)
126 pOptimise (ibc_optimise i)
121 pSyntax (ibc_syntax i)
127 pSyntax (ibc_syntax i)
@@ -174,6 +180,13 @@ pClasses cs = mapM_ (\ (n, c) ->
174 = addDef n c (idris_classes i) }))
180 = addDef n c (idris_classes i) }))
183+pDSLs :: [(Name, DSL)] -> Idris ()
184+pDSLs cs = mapM_ (\ (n, c) ->
186+ putIState (i { idris_dsls
187+ = addDef n c (idris_dsls i) }))
177pDatatypes :: [(Name, TypeInfo)] -> Idris ()
190pDatatypes :: [(Name, TypeInfo)] -> Idris ()
178pDatatypes cs = mapM_ (\ (n, c) ->
191pDatatypes cs = mapM_ (\ (n, c) ->
179 do i <- getIState
192 do i <- getIState
@@ -568,7 +581,7 @@ instance Binary Accessibility where
568 _ -> error "Corrupted binary data for Accessibility"
581 _ -> error "Corrupted binary data for Accessibility"
570instance Binary IBCFile where
583instance Binary IBCFile where
571− put (IBCFile x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14 x15 x16)
584+ put (IBCFile x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14 x15 x16 x17)
572 = do put x1
585 = do put x1
@@ -585,6 +598,7 @@ instance Binary IBCFile where
589 = do x1 <- get
603 = do x1 <- get
590 if x1 == ibcVersion then
604 if x1 == ibcVersion then
@@ -603,7 +617,8 @@ instance Binary IBCFile where
603 x14 <- get
617 x14 <- get
604 x15 <- get
618 x15 <- get
605 x16 <- get
619 x16 <- get
606− return (IBCFile x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14 x15 x16)
621+ return (IBCFile x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14 x15 x16 x17)
607 else return (initIBC { ver = x1 })
622 else return (initIBC { ver = x1 })
609instance Binary Fixity where
624instance Binary Fixity where
@@ -1024,6 +1039,28 @@ instance Binary Syntax where
1024 x3 <- get
1039 x3 <- get
1025 return (Rule x1 x2 x3)
1040 return (Rule x1 x2 x3)
1042+instance (Binary t) => Binary (DSL' t) where
1043+ put (DSL x1 x2 x3 x4 x5 x6 x7 x8 x9)
1063+ return (DSL x1 x2 x3 x4 x5 x6 x7 x8 x9)
1028instance Binary SSymbol where
1065instance Binary SSymbol where