fn resolve_file_refs(&mut self, source_file_ref: SourceFileRef, queue: &mut ResolveQueue) {
        // Steal filename map to decouple its lifetime from the one of the source files vector,
        // and allow lookup while mutably iterating over the source files and their commands
        let mut filename_map = HashMap::new();
        std::mem::swap(&mut filename_map, &mut self.filename_map);

        // Iterate over the commands of the current file and try to enqueue all its unresolved
        // sub-file reference commands for deferred resolution.
        let source_file = self.get_mut(source_file_ref);
        let referer_filename = source_file.filename.clone();
        let mut subfile_set = HashSet::new();
        for cmd in &mut source_file.cmds {
            if let Command::SubFileRef(sfr_cmd) = cmd {
                // All subfile refs come out of parse_raw() as unresolved by definition,
                // since parse_raw() doesn't have access to the source map nor the resolver.
                // See if we can resolve some of them now.
                if let SubFileRef::UnresolvedRef(subfilename) = &sfr_cmd.file {
                    let subfilename = subfilename.clone();
                    // Check the source map
                    if let Some(existing_source_file) = filename_map
                        .get(&subfilename)
                        .map(|&index| SourceFileRef { index })
                    {
                        // If already parsed, reuse
                        trace!(
                            "Updating resolved subfile ref in {} -> {}",
                            referer_filename,
                            subfilename
                        );
                        sfr_cmd.file = SubFileRef::ResolvedRef(existing_source_file);
                    } else if subfile_set.contains(&subfilename) {
                        trace!(
                            "Ignoring already-queued unresolved subfile ref in {} -> {}",
                            referer_filename,
                            subfilename
                        );
                    } else {
                        // If not, push to queue for later parsing, but only once
                        trace!(
                            "Queuing unresolved subfile ref in {} -> {}",
                            referer_filename,
                            subfilename
                        );
                        queue.push(&subfilename[..], &referer_filename[..], source_file_ref);
                        subfile_set.insert(subfilename);
                    }
                }
            }
        }

        // Restore the filename map
        std::mem::swap(&mut filename_map, &mut self.filename_map);
    }
/// Attempt to resolve the sub-file references of a given source file, and insert unresolved
/// references into the given [`ResolveQueue`].
Attempt to resolve the sub-file references of a given source file, and insert unresolved
references into the given [`ResolveQueue`].
Attempt to resolve the sub - file references of a given source file and insert unresolved references into the given [ ` ResolveQueue ` ] .
fn resolve_file_refs(&mut self, source_file_ref: SourceFileRef, queue: &mut ResolveQueue) {
        // Steal filename map to decouple its lifetime from the one of the source files vector,
        // and allow lookup while mutably iterating over the source files and their commands
        let mut filename_map = HashMap::new();
        std::mem::swap(&mut filename_map, &mut self.filename_map);
        // Iterate over the commands of the current file and try to enqueue all its unresolved
        // sub-file reference commands for deferred resolution.
        let source_file = self.get_mut(source_file_ref);
        let referer_filename = source_file.filename.clone();
        let mut subfile_set = HashSet::new();
        for cmd in &mut source_file.cmds {
            if let Command::SubFileRef(sfr_cmd) = cmd {
                // All subfile refs come out of parse_raw() as unresolved by definition,
                // since parse_raw() doesn't have access to the source map nor the resolver.
                // See if we can resolve some of them now.
                if let SubFileRef::UnresolvedRef(subfilename) = &sfr_cmd.file {
                    let subfilename = subfilename.clone();
                    // Check the source map
                    if let Some(existing_source_file) = filename_map
                        .get(&subfilename)
                        .map(|&index| SourceFileRef { index })
                    {
                        // If already parsed, reuse
                        trace!(
                            "Updating resolved subfile ref in {} -> {}",
                            referer_filename,
                            subfilename
                        );
                        sfr_cmd.file = SubFileRef::ResolvedRef(existing_source_file);
                    } else if subfile_set.contains(&subfilename) {
                        trace!(
                            "Ignoring already-queued unresolved subfile ref in {} -> {}",
                            referer_filename,
                            subfilename
                        );
                    } else {
                        // If not, push to queue for later parsing, but only once
                        trace!(
                            "Queuing unresolved subfile ref in {} -> {}",
                            referer_filename,
                            subfilename
                        );
                        queue.push(&subfilename[..], &referer_filename[..], source_file_ref);
                        subfile_set.insert(subfilename);
                    }
                }
            }
        }
        // Restore the filename map
        std::mem::swap(&mut filename_map, &mut self.filename_map);
    }
fn resolve_file_refs ( & mut self , source_file_ref : SourceFileRef , queue : & mut ResolveQueue ) { // Steal filename map to decouple its lifetime from the one of the source files vector, // and allow lookup while mutably iterating over the source files and their commands let mut filename_map = HashMap :: new ( ) ; std :: mem :: swap ( & mut filename_map , & mut self . filename_map ) ; // Iterate over the commands of the current file and try to enqueue all its unresolved // sub-file reference commands for deferred resolution. let source_file = self . get_mut ( source_file_ref ) ; let referer_filename = source_file . filename . clone ( ) ; let mut subfile_set = HashSet :: new ( ) ; for cmd in & mut source_file . cmds { if let Command :: SubFileRef ( sfr_cmd ) = cmd { // All subfile refs come out of parse_raw() as unresolved by definition, // since parse_raw() doesn't have access to the source map nor the resolver. // See if we can resolve some of them now. if let SubFileRef :: UnresolvedRef ( subfilename ) = & sfr_cmd . file { let subfilename = subfilename . clone ( ) ; // Check the source map if let Some ( existing_source_file ) = filename_map . get ( & subfilename ) . map ( | & index | SourceFileRef { index } ) { // If already parsed, reuse trace ! ( " " referer_filename subfilename ) ; sfr_cmd . file = SubFileRef :: ResolvedRef ( existing_source_file ) ; } else if subfile_set . contains ( & subfilename ) { trace ! ( " " referer_filename subfilename ) ; } else { // If not, push to queue for later parsing, but only once trace ! ( " " referer_filename subfilename ) ; queue . push ( & subfilename [ .. ] , & referer_filename [ .. ] , source_file_ref ) ; subfile_set . insert ( subfilename ) ; } } } } // Restore the filename map std :: mem :: swap ( & mut filename_map , & mut self . filename_map ) ; }
Attempt to resolve the sub-file references of a given source file, and insert unresolved
references into the given [`ResolveQueue`].
Attempt to resolve the sub - file references of a given source file and insert unresolved references into the given [ ` ResolveQueue ` ] .
&mut self
source_file_ref
SourceFileRef
queue
&mut ResolveQueue
&mut self
source_file_ref
SourceFileRef
queue
&mut ResolveQueue