From f0624b8929e6ead3f2d8b1939dc7f094c539bee1 Mon Sep 17 00:00:00 2001 From: Miquel Sabaté Solà Date: Tue, 5 Nov 2024 13:39:16 +0100 Subject: Re-work the handling of segments in the assembler MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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à --- lib/xixanta/src/errors.rs | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'lib/xixanta/src/errors.rs') 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 for EvalError { EvalError { line: 0, message: err.to_string(), + global: true, } } } @@ -102,17 +104,22 @@ impl From 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 + ) + } } } -- cgit v1.2.3