@@ -661,12 +661,57 @@ fn def_to_str(ast.def_id did) -> str {
661
661
ret #fmt( "%d: %d", did. _0, did. _1) ;
662
662
}
663
663
664
+ fn simple_ty_code( & @t ty) -> uint {
665
+ alt ( ty. struct ) {
666
+ case ( ty_nil) { ret 0 u; }
667
+ case ( ty_bool) { ret 1 u; }
668
+ case ( ty_int) { ret 2 u; }
669
+ case ( ty_float) { ret 3 u; }
670
+ case ( ty_uint) { ret 4 u; }
671
+ case ( ty_machine( ?tm) ) {
672
+ alt ( tm) {
673
+ case ( common. ty_i8) { ret 5 u; }
674
+ case ( common. ty_i16) { ret 6 u; }
675
+ case ( common. ty_i32) { ret 7 u; }
676
+ case ( common. ty_i64) { ret 8 u; }
677
+
678
+ case ( common. ty_u8) { ret 9 u; }
679
+ case ( common. ty_u16) { ret 10 u; }
680
+ case ( common. ty_u32) { ret 11 u; }
681
+ case ( common. ty_u64) { ret 12 u; }
682
+
683
+ case ( common. ty_f32) { ret 13 u; }
684
+ case ( common. ty_f64) { ret 14 u; }
685
+ }
686
+ }
687
+ case ( ty_char) { ret 15 u; }
688
+ case ( ty_str) { ret 16 u; }
689
+ case ( ty_task) { ret 17 u; }
690
+ case ( ty_type) { ret 18 u; }
691
+ case ( ty_native) { ret 19 u; }
692
+ case ( _) {
693
+ }
694
+ }
695
+ ret 0xffff u;
696
+ }
697
+
664
698
fn hash_ty( & @t ty) -> uint {
699
+ auto s = simple_ty_code( ty) ;
700
+ if ( s != 0xffff u) {
701
+ ret s;
702
+ }
665
703
auto f = def_to_str;
666
704
ret _str. hash( metadata. ty_str( ty, f) ) ;
667
705
}
668
706
669
707
fn eq_ty( & @t a, & @t b) -> bool {
708
+
709
+ auto sa = simple_ty_code( a) ;
710
+ if ( sa != 0xffff u) {
711
+ auto sb = simple_ty_code( b) ;
712
+ ret sa == sb;
713
+ }
714
+
670
715
// FIXME: this is gross, but I think it's safe, and I don't think writing
671
716
// a giant function to handle all the cases is necessary when structural
672
717
// equality will someday save the day.
0 commit comments