/// Imports the codemap from an external crate into the codemap of the crate
/// currently being compiled (the "local crate").
///
/// The import algorithm works analogous to how AST items are inlined from an
/// external crate's metadata:
/// For every FileMap in the external codemap an 'inline' copy is created in the
/// local codemap. The correspondence relation between external and local
/// FileMaps is recorded in the `ImportedFileMap` objects returned from this
/// function. When an item from an external crate is later inlined into this
/// crate, this correspondence information is used to translate the span
/// information of the inlined item so that it refers the correct positions in
/// the local codemap (see `<decoder::DecodeContext as SpecializedDecoder<Span>>`).
///
/// The import algorithm in the function below will reuse FileMaps already
/// existing in the local codemap. For example, even if the FileMap of some
/// source file of libstd gets imported many times, there will only ever be
/// one FileMap object for the corresponding file in the local codemap.
///
/// Note that imported FileMaps do not actually contain the source code of the
/// file they represent, just information about length, line breaks, and
/// multibyte characters. This information is enough to generate valid debuginfo
/// for items inlined from other crates.
Imports the codemap from an external crate into the codemap of the crate
currently being compiled (the "local crate").

The import algorithm works analogous to how AST items are inlined from an
external crate's metadata:
For every FileMap in the external codemap an 'inline' copy is created in the
local codemap. The correspondence relation between external and local
FileMaps is recorded in the `ImportedFileMap` objects returned from this
function. When an item from an external crate is later inlined into this
crate, this correspondence information is used to translate the span
information of the inlined item so that it refers the correct positions in
the local codemap .

The import algorithm in the function below will reuse FileMaps already
existing in the local codemap. For example, even if the FileMap of some
source file of libstd gets imported many times, there will only ever be
one FileMap object for the corresponding file in the local codemap.

Note that imported FileMaps do not actually contain the source code of the
file they represent, just information about length, line breaks, and
multibyte characters. This information is enough to generate valid debuginfo
for items inlined from other crates.
Imports the codemap from an external crate into the codemap of the crate currently being compiled ( the " local crate " ) . The import algorithm works analogous to how AST items are inlined from an external crate ' s metadata : For every FileMap in the external codemap an ' inline ' copy is created in the local codemap . The correspondence relation between external and local FileMaps is recorded in the ` ImportedFileMap ` objects returned from this function . When an item from an external crate is later inlined into this crate this correspondence information is used to translate the span information of the inlined item so that it refers the correct positions in the local codemap . The import algorithm in the function below will reuse FileMaps already existing in the local codemap . For example even if the FileMap of some source file of libstd gets imported many times there will only ever be one FileMap object for the corresponding file in the local codemap . Note that imported FileMaps do not actually contain the source code of the file they represent just information about length line breaks and multibyte characters . This information is enough to generate valid debuginfo for items inlined from other crates .
pub fn imported_filemaps(&'a self,
                             local_codemap: &codemap::CodeMap)
                             -> Ref<'a, Vec<cstore::ImportedFileMap>> {
        {
            let filemaps = self.codemap_import_info.borrow();
            if !filemaps.is_empty() {
                return filemaps;
            }
        }
        let external_codemap = self.root.codemap.decode(self);
        let imported_filemaps = external_codemap.map(|filemap_to_import| {
                // Try to find an existing FileMap that can be reused for the filemap to
                // be imported. A FileMap is reusable if it is exactly the same, just
                // positioned at a different offset within the codemap.
                let reusable_filemap = {
                    local_codemap.files
                        .borrow()
                        .iter()
                        .find(|fm| are_equal_modulo_startpos(&fm, &filemap_to_import))
                        .map(|rc| rc.clone())
                };
                match reusable_filemap {
                    Some(fm) => {
                        debug!("CrateMetaData::imported_filemaps reuse \
                                filemap {:?} original (start_pos {:?} end_pos {:?}) \
                                translated (start_pos {:?} end_pos {:?})",
                               filemap_to_import.name,
                               filemap_to_import.start_pos, filemap_to_import.end_pos,
                               fm.start_pos, fm.end_pos);
                        cstore::ImportedFileMap {
                            original_start_pos: filemap_to_import.start_pos,
                            original_end_pos: filemap_to_import.end_pos,
                            translated_filemap: fm,
                        }
                    }
                    None => {
                        // We can't reuse an existing FileMap, so allocate a new one
                        // containing the information we need.
                        let syntax_pos::FileMap { name,
                                                  name_was_remapped,
                                                  start_pos,
                                                  end_pos,
                                                  lines,
                                                  multibyte_chars,
                                                  .. } = filemap_to_import;
                        let source_length = (end_pos - start_pos).to_usize();
                        // Translate line-start positions and multibyte character
                        // position into frame of reference local to file.
                        // `CodeMap::new_imported_filemap()` will then translate those
                        // coordinates to their new global frame of reference when the
                        // offset of the FileMap is known.
                        let mut lines = lines.into_inner();
                        for pos in &mut lines {
                            *pos = *pos - start_pos;
                        }
                        let mut multibyte_chars = multibyte_chars.into_inner();
                        for mbc in &mut multibyte_chars {
                            mbc.pos = mbc.pos - start_pos;
                        }
                        let local_version = local_codemap.new_imported_filemap(name,
                                                                               name_was_remapped,
                                                                               source_length,
                                                                               lines,
                                                                               multibyte_chars);
                        debug!("CrateMetaData::imported_filemaps alloc \
                                filemap {:?} original (start_pos {:?} end_pos {:?}) \
                                translated (start_pos {:?} end_pos {:?})",
                               local_version.name, start_pos, end_pos,
                               local_version.start_pos, local_version.end_pos);
                        cstore::ImportedFileMap {
                            original_start_pos: start_pos,
                            original_end_pos: end_pos,
                            translated_filemap: local_version,
                        }
                    }
                }
            })
            .collect();
        // This shouldn't borrow twice, but there is no way to downgrade RefMut to Ref.
        *self.codemap_import_info.borrow_mut() = imported_filemaps;
        self.codemap_import_info.borrow()
    }
pub fn imported_filemaps ( & ' a self , local_codemap : & codemap :: CodeMap ) -> Ref < ' a , Vec < cstore :: ImportedFileMap > > { { let filemaps = self . codemap_import_info . borrow ( ) ; if ! filemaps . is_empty ( ) { return filemaps ; } } let external_codemap = self . root . codemap . decode ( self ) ; let imported_filemaps = external_codemap . map ( | filemap_to_import | { // Try to find an existing FileMap that can be reused for the filemap to // be imported. A FileMap is reusable if it is exactly the same, just // positioned at a different offset within the codemap. let reusable_filemap = { local_codemap . files . borrow ( ) . iter ( ) . find ( | fm | are_equal_modulo_startpos ( & fm , & filemap_to_import ) ) . map ( | rc | rc . clone ( ) ) } ; match reusable_filemap { Some ( fm ) => { debug ! ( " \
 \
 " filemap_to_import name filemap_to_import start_pos filemap_to_import end_pos fm start_pos fm end_pos ) ; cstore :: ImportedFileMap { original_start_pos : filemap_to_import . start_pos , original_end_pos : filemap_to_import . end_pos , translated_filemap : fm , } } None => { // We can't reuse an existing FileMap, so allocate a new one // containing the information we need. let syntax_pos :: FileMap { name , name_was_remapped , start_pos , end_pos , lines , multibyte_chars , .. } = filemap_to_import ; let source_length = ( end_pos - start_pos ) . to_usize ( ) ; // Translate line-start positions and multibyte character // position into frame of reference local to file. // `CodeMap::new_imported_filemap()` will then translate those // coordinates to their new global frame of reference when the // offset of the FileMap is known. let mut lines = lines . into_inner ( ) ; for pos in & mut lines { * pos = * pos - start_pos ; } let mut multibyte_chars = multibyte_chars . into_inner ( ) ; for mbc in & mut multibyte_chars { mbc . pos = mbc . pos - start_pos ; } let local_version = local_codemap . new_imported_filemap ( name , name_was_remapped , source_length , lines , multibyte_chars ) ; debug ! ( " \
 \
 " local_version name start_pos end_pos local_version start_pos local_version end_pos ) ; cstore :: ImportedFileMap { original_start_pos : start_pos , original_end_pos : end_pos , translated_filemap : local_version , } } } } ) . collect ( ) ; // This shouldn't borrow twice, but there is no way to downgrade RefMut to Ref. * self . codemap_import_info . borrow_mut ( ) = imported_filemaps ; self . codemap_import_info . borrow ( ) }
Imports the codemap from an external crate into the codemap of the crate
currently being compiled (the "local crate").
Imports the codemap from an external crate into the codemap of the crate currently being compiled ( the " local crate " ) .
&'a self
local_codemap
&codemap::CodeMap