@@ -307,7 +307,7 @@ mod write {
307
307
*/
308
308
309
309
fn build_link_meta ( sess : session , c : ast:: crate , output : ~str ,
310
- sha : sha1 ) -> link_meta {
310
+ symbol_hasher : hash :: streaming ) -> link_meta {
311
311
312
312
type provided_metas =
313
313
{ name : option < @~str > ,
@@ -338,7 +338,7 @@ fn build_link_meta(sess: session, c: ast::crate, output: ~str,
338
338
}
339
339
340
340
// This calculates CMH as defined above
341
- fn crate_meta_extras_hash ( sha : sha1 , _crate : ast:: crate ,
341
+ fn crate_meta_extras_hash ( symbol_hasher : hash :: streaming , _crate : ast:: crate ,
342
342
metas : provided_metas ,
343
343
dep_hashes : ~[ @~str ] ) -> ~str {
344
344
fn len_and_str ( s : ~str ) -> ~str {
@@ -351,15 +351,15 @@ fn build_link_meta(sess: session, c: ast::crate, output: ~str,
351
351
352
352
let cmh_items = attr:: sort_meta_items ( metas. cmh_items ) ;
353
353
354
- sha . reset ( ) ;
354
+ symbol_hasher . reset ( ) ;
355
355
for cmh_items. each |m_| {
356
356
let m = m_;
357
357
alt m. node {
358
358
ast:: meta_name_value ( key, value) {
359
- sha . input_str ( len_and_str ( * key) ) ;
360
- sha . input_str ( len_and_str_lit ( value) ) ;
359
+ symbol_hasher . input_str ( len_and_str ( * key) ) ;
360
+ symbol_hasher . input_str ( len_and_str_lit ( value) ) ;
361
361
}
362
- ast:: meta_word ( name) { sha . input_str ( len_and_str ( * name) ) ; }
362
+ ast:: meta_word ( name) { symbol_hasher . input_str ( len_and_str ( * name) ) ; }
363
363
ast:: meta_list ( _, _) {
364
364
// FIXME (#607): Implement this
365
365
fail ~"unimplemented meta_item variant";
@@ -368,10 +368,10 @@ fn build_link_meta(sess: session, c: ast::crate, output: ~str,
368
368
}
369
369
370
370
for dep_hashes. each |dh| {
371
- sha . input_str ( len_and_str ( * dh) ) ;
371
+ symbol_hasher . input_str ( len_and_str ( * dh) ) ;
372
372
}
373
373
374
- ret truncated_sha1_result ( sha ) ;
374
+ ret truncated_hash_result ( symbol_hasher ) ;
375
375
}
376
376
377
377
fn warn_missing ( sess : session , name : ~str , default : ~str ) {
@@ -419,40 +419,40 @@ fn build_link_meta(sess: session, c: ast::crate, output: ~str,
419
419
let vers = crate_meta_vers ( sess, c, provided_metas) ;
420
420
let dep_hashes = cstore:: get_dep_hashes ( sess. cstore ) ;
421
421
let extras_hash =
422
- crate_meta_extras_hash ( sha , c, provided_metas, dep_hashes) ;
422
+ crate_meta_extras_hash ( symbol_hasher , c, provided_metas, dep_hashes) ;
423
423
424
424
ret { name : name, vers : vers, extras_hash : extras_hash} ;
425
425
}
426
426
427
- fn truncated_sha1_result ( sha : sha1 ) -> ~str unsafe {
428
- ret str :: slice ( sha . result_str ( ) , 0 u , 16 u ) ;
427
+ fn truncated_hash_result ( symbol_hasher : hash :: streaming ) -> ~str unsafe {
428
+ symbol_hasher . result_str ( )
429
429
}
430
430
431
431
432
432
// This calculates STH for a symbol, as defined above
433
- fn symbol_hash ( tcx : ty:: ctxt , sha : sha1 , t : ty:: t ,
433
+ fn symbol_hash ( tcx : ty:: ctxt , symbol_hasher : hash :: streaming , t : ty:: t ,
434
434
link_meta : link_meta ) -> ~str {
435
435
// NB: do *not* use abbrevs here as we want the symbol names
436
436
// to be independent of one another in the crate.
437
437
438
- sha . reset ( ) ;
439
- sha . input_str ( * link_meta. name ) ;
440
- sha . input_str ( ~"-");
441
- sha .input_str(link_meta.extras_hash);
442
- sha .input_str(~" -");
443
- sha .input_str(encoder::encoded_ty(tcx, t));
444
- let hash = truncated_sha1_result(sha );
438
+ symbol_hasher . reset ( ) ;
439
+ symbol_hasher . input_str ( * link_meta. name ) ;
440
+ symbol_hasher . input_str ( ~"-");
441
+ symbol_hasher .input_str(link_meta.extras_hash);
442
+ symbol_hasher .input_str(~" -");
443
+ symbol_hasher .input_str(encoder::encoded_ty(tcx, t));
444
+ let hash = truncated_hash_result(symbol_hasher );
445
445
// Prefix with _ so that it never blends into adjacent digits
446
446
447
447
ret ~" _" + hash;
448
448
}
449
449
450
450
fn get_symbol_hash ( ccx : @crate_ctxt , t : ty:: t ) -> ~str {
451
- alt ccx. type_sha1s . find ( t) {
451
+ alt ccx. type_hashcodes . find ( t) {
452
452
some ( h) { ret h; }
453
453
none {
454
- let hash = symbol_hash ( ccx. tcx , ccx. sha , t, ccx. link_meta ) ;
455
- ccx. type_sha1s . insert ( t, hash) ;
454
+ let hash = symbol_hash ( ccx. tcx , ccx. symbol_hasher , t, ccx. link_meta ) ;
455
+ ccx. type_hashcodes . insert ( t, hash) ;
456
456
ret hash;
457
457
}
458
458
}
0 commit comments