mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-13 10:29:16 +00:00
rustc_metadata: rename index::Index to table::Table.
This commit is contained in:
parent
83b3c39218
commit
f49274032b
@ -472,7 +472,7 @@ impl<'a, 'tcx> CrateMetadata {
|
||||
}
|
||||
|
||||
fn maybe_entry(&self, item_id: DefIndex) -> Option<Lazy<Entry<'tcx>>> {
|
||||
self.root.entries_index.lookup(self.blob.raw_bytes(), item_id)
|
||||
self.root.entries_table.lookup(self.blob.raw_bytes(), item_id)
|
||||
}
|
||||
|
||||
fn entry(&self, item_id: DefIndex) -> Entry<'tcx> {
|
||||
|
@ -1,5 +1,5 @@
|
||||
use crate::index::Index;
|
||||
use crate::schema::*;
|
||||
use crate::table::Table;
|
||||
|
||||
use rustc::middle::cstore::{LinkagePreference, NativeLibrary,
|
||||
EncodedMetadata, ForeignModule};
|
||||
@ -47,7 +47,7 @@ struct EncodeContext<'tcx> {
|
||||
opaque: opaque::Encoder,
|
||||
tcx: TyCtxt<'tcx>,
|
||||
|
||||
entries_index: Index<'tcx>,
|
||||
entries_table: Table<'tcx>,
|
||||
|
||||
lazy_state: LazyState,
|
||||
type_shorthands: FxHashMap<Ty<'tcx>, usize>,
|
||||
@ -325,7 +325,7 @@ impl<'tcx> EncodeContext<'tcx> {
|
||||
|
||||
let entry = op(self, data);
|
||||
let entry = self.lazy(entry);
|
||||
self.entries_index.record(id, entry);
|
||||
self.entries_table.record(id, entry);
|
||||
}
|
||||
|
||||
fn encode_info_for_items(&mut self) {
|
||||
@ -477,8 +477,8 @@ impl<'tcx> EncodeContext<'tcx> {
|
||||
|
||||
|
||||
i = self.position();
|
||||
let entries_index = self.entries_index.write_index(&mut self.opaque);
|
||||
let entries_index_bytes = self.position() - i;
|
||||
let entries_table = self.entries_table.encode(&mut self.opaque);
|
||||
let entries_table_bytes = self.position() - i;
|
||||
|
||||
// Encode the proc macro data
|
||||
i = self.position();
|
||||
@ -537,7 +537,7 @@ impl<'tcx> EncodeContext<'tcx> {
|
||||
impls,
|
||||
exported_symbols,
|
||||
interpret_alloc_index,
|
||||
entries_index,
|
||||
entries_table,
|
||||
});
|
||||
|
||||
let total_bytes = self.position();
|
||||
@ -562,7 +562,7 @@ impl<'tcx> EncodeContext<'tcx> {
|
||||
println!(" def-path table bytes: {}", def_path_table_bytes);
|
||||
println!(" proc-macro-data-bytes: {}", proc_macro_data_bytes);
|
||||
println!(" item bytes: {}", item_bytes);
|
||||
println!(" entries index bytes: {}", entries_index_bytes);
|
||||
println!(" entries table bytes: {}", entries_table_bytes);
|
||||
println!(" zero bytes: {}", zero_bytes);
|
||||
println!(" total bytes: {}", total_bytes);
|
||||
}
|
||||
@ -1916,7 +1916,7 @@ crate fn encode_metadata(tcx: TyCtxt<'_>) -> EncodedMetadata {
|
||||
let mut ecx = EncodeContext {
|
||||
opaque: encoder,
|
||||
tcx,
|
||||
entries_index: Index::new(tcx.hir().definitions().def_index_count()),
|
||||
entries_table: Table::new(tcx.hir().definitions().def_index_count()),
|
||||
lazy_state: LazyState::NoNode,
|
||||
type_shorthands: Default::default(),
|
||||
predicate_shorthands: Default::default(),
|
||||
|
@ -26,15 +26,15 @@ extern crate rustc_data_structures;
|
||||
|
||||
pub mod error_codes;
|
||||
|
||||
mod index;
|
||||
mod encoder;
|
||||
mod decoder;
|
||||
mod cstore_impl;
|
||||
mod schema;
|
||||
mod native_libs;
|
||||
mod link_args;
|
||||
mod foreign_modules;
|
||||
mod dependency_format;
|
||||
mod cstore_impl;
|
||||
mod foreign_modules;
|
||||
mod link_args;
|
||||
mod native_libs;
|
||||
mod schema;
|
||||
mod table;
|
||||
|
||||
pub mod creader;
|
||||
pub mod cstore;
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::index;
|
||||
use crate::table::Table;
|
||||
|
||||
use rustc::hir;
|
||||
use rustc::hir::def::{self, CtorKind};
|
||||
@ -186,7 +186,7 @@ crate struct CrateRoot<'tcx> {
|
||||
pub exported_symbols: Lazy<[(ExportedSymbol<'tcx>, SymbolExportLevel)]>,
|
||||
pub interpret_alloc_index: Lazy<[u32]>,
|
||||
|
||||
pub entries_index: Lazy<[index::Index<'tcx>]>,
|
||||
pub entries_table: Lazy<[Table<'tcx>]>,
|
||||
|
||||
/// The DefIndex's of any proc macros delcared by
|
||||
/// this crate
|
||||
|
@ -76,14 +76,14 @@ impl FixedSizeEncoding for u32 {
|
||||
/// `0`. Whenever an index is visited, we fill in the
|
||||
/// appropriate spot by calling `record_position`. We should never
|
||||
/// visit the same index twice.
|
||||
crate struct Index<'tcx> {
|
||||
crate struct Table<'tcx> {
|
||||
positions: Vec<u8>,
|
||||
_marker: PhantomData<&'tcx ()>,
|
||||
}
|
||||
|
||||
impl Index<'tcx> {
|
||||
impl Table<'tcx> {
|
||||
crate fn new(max_index: usize) -> Self {
|
||||
Index {
|
||||
Table {
|
||||
positions: vec![0; max_index * 4],
|
||||
_marker: PhantomData,
|
||||
}
|
||||
@ -108,7 +108,7 @@ impl Index<'tcx> {
|
||||
position.write_to_bytes_at(positions, array_index)
|
||||
}
|
||||
|
||||
crate fn write_index(&self, buf: &mut Encoder) -> Lazy<[Self]> {
|
||||
crate fn encode(&self, buf: &mut Encoder) -> Lazy<[Self]> {
|
||||
let pos = buf.position();
|
||||
buf.emit_raw_bytes(&self.positions);
|
||||
Lazy::from_position_and_meta(
|
||||
@ -118,18 +118,18 @@ impl Index<'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
impl Lazy<[Index<'tcx>]> {
|
||||
impl Lazy<[Table<'tcx>]> {
|
||||
/// Given the metadata, extract out the offset of a particular
|
||||
/// DefIndex (if any).
|
||||
#[inline(never)]
|
||||
crate fn lookup(&self, bytes: &[u8], def_index: DefIndex) -> Option<Lazy<Entry<'tcx>>> {
|
||||
debug!("Index::lookup: index={:?} len={:?}",
|
||||
debug!("Table::lookup: index={:?} len={:?}",
|
||||
def_index,
|
||||
self.meta);
|
||||
|
||||
let bytes = &bytes[self.position.get()..][..self.meta * 4];
|
||||
let position = u32::read_from_bytes_at(bytes, def_index.index());
|
||||
debug!("Index::lookup: position={:?}", position);
|
||||
debug!("Table::lookup: position={:?}", position);
|
||||
NonZeroUsize::new(position as usize).map(Lazy::from_position)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user