@@ -309,7 +309,6 @@ impure fn resolve_path(vec[ast.ident] path, vec[u8] data) -> resolve_result {
309
309
auto ebml_r = ebml. create_reader ( io_r) ;
310
310
while ( ebml. bytes_left ( ebml_r) > 0 u) {
311
311
auto ebml_tag = ebml. peek ( ebml_r) ;
312
- log #fmt( "outer ebml tag id: %u" , ebml_tag. id ) ;
313
312
if ( ebml_tag. id == metadata. tag_paths ) {
314
313
ebml. move_to_first_child ( ebml_r) ;
315
314
ret resolve_path_inner ( path, ebml_r) ;
@@ -321,6 +320,57 @@ impure fn resolve_path(vec[ast.ident] path, vec[u8] data) -> resolve_result {
321
320
fail;
322
321
}
323
322
323
+ impure fn move_to_item ( & ebml. reader ebml_r, ast. def_id did) {
324
+ while ( ebml. bytes_left ( ebml_r) > 0 u) {
325
+ auto outer_ebml_tag = ebml. peek ( ebml_r) ;
326
+ if ( outer_ebml_tag. id == metadata. tag_items ) {
327
+ ebml. move_to_first_child ( ebml_r) ;
328
+
329
+ while ( ebml. bytes_left ( ebml_r) > 0 u) {
330
+ auto inner_ebml_tag = ebml. peek ( ebml_r) ;
331
+ if ( inner_ebml_tag. id == metadata. tag_items_item ) {
332
+ ebml. move_to_first_child ( ebml_r) ;
333
+
334
+ while ( ebml. bytes_left ( ebml_r) > 0 u) {
335
+ auto innermost_ebml_tag = ebml. peek ( ebml_r) ;
336
+ if ( innermost_ebml_tag. id ==
337
+ metadata. tag_items_def_id ) {
338
+ ebml. move_to_first_child ( ebml_r) ;
339
+ auto did_data = ebml. read_data ( ebml_r) ;
340
+ ebml. move_to_parent ( ebml_r) ;
341
+
342
+ auto this_did = parse_def_id ( did_data) ;
343
+ if ( did. _0 == this_did. _0 &&
344
+ did. _1 == this_did. _1 ) {
345
+ // Move to the start of this item's data.
346
+ ebml. move_to_parent ( ebml_r) ;
347
+ ebml. move_to_first_child ( ebml_r) ;
348
+ ret;
349
+ }
350
+ }
351
+ ebml. move_to_next_sibling ( ebml_r) ;
352
+ }
353
+ ebml. move_to_parent ( ebml_r) ;
354
+ }
355
+ ebml. move_to_next_sibling ( ebml_r) ;
356
+ }
357
+ ebml. move_to_parent ( ebml_r) ;
358
+ }
359
+ ebml. move_to_next_sibling ( ebml_r) ;
360
+ }
361
+
362
+ log #fmt( "move_to_item: item not found: %d:%d" , did. _0 , did. _1 ) ;
363
+ }
364
+
365
+ impure fn get_item_kind ( ast. def_id did, vec[ u8] data) -> u8 {
366
+ auto io_r = io. new_reader_ ( io. new_byte_buf_reader ( data) ) ;
367
+ auto ebml_r = ebml. create_reader ( io_r) ;
368
+ move_to_item ( ebml_r, did) ;
369
+
370
+ log "found item" ;
371
+ fail;
372
+ }
373
+
324
374
325
375
fn load_crate ( session. session sess,
326
376
int cnum,
@@ -407,10 +457,8 @@ fn lookup_def(session.session sess, &span sp, int cnum, vec[ast.ident] path)
407
457
}
408
458
}
409
459
410
- log #fmt( "resolved '%s' to %d:%d" , _str. connect( path, "." ) , did. _0,
411
- did. _1) ;
412
-
413
460
// TODO: Look up item type, use that to determine the type of def.
461
+ auto kind_ch = get_item_kind( did, data) ;
414
462
415
463
fail;
416
464
}
0 commit comments