aboutsummaryrefslogtreecommitdiff
path: root/lib/xixanta/src/errors.rs
diff options
context:
space:
mode:
authorMiquel Sabaté Solà <mikisabate@gmail.com>2024-11-05 13:39:16 +0100
committerMiquel Sabaté Solà <mikisabate@gmail.com>2024-12-12 07:55:55 +0100
commitf0624b8929e6ead3f2d8b1939dc7f094c539bee1 (patch)
tree649391e261e7d023ade940a1d25f1974143250fd /lib/xixanta/src/errors.rs
parentb768b2c6749986b0efe8610c023b42eb0d9e2ce6 (diff)
downloadtools.nes-f0624b8929e6ead3f2d8b1939dc7f094c539bee1.tar.gz
tools.nes-f0624b8929e6ead3f2d8b1939dc7f094c539bee1.zip
Re-work the handling of segments in the assembler
There were a lot of assumptions on the assembler that stemmed from a fundamental missunderstanding from my side on how segments are laid out on the final file. This commit is the first step to address this. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
Diffstat (limited to 'lib/xixanta/src/errors.rs')
-rw-r--r--lib/xixanta/src/errors.rs19
1 files changed, 13 insertions, 6 deletions
diff --git a/lib/xixanta/src/errors.rs b/lib/xixanta/src/errors.rs
index 6abf280..28eaec1 100644
--- a/lib/xixanta/src/errors.rs
+++ b/lib/xixanta/src/errors.rs
@@ -84,6 +84,7 @@ impl fmt::Display for ContextError {
pub struct EvalError {
pub line: usize,
pub message: String,
+ pub global: bool,
}
impl std::error::Error for EvalError {}
@@ -93,6 +94,7 @@ impl From<std::io::Error> for EvalError {
EvalError {
line: 0,
message: err.to_string(),
+ global: true,
}
}
}
@@ -102,17 +104,22 @@ impl From<ContextError> for EvalError {
EvalError {
line: err.line,
message: err.message,
+ global: false,
}
}
}
impl fmt::Display for EvalError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- write!(
- f,
- "Evaluation error (line {}): {}.",
- self.line + 1,
- self.message
- )
+ if self.global {
+ write!(f, "Evaluation error: {}.", self.message)
+ } else {
+ write!(
+ f,
+ "Evaluation error (line {}): {}.",
+ self.line + 1,
+ self.message
+ )
+ }
}
}