SCM Repository
Annotation of /sml/trunk/src/compiler/Semant/pickle/rehash.sml
Parent Directory
|
Revision Log
Revision 1137 - (view) (download)
1 : | blume | 879 | (* rehash.sml |
2 : | * | ||
3 : | * (C) 2001 Lucent Technologies, Bell Labs | ||
4 : | * | ||
5 : | * Compute hash for a library that is the product of filtering | ||
6 : | * a larger environment. Since every environment (after unpickling) | ||
7 : | * contains references to its own hash id, re-hashing requires | ||
8 : | * the original hash id (to be able to recognize it). The result | ||
9 : | * of re-hashing will then be the same value that would have been | ||
10 : | * produced had the smaller environment been pickled (and hashed) in | ||
11 : | * the first place. *) | ||
12 : | blume | 1058 | structure Rehash : sig |
13 : | blume | 1137 | val addGUID : { hash: PersStamps.persstamp, guid: string } |
14 : | blume | 1058 | -> PersStamps.persstamp |
15 : | val rehash : { env: StaticEnv.staticEnv, | ||
16 : | orig_pid: PersStamps.persstamp, | ||
17 : | blume | 1137 | guid: string } |
18 : | blume | 1058 | -> PersStamps.persstamp |
19 : | end = struct | ||
20 : | blume | 1137 | fun addGUID { hash, guid } = let |
21 : | blume | 1058 | val crc = CRC.fromString (Byte.bytesToString (PersStamps.toBytes hash)) |
22 : | fun append (c, x) = CRC.append (x, c) | ||
23 : | blume | 1137 | val crc' = CharVector.foldl append crc guid |
24 : | blume | 1058 | in |
25 : | PersStamps.fromBytes (Byte.stringToBytes (CRC.toString crc')) | ||
26 : | end | ||
27 : | |||
28 : | blume | 1137 | fun rehash { env, orig_pid, guid } = |
29 : | addGUID { hash = #hash (PickMod.pickleEnv | ||
30 : | (PickMod.REHASH orig_pid) env), | ||
31 : | guid = guid } | ||
32 : | blume | 879 | end |
root@smlnj-gforge.cs.uchicago.edu | ViewVC Help |
Powered by ViewVC 1.0.0 |