@@ -273,7 +273,7 @@ tag sty {
273
273
ty_var ( int) ; // type variable
274
274
ty_param ( uint) ; // fn/tag type param
275
275
ty_type;
276
- ty_native;
276
+ ty_native ( def_id ) ;
277
277
// TODO: ty_fn_arg(t), for a possibly-aliased function argument
278
278
}
279
279
@@ -342,13 +342,11 @@ const uint idx_istr = 17u;
342
342
343
343
const uint idx_task = 18 u;
344
344
345
- const uint idx_native = 19 u;
345
+ const uint idx_type = 19 u;
346
346
347
- const uint idx_type = 20 u;
347
+ const uint idx_bot = 20 u;
348
348
349
- const uint idx_bot = 21 u;
350
-
351
- const uint idx_first_others = 22 u;
349
+ const uint idx_first_others = 21 u;
352
350
353
351
type type_store = interner:: interner [ raw_t] ;
354
352
@@ -377,7 +375,6 @@ fn populate_type_store(&ctxt cx) {
377
375
intern ( cx, ty_str, none[ str] ) ;
378
376
intern ( cx, ty_istr, none[ str] ) ;
379
377
intern ( cx, ty_task, none[ str] ) ;
380
- intern ( cx, ty_native, none[ str] ) ;
381
378
intern ( cx, ty_type, none[ str] ) ;
382
379
intern ( cx, ty_bot, none[ str] ) ;
383
380
assert ( vec:: len ( cx. ts . vect ) == idx_first_others) ;
@@ -462,7 +459,7 @@ fn mk_raw_ty(&ctxt cx, &sty st, &option::t[str] cname) -> raw_t {
462
459
case ( ty_istr) { /* no-op */ }
463
460
case ( ty_task) { /* no-op */ }
464
461
case ( ty_type) { /* no-op */ }
465
- case ( ty_native) { /* no-op */ }
462
+ case ( ty_native ( _ ) ) { /* no-op */ }
466
463
case ( ty_param ( _) ) { has_params = true ; }
467
464
case ( ty_var ( _) ) { has_vars = true ; }
468
465
case ( ty_tag ( _, ?tys) ) {
@@ -620,7 +617,7 @@ fn mk_param(&ctxt cx, uint n) -> t { ret gen_ty(cx, ty_param(n)); }
620
617
621
618
fn mk_type( & ctxt cx) -> t { ret idx_type; }
622
619
623
- fn mk_native( & ctxt cx) -> t { ret idx_native ; }
620
+ fn mk_native( & ctxt cx, & def_id did ) -> t { ret gen_ty ( cx , ty_native ( did ) ) ; }
624
621
625
622
626
623
// Returns the one-level-deep type structure of the given type.
@@ -664,7 +661,7 @@ fn walk_ty(&ctxt cx, ty_walk walker, t ty) {
664
661
case ( ty_str) { /* no-op * / }
665
662
case ( ty_istr) { /* no-op * / }
666
663
case ( ty_type) { /* no-op * / }
667
- case ( ty_native) { /* no-op * / }
664
+ case ( ty_native( _ ) ) { /* no-op * / }
668
665
case ( ty_box( ?tm) ) { walk_ty( cx, walker, tm. ty) ; }
669
666
case ( ty_vec( ?tm) ) { walk_ty( cx, walker, tm. ty) ; }
670
667
case ( ty_ivec( ?tm) ) { walk_ty( cx, walker, tm. ty) ; }
@@ -731,7 +728,7 @@ fn fold_ty(&ctxt cx, fold_mode fld, t ty_0) -> t {
731
728
case ( ty_str) { /* no-op * / }
732
729
case ( ty_istr) { /* no-op * / }
733
730
case ( ty_type) { /* no-op * / }
734
- case ( ty_native) { /* no-op * / }
731
+ case ( ty_native( _ ) ) { /* no-op * / }
735
732
case ( ty_task) { /* no-op * / }
736
733
case ( ty_box( ?tm) ) {
737
734
ty =
@@ -1017,7 +1014,7 @@ fn type_is_scalar(&ctxt cx, &t ty) -> bool {
1017
1014
case ( ty_machine( _) ) { ret true; }
1018
1015
case ( ty_char) { ret true; }
1019
1016
case ( ty_type) { ret true; }
1020
- case ( ty_native) { ret true; }
1017
+ case ( ty_native( _ ) ) { ret true; }
1021
1018
case ( ty_ptr( _) ) { ret true; }
1022
1019
case ( _) { ret false; }
1023
1020
}
@@ -1041,7 +1038,7 @@ fn type_has_pointers(&ctxt cx, &t ty) -> bool {
1041
1038
case ( ty_machine( _) ) { /* no-op */ }
1042
1039
case ( ty_char) { /* no-op */ }
1043
1040
case ( ty_type) { /* no-op */ }
1044
- case ( ty_native) { /* no-op */ }
1041
+ case ( ty_native( _ ) ) { /* no-op */ }
1045
1042
case ( ty_tup( ?elts) ) {
1046
1043
for ( mt m in elts) {
1047
1044
if ( type_has_pointers( cx, m. ty) ) { result = true; }
@@ -1082,7 +1079,7 @@ fn type_has_pointers(&ctxt cx, &t ty) -> bool {
1082
1079
// type_is_scalar?
1083
1080
fn type_is_native( & ctxt cx, & t ty) -> bool {
1084
1081
alt ( struct ( cx, ty) ) {
1085
- case ( ty_native) { ret true; }
1082
+ case ( ty_native( _ ) ) { ret true; }
1086
1083
case ( _) { ret false; }
1087
1084
}
1088
1085
}
@@ -1142,7 +1139,7 @@ fn type_has_dynamic_size(&ctxt cx, &t ty) -> bool {
1142
1139
case ( ty_var( _) ) { fail "ty_var in type_has_dynamic_size( ) "; }
1143
1140
case ( ty_param( _) ) { ret true; }
1144
1141
case ( ty_type) { ret false; }
1145
- case ( ty_native) { ret false; }
1142
+ case ( ty_native( _ ) ) { ret false; }
1146
1143
}
1147
1144
}
1148
1145
@@ -1219,7 +1216,7 @@ fn type_owns_heap_mem(&ctxt cx, &t ty) -> bool {
1219
1216
case ( ty_machine( _) ) { result = false; }
1220
1217
case ( ty_char) { result = false; }
1221
1218
case ( ty_type) { result = false; }
1222
- case ( ty_native) { result = false; }
1219
+ case ( ty_native( _ ) ) { result = false; }
1223
1220
1224
1221
// boxed types
1225
1222
case ( ty_str) { result = false; }
@@ -1388,7 +1385,7 @@ fn hash_type_structure(&sty st) -> uint {
1388
1385
case ( ty_var( ?v) ) { ret hash_uint( 30 u, v as uint) ; }
1389
1386
case ( ty_param( ?pid) ) { ret hash_uint( 31 u, pid) ; }
1390
1387
case ( ty_type) { ret 32 u; }
1391
- case ( ty_native) { ret 33 u; }
1388
+ case ( ty_native( ?did ) ) { ret hash_def ( 33 u, did ) ; }
1392
1389
case ( ty_bot) { ret 34 u; }
1393
1390
case ( ty_ptr( ?mt) ) { ret hash_subty( 35 u, mt. ty) ; }
1394
1391
case ( ty_res( ?did, ?sub, ?tps) ) {
@@ -1687,8 +1684,12 @@ fn equal_type_structures(&sty a, &sty b) -> bool {
1687
1684
case ( ty_type) {
1688
1685
alt ( b) { case ( ty_type) { ret true; } case ( _) { ret false; } }
1689
1686
}
1690
- case ( ty_native) {
1691
- alt ( b) { case ( ty_native) { ret true; } case ( _) { ret false; } }
1687
+ case ( ty_native( ?a_id) ) {
1688
+ alt ( b) {
1689
+ case ( ty_native( ?b_id) ) {
1690
+ ret a_id. _0 == b_id. _0 && a_id. _1 == b_id. _1;
1691
+ }
1692
+ case ( _) { ret false; } }
1692
1693
}
1693
1694
}
1694
1695
}
@@ -2313,9 +2314,8 @@ mod unify {
2313
2314
}
2314
2315
alt ( struct ( cx. tcx, expected) ) {
2315
2316
case ( ty:: ty_nil) { ret struct_cmp( cx, expected, actual) ; }
2316
- case (
2317
- // _|_ unifies with anything
2318
- ty:: ty_bot) {
2317
+ // _|_ unifies with anything
2318
+ case ( ty:: ty_bot) {
2319
2319
ret ures_ok( actual) ;
2320
2320
}
2321
2321
case ( ty:: ty_bool) { ret struct_cmp( cx, expected, actual) ; }
@@ -2327,7 +2327,18 @@ mod unify {
2327
2327
case ( ty:: ty_str) { ret struct_cmp( cx, expected, actual) ; }
2328
2328
case ( ty:: ty_istr) { ret struct_cmp( cx, expected, actual) ; }
2329
2329
case ( ty:: ty_type) { ret struct_cmp( cx, expected, actual) ; }
2330
- case ( ty:: ty_native) { ret struct_cmp( cx, expected, actual) ; }
2330
+ case ( ty:: ty_native( ?ex_id) ) {
2331
+ alt ( struct ( cx. tcx, actual) ) {
2332
+ case ( ty_native( ?act_id) ) {
2333
+ if ( ex_id. _0 == act_id. _0 && ex_id. _1 == act_id. _1) {
2334
+ ret ures_ok( actual) ;
2335
+ } else {
2336
+ ret ures_err( terr_mismatch) ;
2337
+ }
2338
+ }
2339
+ case ( _) { ret ures_err( terr_mismatch) ; }
2340
+ }
2341
+ }
2331
2342
case ( ty:: ty_param( _) ) { ret struct_cmp( cx, expected, actual) ; }
2332
2343
case ( ty:: ty_tag( ?expected_id, ?expected_tps) ) {
2333
2344
alt ( struct ( cx. tcx, actual) ) {
0 commit comments