Skip to content

Commit

Permalink
add a cross-reference index
Browse files Browse the repository at this point in the history
it still does not *do* anything
  • Loading branch information
Ariel Ben-Yehuda authored and arielb1 committed Oct 1, 2015
1 parent 67e60bf commit d981659
Show file tree
Hide file tree
Showing 6 changed files with 149 additions and 105 deletions.
6 changes: 4 additions & 2 deletions src/librustc/metadata/common.rs
Expand Up @@ -43,9 +43,11 @@ pub const tag_items_data_parent_item: usize = 0x28;

pub const tag_items_data_item_is_tuple_struct_ctor: usize = 0x29;

pub const tag_index: usize = 0x2a;
pub const tag_index: usize = 0x110; // top-level only
pub const tag_xref_index: usize = 0x111; // top-level only
pub const tag_xref_data: usize = 0x112; // top-level only

// GAP 0x2b, 0x2c, 0x2d, 0x2e
// GAP 0x2a, 0x2b, 0x2c, 0x2d, 0x2e

pub const tag_meta_item_name_value: usize = 0x2f;

Expand Down
1 change: 1 addition & 0 deletions src/librustc/metadata/creader.rs
Expand Up @@ -326,6 +326,7 @@ impl<'a> CrateReader<'a> {
name: name.to_string(),
local_path: RefCell::new(SmallVector::zero()),
index: decoder::load_index(metadata.as_slice()),
xref_index: decoder::load_xrefs(metadata.as_slice()),
data: metadata,
cnum_map: RefCell::new(cnum_map),
cnum: cnum,
Expand Down
2 changes: 2 additions & 0 deletions src/librustc/metadata/cstore.rs
Expand Up @@ -65,7 +65,9 @@ pub struct crate_metadata {
pub codemap_import_info: RefCell<Vec<ImportedFileMap>>,
pub span: codemap::Span,
pub staged_api: bool,

pub index: index::Index,
pub xref_index: index::DenseIndex,

/// Flag if this crate is required by an rlib version of this crate, or in
/// other words whether it was explicitly linked to. An example of a crate
Expand Down
5 changes: 5 additions & 0 deletions src/librustc/metadata/decoder.rs
Expand Up @@ -82,6 +82,11 @@ pub fn crate_rustc_version(data: &[u8]) -> Option<String> {
reader::maybe_get_doc(doc, tag_rustc_version).map(|s| s.as_str())
}

pub fn load_xrefs(data: &[u8]) -> index::DenseIndex {
let index = reader::get_doc(rbml::Doc::new(data), tag_xref_index);
index::DenseIndex::from_buf(index.data, index.start, index.end)
}

#[derive(Debug, PartialEq)]
enum Family {
ImmStatic, // c
Expand Down

0 comments on commit d981659

Please sign in to comment.