@@ -17,6 +17,7 @@ import Core.UnifyState
17
17
18
18
import Data.Buffer
19
19
import Data.List
20
+ import Data.String
20
21
21
22
import System.File
22
23
@@ -31,7 +32,7 @@ import public Libraries.Utils.Binary
31
32
||| (Increment this when changing anything in the data format)
32
33
export
33
34
ttcVersion : Int
34
- ttcVersion = 61
35
+ ttcVersion = 62
35
36
36
37
export
37
38
checkTTCVersion : String -> Int -> Int -> Core ()
@@ -41,6 +42,7 @@ checkTTCVersion file ver exp
41
42
record TTCFile extra where
42
43
constructor MkTTCFile
43
44
version : Int
45
+ totalReq : TotalReq
44
46
sourceHash : String
45
47
ifaceHash : Int
46
48
importHashes : List (Namespace, Int)
@@ -93,14 +95,14 @@ HasNames (Name, Name, Bool) where
93
95
resolved c (n1, n2, b) = pure (! (resolved c n1), ! (resolved c n2), b)
94
96
95
97
HasNames e => HasNames (TTCFile e) where
96
- full gam (MkTTCFile version sourceHash ifaceHash iHashes incData
98
+ full gam (MkTTCFile version totalReq sourceHash ifaceHash iHashes incData
97
99
context userHoles
98
100
autoHints typeHints
99
101
imported nextVar currentNS nestedNS
100
102
pairnames rewritenames primnames
101
103
namedirectives cgdirectives trans
102
104
extra)
103
- = pure $ MkTTCFile version sourceHash ifaceHash iHashes incData
105
+ = pure $ MkTTCFile version totalReq sourceHash ifaceHash iHashes incData
104
106
context userHoles
105
107
! (traverse (full gam) autoHints)
106
108
! (traverse (full gam) typeHints)
@@ -131,14 +133,14 @@ HasNames e => HasNames (TTCFile e) where
131
133
-- I don't think we ever actually want to call this, because after we read
132
134
-- from the file we're going to add them to learn what the resolved names
133
135
-- are supposed to be! But for completeness, let's do it right.
134
- resolved gam (MkTTCFile version sourceHash ifaceHash iHashes incData
136
+ resolved gam (MkTTCFile version totalReq sourceHash ifaceHash iHashes incData
135
137
context userHoles
136
138
autoHints typeHints
137
139
imported nextVar currentNS nestedNS
138
140
pairnames rewritenames primnames
139
141
namedirectives cgdirectives trans
140
142
extra)
141
- = pure $ MkTTCFile version sourceHash ifaceHash iHashes incData
143
+ = pure $ MkTTCFile version totalReq sourceHash ifaceHash iHashes incData
142
144
context userHoles
143
145
! (traverse (resolved gam) autoHints)
144
146
! (traverse (resolved gam) typeHints)
@@ -177,6 +179,7 @@ writeTTCFile b file_in
177
179
= do file <- toFullNames file_in
178
180
toBuf b " TT2"
179
181
toBuf @{Wasteful } b (version file)
182
+ toBuf b (totalReq file)
180
183
toBuf b (sourceHash file)
181
184
toBuf b (ifaceHash file)
182
185
toBuf b (importHashes file)
@@ -204,17 +207,20 @@ readTTCFile : TTC extra =>
204
207
readTTCFile readall file as b
205
208
= do hdr <- fromBuf b
206
209
chunk <- get Bin
207
- when (hdr /= " TT2" ) $ corrupt (" TTC header in " ++ file ++ " " ++ show hdr)
210
+ when (hdr /= " TT2" ) $
211
+ corrupt (" TTC header in " ++ file ++ " " ++ show hdr)
208
212
ver <- fromBuf @{Wasteful } b
209
213
checkTTCVersion file ver ttcVersion
214
+ totalReq <- fromBuf b
210
215
sourceFileHash <- fromBuf b
211
216
ifaceHash <- fromBuf b
212
217
importHashes <- fromBuf b
213
218
incData <- fromBuf b
214
219
imp <- fromBuf b
215
220
ex <- fromBuf b
216
221
if not readall
217
- then pure (MkTTCFile ver sourceFileHash ifaceHash importHashes
222
+ then pure (MkTTCFile ver totalReq
223
+ sourceFileHash ifaceHash importHashes
218
224
incData [] [] [] [] []
219
225
0 (mkNamespace " " ) [] Nothing
220
226
Nothing
@@ -234,7 +240,8 @@ readTTCFile readall file as b
234
240
nds <- fromBuf b
235
241
cgds <- fromBuf b
236
242
trans <- fromBuf b
237
- pure (MkTTCFile ver sourceFileHash ifaceHash importHashes incData
243
+ pure (MkTTCFile ver totalReq
244
+ sourceFileHash ifaceHash importHashes incData
238
245
(map (replaceNS cns) defs) uholes
239
246
autohs typehs imp nextv cns nns
240
247
pns rws prims nds cgds trans ex)
@@ -278,9 +285,15 @@ writeToTTC extradata sourceFileName ttcFileName
278
285
ust <- get UST
279
286
gdefs <- getSaveDefs (currentNS defs) (keys (toSave defs)) [] defs
280
287
sourceHash <- hashFileWith defs. options. hashFn sourceFileName
281
- log " ttc.write" 5 $ " Writing " ++ ttcFileName ++ " with source hash " ++ sourceHash ++ " and interface hash " ++ show (ifaceHash defs)
288
+ totalReq <- getDefaultTotalityOption
289
+ log " ttc.write" 5 $ unwords
290
+ [ " Writing" , ttcFileName
291
+ , " with source hash" , sourceHash
292
+ , " and interface hash" , show (ifaceHash defs)
293
+ ]
282
294
writeTTCFile bin
283
- (MkTTCFile ttcVersion (sourceHash) (ifaceHash defs) (importHashes defs)
295
+ (MkTTCFile ttcVersion totalReq
296
+ sourceHash (ifaceHash defs) (importHashes defs)
284
297
(incData defs)
285
298
gdefs
286
299
(keys (userHoles defs))
@@ -507,17 +520,38 @@ getImportHashes file b
507
520
when (hdr /= " TT2" ) $ corrupt (" TTC header in " ++ file ++ " " ++ show hdr)
508
521
ver <- fromBuf @{Wasteful } b
509
522
checkTTCVersion file ver ttcVersion
523
+ totalReq <- fromBuf {a = TotalReq } b
510
524
sourceFileHash <- fromBuf {a = String } b
511
525
interfaceHash <- fromBuf {a = Int } b
512
526
fromBuf b
513
527
528
+ export
529
+ getTotalReq : String -> Ref Bin Binary -> Core TotalReq
530
+ getTotalReq file b
531
+ = do hdr <- fromBuf {a = String } b
532
+ when (hdr /= " TT2" ) $ corrupt (" TTC header in " ++ file ++ " " ++ show hdr)
533
+ ver <- fromBuf @{Wasteful } b
534
+ checkTTCVersion file ver ttcVersion
535
+ fromBuf b
536
+
537
+ export
538
+ readTotalReq : (fileName : String) -> -- file containing the module
539
+ Core (Maybe TotalReq )
540
+ readTotalReq fileName
541
+ = do Right buffer <- coreLift $ readFromFile fileName
542
+ | Left err => pure Nothing
543
+ b <- newRef Bin buffer
544
+ catch (Just <$> getTotalReq fileName b)
545
+ (\ err => pure Nothing )
546
+
514
547
export
515
548
getHashes : String -> Ref Bin Binary -> Core (String, Int)
516
549
getHashes file b
517
550
= do hdr <- fromBuf {a = String } b
518
551
when (hdr /= " TT2" ) $ corrupt (" TTC header in " ++ file ++ " " ++ show hdr)
519
552
ver <- fromBuf @{Wasteful } b
520
553
checkTTCVersion file ver ttcVersion
554
+ totReq <- fromBuf {a = TotalReq } b
521
555
sourceFileHash <- fromBuf b
522
556
interfaceHash <- fromBuf b
523
557
pure (sourceFileHash, interfaceHash)
@@ -529,8 +563,7 @@ readHashes fileName
529
563
= do Right buffer <- coreLift $ readFromFile fileName
530
564
| Left err => pure (" " , 0 )
531
565
b <- newRef Bin buffer
532
- catch (do hashes <- getHashes fileName b
533
- pure hashes)
566
+ catch (getHashes fileName b)
534
567
(\ err => pure (" " , 0 ))
535
568
536
569
export
0 commit comments