diff options
author | Ben Bridle <ben@derelict.engineering> | 2025-03-11 16:18:01 +1300 |
---|---|---|
committer | Ben Bridle <ben@derelict.engineering> | 2025-03-11 16:18:01 +1300 |
commit | a9e9dd452e23fa2e816df926a56c1f743eb32488 (patch) | |
tree | 633665f936b41f1289104dc23e299a8135f990be /src/locators | |
parent | bd7955cbc1c1746f37dcb0742603994fd2e04c90 (diff) | |
download | assembler-a9e9dd452e23fa2e816df926a56c1f743eb32488.zip |
Implement source chains
A SourceSpan can now contain a child SourceSpan, ad infinitum, in order
to represent a chain of locations. The report_source_issue function
has been changed to print the entire chain, instead of just one
SourceSpan.
The report_source_issue function has also been changed to correctly
print SourceSpans that extend across multiple source lines.
Diffstat (limited to 'src/locators')
-rw-r--r-- | src/locators/source.rs | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/locators/source.rs b/src/locators/source.rs index 6837133..7e5abd2 100644 --- a/src/locators/source.rs +++ b/src/locators/source.rs @@ -9,12 +9,19 @@ pub struct SourceSpan { pub in_merged: SourceLocation, /// The location of this span in the original source file. pub in_source: Option<SourceLocation>, + /// Drill down to a more accurate location. + pub child: Option<Box<SourceSpan>>, } impl SourceSpan { pub fn location(&self) -> &SourceLocation { self.in_source.as_ref().unwrap_or(&self.in_merged) } + + /// Wrap this source span around a child source span. + pub fn wrap(mut self, source: SourceSpan) -> Self { + self.child = Some(Box::new(source)); self + } } |