@@ -9,6 +9,7 @@ import metadata::{csearch, cstore};
9
9
import driver:: session:: session;
10
10
import util:: common:: * ;
11
11
import std:: map:: { int_hash, str_hash, hashmap} ;
12
+ import vec:: each;
12
13
import syntax:: codemap:: span;
13
14
import syntax:: visit;
14
15
import visit:: vt;
@@ -402,6 +403,11 @@ fn maybe_insert(e: @env, id: node_id, def: option<def>) {
402
403
}
403
404
}
404
405
406
+ fn resolve_iface_ref ( p : @iface_ref , sc : scopes , e : @env ) {
407
+ maybe_insert ( e, p. id ,
408
+ lookup_path_strict ( * e, sc, p. path . span , p. path , ns_type) ) ;
409
+ }
410
+
405
411
fn resolve_names ( e : @env , c : @ast:: crate ) {
406
412
e. used_imports . track = true ;
407
413
let v =
@@ -431,9 +437,10 @@ fn resolve_names(e: @env, c: @ast::crate) {
431
437
alt i. node {
432
438
ast:: item_class ( _, ifaces, _, _, _) {
433
439
/* visit the iface paths... */
434
- for ifaces. each { |p|
435
- maybe_insert( e, p. id,
436
- lookup_path_strict( * e, sc, p. path. span, p. path, ns_type) ) } ;
440
+ for ifaces. each { |p| resolve_iface_ref( p, sc, e) } ;
441
+ }
442
+ ast:: item_impl ( _, ifce, _, _) {
443
+ option:: iter ( ifce, { |p| resolve_iface_ref ( p, sc, e) } ) ;
437
444
}
438
445
_ { }
439
446
}
@@ -535,7 +542,7 @@ fn visit_item_with_scope(e: @env, i: @ast::item, sc: scopes, v: vt<scopes>) {
535
542
alt i. node {
536
543
ast:: item_impl ( tps, ifce, sty, methods) {
537
544
visit:: visit_ty_params ( tps, sc, v) ;
538
- alt ifce { some ( ty ) { v . visit_ty ( ty , sc, v) ; } _ { } }
545
+ option :: iter ( ifce ) { |p| visit :: visit_path ( p . path , sc, v) } ;
539
546
v. visit_ty ( sty, sc, v) ;
540
547
for methods. each { |m|
541
548
v. visit_ty_params( m. tps, sc, v) ;
@@ -1109,20 +1116,20 @@ fn lookup_in_scope(e: env, sc: scopes, sp: span, name: ident, ns: namespace,
1109
1116
}
1110
1117
ret some( df) ;
1111
1118
}
1112
- _ { }
1113
- }
1114
- if left_fn {
1115
- left_fn_level2 = true;
1116
- } else if ns != ns_module {
1119
+ _ { }
1120
+ }
1121
+ if left_fn {
1122
+ left_fn_level2 = true;
1123
+ } else if ns != ns_module {
1117
1124
left_fn = scope_is_fn( hd) ;
1118
1125
alt scope_closes( hd) {
1119
1126
some( node_id) { closing += [ node_id] ; }
1120
1127
_ { }
1121
1128
}
1122
1129
}
1123
1130
sc = * tl;
1124
- }
1125
1131
}
1132
+ }
1126
1133
} ;
1127
1134
}
1128
1135
@@ -2103,6 +2110,8 @@ fn check_exports(e: @env) {
2103
2110
// Impl resolution
2104
2111
2105
2112
type method_info = { did: def_id, n_tps: uint, ident: ast:: ident} ;
2113
+ /* what are the did and ident here? */
2114
+ /* ident = the name of the impl */
2106
2115
type _impl = { did: def_id, ident: ast:: ident, methods: [ @method_info] } ;
2107
2116
type iscopes = list<@[ @_impl] >;
2108
2117
@@ -2177,6 +2186,12 @@ fn find_impls_in_view_item(e: env, vi: @ast::view_item,
2177
2186
}
2178
2187
}
2179
2188
2189
+ /*
2190
+ Given an item <i>, adds one record to the mutable vec
2191
+ <impls> if the item is an impl; zero or more records if the
2192
+ item is a class; and none otherwise. Each record describes
2193
+ one interface implemented by i.
2194
+ */
2180
2195
fn find_impls_in_item( e: env, i: @ast:: item, & impls: [ @_impl] ,
2181
2196
name: option < ident > ,
2182
2197
ck_exports: option < @indexed_mod > ) {
@@ -2196,6 +2211,20 @@ fn find_impls_in_item(e: env, i: @ast::item, &impls: [@_impl],
2196
2211
} ) } ] ;
2197
2212
}
2198
2213
}
2214
+ ast:: item_class( tps, ifces, items, _, _) {
2215
+ let ( _, mthds) = ast_util:: split_class_items( items) ;
2216
+ let n_tps = tps. len( ) ;
2217
+ vec:: iter( ifces) { |p|
2218
+ // The def_id, in this case, identifies the combination of
2219
+ // class and iface
2220
+ impls += [ @{ did : local_def( p. id) ,
2221
+ ident : i. ident,
2222
+ methods : vec:: map( mthds, { |m|
2223
+ @{ did: local_def( m. id) ,
2224
+ n_tps: n_tps + m. tps. len( ) ,
2225
+ ident: m. ident} } ) } ] ;
2226
+ }
2227
+ }
2199
2228
_ { }
2200
2229
}
2201
2230
}
0 commit comments