@@ -24,9 +24,8 @@ import System.Directory
24import Codec.Compression.Zlib (compress)
24import Codec.Compression.Zlib (compress)
25import Util.Zlib (decompressEither)
25import Util.Zlib (decompressEither)
28ibcVersion :: Word8
27ibcVersion :: Word8
29−ibcVersion = 60
28+ibcVersion = 61
32data IBCFile = IBCFile { ver :: Word8,
31data IBCFile = IBCFile { ver :: Word8,
@@ -61,7 +60,8 @@ data IBCFile = IBCFile { ver :: Word8,
61 ibc_namehints :: [(Name, Name)],
60 ibc_namehints :: [(Name, Name)],
62 ibc_metainformation :: [(Name, MetaInformation)],
61 ibc_metainformation :: [(Name, MetaInformation)],
63 ibc_errorhandlers :: [Name],
62 ibc_errorhandlers :: [Name],
64− ibc_function_errorhandlers :: [(Name, Name, Name)] -- fn, arg, handler
63+ ibc_function_errorhandlers :: [(Name, Name, Name)], -- fn, arg, handler
64+ ibc_metavars :: [(Name, (Maybe Name, Int, Bool))]
66 deriving Show
66 deriving Show
@@ -69,8 +69,7 @@ deriving instance Binary IBCFile
71initIBC :: IBCFile
71initIBC :: IBCFile
72−initIBC = IBCFile ibcVersion "" [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] []
72+initIBC = IBCFile ibcVersion "" [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] []
75loadIBC :: FilePath -> Idris ()
74loadIBC :: FilePath -> Idris ()
76loadIBC fp = do iLOG $ "Loading ibc " ++ fp
75loadIBC fp = do iLOG $ "Loading ibc " ++ fp
@@ -91,9 +90,9 @@ writeIBC :: FilePath -> FilePath -> Idris ()
91writeIBC src f
90writeIBC src f
92 = do iLOG $ "Writing ibc " ++ show f
91 = do iLOG $ "Writing ibc " ++ show f
93 i <- getIState
92 i <- getIState
94− case (Data.List.map fst (idris_metavars i)) \\ primDefs of
93+-- case (Data.List.map fst (idris_metavars i)) \\ primDefs of
95− (_:_) -> ifail "Can't write ibc when there are unsolved metavariables"
94+-- (_:_) -> ifail "Can't write ibc when there are unsolved metavariables"
96− [] -> return ()
95+-- [] -> return ()
97 resetNameIdx
96 resetNameIdx
98 ibcf <- mkIBC (ibc_write i) (initIBC { sourcefile = src })
97 ibcf <- mkIBC (ibc_write i) (initIBC { sourcefile = src })
99 idrisCatch (do runIO $ createDirectoryIfMissing True (dropFileName f)
98 idrisCatch (do runIO $ createDirectoryIfMissing True (dropFileName f)
@@ -222,6 +221,10 @@ ibc i (IBCMetaInformation n m) f = return f { ibc_metainformation = (n,m) : ibc_
222ibc i (IBCErrorHandler n) f = return f { ibc_errorhandlers = n : ibc_errorhandlers f }
221ibc i (IBCErrorHandler n) f = return f { ibc_errorhandlers = n : ibc_errorhandlers f }
223ibc i (IBCFunctionErrorHandler fn a n) f =
222ibc i (IBCFunctionErrorHandler fn a n) f =
224 return f { ibc_function_errorhandlers = (fn, a, n) : ibc_function_errorhandlers f }
223 return f { ibc_function_errorhandlers = (fn, a, n) : ibc_function_errorhandlers f }
224+ibc i (IBCMetavar n) f =
225+ case lookup n (idris_metavars i) of
227+ Just t -> return f { ibc_metavars = (n, t) : ibc_metavars f }
226process :: IBCFile -> FilePath -> Idris ()
229process :: IBCFile -> FilePath -> Idris ()
227process i fn
230process i fn
@@ -262,6 +265,7 @@ process i fn
262 pMetaInformation (ibc_metainformation i)
265 pMetaInformation (ibc_metainformation i)
263 pErrorHandlers (ibc_errorhandlers i)
266 pErrorHandlers (ibc_errorhandlers i)
264 pFunctionErrorHandlers (ibc_function_errorhandlers i)
267 pFunctionErrorHandlers (ibc_function_errorhandlers i)
268+ pMetavars (ibc_metavars i)
266timestampOlder :: FilePath -> FilePath -> IO ()
270timestampOlder :: FilePath -> FilePath -> IO ()
267timestampOlder src ibc = do srct <- getModificationTime src
271timestampOlder src ibc = do srct <- getModificationTime src
@@ -451,6 +455,12 @@ pFunctionErrorHandlers :: [(Name, Name, Name)] -> Idris ()
451pFunctionErrorHandlers [] = return ()
455pFunctionErrorHandlers [] = return ()
452pFunctionErrorHandlers ((fn, arg, handler):ns) = do addFunctionErrorHandlers fn arg [handler]
456pFunctionErrorHandlers ((fn, arg, handler):ns) = do addFunctionErrorHandlers fn arg [handler]
453 pFunctionErrorHandlers ns
457 pFunctionErrorHandlers ns
459+pMetavars :: [(Name, (Maybe Name, Int, Bool))] -> Idris ()
460+pMetavars ns = do i <- getIState
461+ putIState $ i { idris_metavars = Data.List.reverse ns
462+ ++ idris_metavars i }
454----- Generated by 'derive'
464----- Generated by 'derive'
456instance Binary SizeChange where
466instance Binary SizeChange where
@@ -1037,7 +1047,7 @@ instance Binary MetaInformation where
1037 return (DataMI x1)
1047 return (DataMI x1)
1039instance Binary IBCFile where
1049instance Binary IBCFile where
1040− put x@(IBCFile x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14 x15 x16 x17 x18 x19 x20 x21 x22 x23 x24 x25 x26 x27 x28 x29 x30 x31 x32 x33)
1050+ put x@(IBCFile x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14 x15 x16 x17 x18 x19 x20 x21 x22 x23 x24 x25 x26 x27 x28 x29 x30 x31 x32 x33 x34)
1041 = {-# SCC "putIBCFile" #-}
1051 = {-# SCC "putIBCFile" #-}
1042 do put x1
1052 do put x1
@@ -1072,6 +1082,7 @@ instance Binary IBCFile where
1077 = do x1 <- get
1088 = do x1 <- get
@@ -1108,7 +1119,8 @@ instance Binary IBCFile where
1108 x31 <- get
1119 x31 <- get
1109 x32 <- get
1120 x32 <- get
1110 x33 <- get
1121 x33 <- get
1111− return (IBCFile x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14 x15 x16 x17 x18 x19 x20 x21 x22 x23 x24 x25 x26 x27 x28 x29 x30 x31 x32 x33)
1123+ return (IBCFile x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14 x15 x16 x17 x18 x19 x20 x21 x22 x23 x24 x25 x26 x27 x28 x29 x30 x31 x32 x33 x34)
1112 else return (initIBC { ver = x1 })
1124 else return (initIBC { ver = x1 })
1114instance Binary DataOpt where
1126instance Binary DataOpt where