Struct debris_common::InputFiles
source · pub struct InputFiles {
input_files: Vec<InputFile>,
}
Expand description
Keeps track of all input files and allows to make cheap copy-able spans
Fields§
§input_files: Vec<InputFile>
All input files which are used in this compiler
This vector is append-only and the offset of the input files is guaranteed to be increasing.
Implementations§
source§impl InputFiles
impl InputFiles
pub fn new() -> Self
pub fn get_code_ref(&self, code_id: CodeId) -> CodeRef<'_>
sourcepub fn find_by_filename(&self, filename: &str) -> Option<CodeId>
pub fn find_by_filename(&self, filename: &str) -> Option<CodeId>
Searches the registered InputFile
s and returns the first with a matching filename
sourcepub fn get_input_offset(&self, code_id: CodeId) -> usize
pub fn get_input_offset(&self, code_id: CodeId) -> usize
Gets the offset of the file with this id
sourcepub fn get_total_offset(&self) -> usize
pub fn get_total_offset(&self) -> usize
Calculates the total byte offset
sourcefn get_span_file(&self, span: Span) -> (usize, &InputFile)
fn get_span_file(&self, span: Span) -> (usize, &InputFile)
Searches for the input file that contains the given span
Returns a (index, &input_file)
tuple.
Since the input files are stored sorted, the search can be
completed with O(log n) time complexity
pub fn get_span_code(&self, span: Span) -> CodeRef<'_>
sourcepub fn get_span_str(&self, span: Span) -> &str
pub fn get_span_str(&self, span: Span) -> &str
Trait Implementations§
source§impl Debug for InputFiles
impl Debug for InputFiles
source§impl Default for InputFiles
impl Default for InputFiles
source§fn default() -> InputFiles
fn default() -> InputFiles
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl RefUnwindSafe for InputFiles
impl Send for InputFiles
impl Sync for InputFiles
impl Unpin for InputFiles
impl UnwindSafe for InputFiles
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more