@@ -4,6 +4,7 @@ import Core.Context
4
4
import Core.Context.Log
5
5
import Core.Core
6
6
import Core.Hash
7
+ import Core.Name.Namespace
7
8
import Core.Normalise
8
9
import Core.Options
9
10
import Core.TT
@@ -31,7 +32,7 @@ import Data.Buffer
31
32
-- TTC files can only be compatible if the version number is the same
32
33
export
33
34
ttcVersion : Int
34
- ttcVersion = 52
35
+ ttcVersion = 53
35
36
36
37
export
37
38
checkTTCVersion : String -> Int -> Int -> Core ()
@@ -177,11 +178,12 @@ writeTTCFile b file_in
177
178
toBuf b (version file)
178
179
toBuf b (ifaceHash file)
179
180
toBuf b (importHashes file)
181
+ toBuf b (imported file)
182
+ toBuf b (extraData file)
180
183
toBuf b (context file)
181
184
toBuf b (userHoles file)
182
185
toBuf b (autoHints file)
183
186
toBuf b (typeHints file)
184
- toBuf b (imported file)
185
187
toBuf b (nextVar file)
186
188
toBuf b (currentNS file)
187
189
toBuf b (nestedNS file)
@@ -191,41 +193,45 @@ writeTTCFile b file_in
191
193
toBuf b (namedirectives file)
192
194
toBuf b (cgdirectives file)
193
195
toBuf b (transforms file)
194
- toBuf b (extraData file)
195
196
196
197
readTTCFile : TTC extra =>
197
198
{auto c : Ref Ctxt Defs} ->
198
- String -> Maybe (Namespace) ->
199
+ Bool -> String -> Maybe (Namespace) ->
199
200
Ref Bin Binary -> Core (TTCFile extra)
200
- readTTCFile file as b
201
+ readTTCFile readall file as b
201
202
= do hdr <- fromBuf b
202
203
chunk <- get Bin
203
204
when (hdr /= " TT2" ) $ corrupt (" TTC header in " ++ file ++ " " ++ show hdr)
204
205
ver <- fromBuf b
205
206
checkTTCVersion file ver ttcVersion
206
207
ifaceHash <- fromBuf b
207
208
importHashes <- fromBuf b
208
- defs <- fromBuf b
209
- uholes <- fromBuf b
210
- autohs <- fromBuf b
211
- typehs <- fromBuf b
212
- -- coreLift $ putStrLn ("Hints: " ++ show typehs)
213
- -- coreLift $ putStrLn $ "Read " ++ show (length (map fullname defs)) ++ " defs"
214
209
imp <- fromBuf b
215
- nextv <- fromBuf b
216
- cns <- fromBuf b
217
- nns <- fromBuf b
218
- pns <- fromBuf b
219
- rws <- fromBuf b
220
- prims <- fromBuf b
221
- nds <- fromBuf b
222
- cgds <- fromBuf b
223
- trans <- fromBuf b
224
210
ex <- fromBuf b
225
- pure (MkTTCFile ver ifaceHash importHashes
226
- defs uholes
227
- autohs typehs imp nextv cns nns
228
- pns rws prims nds cgds trans ex)
211
+ if not readall
212
+ then pure (MkTTCFile ver ifaceHash importHashes [] [] [] [] []
213
+ 0 (mkNamespace " " ) [] Nothing
214
+ Nothing
215
+ (MkPrimNs Nothing Nothing Nothing Nothing )
216
+ [] [] [] ex)
217
+ else do
218
+ defs <- fromBuf b
219
+ uholes <- fromBuf b
220
+ autohs <- fromBuf b
221
+ typehs <- fromBuf b
222
+ nextv <- fromBuf b
223
+ cns <- fromBuf b
224
+ nns <- fromBuf b
225
+ pns <- fromBuf b
226
+ rws <- fromBuf b
227
+ prims <- fromBuf b
228
+ nds <- fromBuf b
229
+ cgds <- fromBuf b
230
+ trans <- fromBuf b
231
+ pure (MkTTCFile ver ifaceHash importHashes
232
+ defs uholes
233
+ autohs typehs imp nextv cns nns
234
+ pns rws prims nds cgds trans ex)
229
235
230
236
-- Pull out the list of GlobalDefs that we want to save
231
237
getSaveDefs : List Name -> List (Name, Binary) -> Defs ->
@@ -422,15 +428,17 @@ readFromTTC nestedns loc reexp fname modNS importAs
422
428
let as = if importAs == miAsNamespace modNS
423
429
then Nothing
424
430
else Just importAs
425
- ttc <- readTTCFile fname as bin
426
431
427
432
-- If it's already imported, but without reexporting, then all we're
428
433
-- interested in is returning which other modules to load.
429
434
-- Otherwise, add the data
430
- let ex = extraData ttc
431
435
if alreadyDone modNS importAs (allImported defs)
432
- then pure (Just (ex, ifaceHash ttc, imported ttc))
436
+ then do ttc <- readTTCFile False fname as bin
437
+ let ex = extraData ttc
438
+ pure (Just (ex, ifaceHash ttc, imported ttc))
433
439
else do
440
+ ttc <- readTTCFile True fname as bin
441
+ let ex = extraData ttc
434
442
traverse_ (addGlobalDef modNS as) (context ttc)
435
443
traverse_ addUserHole (userHoles ttc)
436
444
setNS (currentNS ttc)
0 commit comments