Skip to content

Commit d981659

Browse files
Ariel Ben-Yehudaarielb1
authored andcommitted
add a cross-reference index
it still does not *do* anything
1 parent 67e60bf commit d981659

File tree

6 files changed

+149
-105
lines changed

6 files changed

+149
-105
lines changed

src/librustc/metadata/common.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,11 @@ pub const tag_items_data_parent_item: usize = 0x28;
4343

4444
pub const tag_items_data_item_is_tuple_struct_ctor: usize = 0x29;
4545

46-
pub const tag_index: usize = 0x2a;
46+
pub const tag_index: usize = 0x110; // top-level only
47+
pub const tag_xref_index: usize = 0x111; // top-level only
48+
pub const tag_xref_data: usize = 0x112; // top-level only
4749

48-
// GAP 0x2b, 0x2c, 0x2d, 0x2e
50+
// GAP 0x2a, 0x2b, 0x2c, 0x2d, 0x2e
4951

5052
pub const tag_meta_item_name_value: usize = 0x2f;
5153

src/librustc/metadata/creader.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,7 @@ impl<'a> CrateReader<'a> {
326326
name: name.to_string(),
327327
local_path: RefCell::new(SmallVector::zero()),
328328
index: decoder::load_index(metadata.as_slice()),
329+
xref_index: decoder::load_xrefs(metadata.as_slice()),
329330
data: metadata,
330331
cnum_map: RefCell::new(cnum_map),
331332
cnum: cnum,

src/librustc/metadata/cstore.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,9 @@ pub struct crate_metadata {
6565
pub codemap_import_info: RefCell<Vec<ImportedFileMap>>,
6666
pub span: codemap::Span,
6767
pub staged_api: bool,
68+
6869
pub index: index::Index,
70+
pub xref_index: index::DenseIndex,
6971

7072
/// Flag if this crate is required by an rlib version of this crate, or in
7173
/// other words whether it was explicitly linked to. An example of a crate

src/librustc/metadata/decoder.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,11 @@ pub fn crate_rustc_version(data: &[u8]) -> Option<String> {
8282
reader::maybe_get_doc(doc, tag_rustc_version).map(|s| s.as_str())
8383
}
8484

85+
pub fn load_xrefs(data: &[u8]) -> index::DenseIndex {
86+
let index = reader::get_doc(rbml::Doc::new(data), tag_xref_index);
87+
index::DenseIndex::from_buf(index.data, index.start, index.end)
88+
}
89+
8590
#[derive(Debug, PartialEq)]
8691
enum Family {
8792
ImmStatic, // c

0 commit comments

Comments
 (0)