From 165cbcf2f92ea0aa992e96d5feb8aacd9752ac47 Mon Sep 17 00:00:00 2001 From: Miquel Sabaté Solà Date: Wed, 27 Aug 2025 23:57:10 +0200 Subject: xixanta: Be more mindful on what's being exported MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This means removing a lot of `pub` structs or enums, as well as adding documentation on `pub` structs. Signed-off-by: Miquel Sabaté Solà --- lib/xixanta/src/assembler.rs | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/lib/xixanta/src/assembler.rs b/lib/xixanta/src/assembler.rs index 1d08b57..23d4219 100644 --- a/lib/xixanta/src/assembler.rs +++ b/lib/xixanta/src/assembler.rs @@ -13,7 +13,7 @@ use std::ops::Neg; /// The mode in which a literal is expressed. #[derive(Clone, PartialEq)] -pub enum LiteralMode { +enum LiteralMode { /// An 8/16 bit hexadecimal value. Hexadecimal, @@ -27,7 +27,7 @@ pub enum LiteralMode { /// The different stages that the assembler goes through and which are relevant /// for the process. #[derive(PartialEq)] -pub enum Stage { +enum Stage { /// The context is still building up (i.e. we don't have all the variable /// values, labels and their addresses yet). Context, @@ -43,8 +43,10 @@ pub enum Stage { Crunching, } +/// A Node which is pending to be resolved, with all the info necessary so a +/// stage like Stage::Crunching can re-create the original context. #[derive(Clone, Debug)] -pub struct PendingNode { +struct PendingNode { mapping: usize, segment: usize, context: String, @@ -53,7 +55,7 @@ pub struct PendingNode { labels_seen: usize, } -pub struct Assembler<'a> { +struct Assembler<'a> { context: Context, literal_mode: Option, stage: Stage, @@ -83,11 +85,24 @@ pub struct Assembler<'a> { sources: Vec, } +/// All the information that a caller needs after calling either +/// `assembler::assemble` or `assembler::assemble_with_mapping`. #[derive(Debug)] pub struct AssemblerResult { + /// The binary data that comes as a result from assembling a given + /// source. Ignore this if `errors` is not empty. pub bundles: Vec, + + /// Errors which the assembler detected and which should make the + /// application to fail. pub errors: Vec, + + /// Issues caught by the assembler which is up to the application to deem as + /// a failure or not. pub warnings: Vec, + + /// The resulting mappings after assembling a source. You can count on + /// fields like `offset` if `errors` is empty. pub mappings: Vec, } @@ -218,7 +233,7 @@ pub fn assemble_with_mapping( } impl<'a> Assembler<'a> { - pub fn new(mappings: Vec) -> Self { + fn new(mappings: Vec) -> Self { Self { context: Context::new(), literal_mode: None, @@ -238,7 +253,7 @@ impl<'a> Assembler<'a> { } /// Define a new variable by using the given `name` and `value`. - pub fn define_variable_value(&mut self, name: &String, value: u8) -> Result<(), Error> { + fn define_variable_value(&mut self, name: &String, value: u8) -> Result<(), Error> { if name.is_empty() { return Err(Error { global: true, -- cgit v1.2.3