@@ -2,6 +2,7 @@ import front.ast;
2
2
import front. ast . ident ;
3
3
import front. ast . def ;
4
4
import front. ast . ann ;
5
+ import front. creader ;
5
6
import driver. session ;
6
7
import util. common . new_def_hash ;
7
8
import util. common . span ;
@@ -107,9 +108,9 @@ fn find_final_def(&env e, import_map index,
107
108
& span sp, vec[ ident] idents ,
108
109
option. t[ ast. def_id] import_id ) -> def_wrap {
109
110
110
- // We are given a series of identifiers (a.b.c.d ) and we know that
111
- // in the environment 'e' the identifier 'a ' was resolved to 'd'. We
112
- // should return what a.b.c.d points to in the end.
111
+ // We are given a series of identifiers (p.q.r ) and we know that
112
+ // in the environment 'e' the identifier 'p ' was resolved to 'd'. We
113
+ // should return what p.q.r points to in the end.
113
114
fn found_something ( & env e, import_map index,
114
115
& span sp, vec[ ident] idents , def_wrap d) -> def_wrap {
115
116
@@ -135,6 +136,15 @@ fn find_final_def(&env e, import_map index,
135
136
}
136
137
}
137
138
139
+ fn found_crate ( & env e, & import_map index, & span sp,
140
+ vec[ ident] idents ,
141
+ @ast. external_crate_info cinfo ) -> def_wrap {
142
+ auto len = _vec. len [ ident] ( idents) ;
143
+ auto rest_idents = _vec. slice [ ident] ( idents, 1 u, len) ;
144
+ auto def = creader. lookup_def ( sp, cinfo, rest_idents) ;
145
+ ret def_wrap_other ( def) ;
146
+ }
147
+
138
148
alt ( d) {
139
149
case ( def_wrap_import ( ?imp) ) {
140
150
alt ( imp. node ) {
@@ -159,8 +169,16 @@ fn find_final_def(&env e, import_map index,
159
169
case ( def_wrap_native_mod ( ?i) ) {
160
170
ret found_mod ( e, index, sp, idents, i) ;
161
171
}
162
- case ( def_wrap_use ( ?c) ) {
163
- e. sess . span_err ( sp, "Crate access is not implemented" ) ;
172
+ case ( def_wrap_use ( ?vi) ) {
173
+ alt ( vi. node ) {
174
+ case ( ast. view_item_use ( _, _, _, ?ann) ) {
175
+ alt ( ann) {
176
+ case ( ast. ann_crate ( ?cinfo) ) {
177
+ ret found_crate ( e, index, sp, idents, cinfo) ;
178
+ }
179
+ }
180
+ }
181
+ }
164
182
}
165
183
case ( def_wrap_other ( ?d) ) {
166
184
let uint l = _vec. len [ ident] ( idents) ;
0 commit comments