incr.comp.: Track expanded spans instead of FileMaps.

This commit is contained in:
Michael Woerister
2017-05-23 16:21:24 +02:00
parent 5b13bff520
commit 21dd71f514
12 changed files with 78 additions and 139 deletions

View File

@@ -103,18 +103,11 @@ impl FileLoader for RealFileLoader {
//
pub struct CodeMap {
// The `files` field should not be visible outside of libsyntax so that we
// can do proper dependency tracking.
pub(super) files: RefCell<Vec<Rc<FileMap>>>,
file_loader: Box<FileLoader>,
// This is used to apply the file path remapping as specified via
// -Zremap-path-prefix to all FileMaps allocated within this CodeMap.
path_mapping: FilePathMapping,
// The CodeMap will invoke this callback whenever a specific FileMap is
// accessed. The callback starts out as a no-op but when the dependency
// graph becomes available later during the compilation process, it is
// be replaced with something that notifies the dep-tracking system.
dep_tracking_callback: RefCell<Box<Fn(&FileMap)>>,
}
impl CodeMap {
@@ -123,7 +116,6 @@ impl CodeMap {
files: RefCell::new(Vec::new()),
file_loader: Box::new(RealFileLoader),
path_mapping: path_mapping,
dep_tracking_callback: RefCell::new(Box::new(|_| {})),
}
}
@@ -134,7 +126,6 @@ impl CodeMap {
files: RefCell::new(Vec::new()),
file_loader: file_loader,
path_mapping: path_mapping,
dep_tracking_callback: RefCell::new(Box::new(|_| {})),
}
}
@@ -142,10 +133,6 @@ impl CodeMap {
&self.path_mapping
}
pub fn set_dep_tracking_callback(&self, cb: Box<Fn(&FileMap)>) {
*self.dep_tracking_callback.borrow_mut() = cb;
}
pub fn file_exists(&self, path: &Path) -> bool {
self.file_loader.file_exists(path)
}
@@ -156,15 +143,6 @@ impl CodeMap {
}
pub fn files(&self) -> Ref<Vec<Rc<FileMap>>> {
let files = self.files.borrow();
for file in files.iter() {
(self.dep_tracking_callback.borrow())(file);
}
files
}
/// Only use this if you do your own dependency tracking!
pub fn files_untracked(&self) -> Ref<Vec<Rc<FileMap>>> {
self.files.borrow()
}
@@ -311,8 +289,6 @@ impl CodeMap {
let files = self.files.borrow();
let f = (*files)[idx].clone();
(self.dep_tracking_callback.borrow())(&f);
match f.lookup_line(pos) {
Some(line) => Ok(FileMapAndLine { fm: f, line: line }),
None => Err(f)
@@ -502,7 +478,6 @@ impl CodeMap {
pub fn get_filemap(&self, filename: &str) -> Option<Rc<FileMap>> {
for fm in self.files.borrow().iter() {
if filename == fm.name {
(self.dep_tracking_callback.borrow())(fm);
return Some(fm.clone());
}
}
@@ -513,7 +488,6 @@ impl CodeMap {
pub fn lookup_byte_offset(&self, bpos: BytePos) -> FileMapAndBytePos {
let idx = self.lookup_filemap_idx(bpos);
let fm = (*self.files.borrow())[idx].clone();
(self.dep_tracking_callback.borrow())(&fm);
let offset = bpos - fm.start_pos;
FileMapAndBytePos {fm: fm, pos: offset}
}
@@ -524,8 +498,6 @@ impl CodeMap {
let files = self.files.borrow();
let map = &(*files)[idx];
(self.dep_tracking_callback.borrow())(map);
// The number of extra bytes due to multibyte chars in the FileMap
let mut total_extra_bytes = 0;