From 16114b2ca358dbbef09cb5a8d3a843a0e11a3b88 Mon Sep 17 00:00:00 2001 From: Miquel Sabaté Solà Date: Wed, 9 Oct 2024 15:41:30 +0200 Subject: Adapt the assembler to the changes on the parser MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As of 184c39579227 ("Re-work the parser from scratch") the parser has a proper AST, and the assembler has to traverse it accordingly. Moreover, the assembler has been stripped from a lot of unneeded memory allocations and it's overall more keen on using mere references when possible. Signed-off-by: Miquel Sabaté Solà --- lib/xixanta/src/mapping.rs | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) (limited to 'lib/xixanta/src/mapping.rs') diff --git a/lib/xixanta/src/mapping.rs b/lib/xixanta/src/mapping.rs index 231883f..9d313a5 100644 --- a/lib/xixanta/src/mapping.rs +++ b/lib/xixanta/src/mapping.rs @@ -1,9 +1,3 @@ -use crate::instruction::{Fill, Node, PString}; -use std::collections::HashMap; - -use crate::errors::ParseError; -type Result = std::result::Result; - lazy_static! { pub static ref EMPTY: Vec = vec![Segment { name: String::from("CODE"), @@ -16,25 +10,25 @@ lazy_static! { name: String::from("HEADER"), start: 0x0000, size: 0x0010, - fill: Some(Fill { value: 0x00 }), + fill: Some(0x00), }, Segment { name: String::from("VECTORS"), start: 0xFFFA, size: 0x0006, - fill: Some(Fill { value: 0x00 }), + fill: Some(0x00), }, Segment { name: String::from("CODE"), start: 0x8000, size: 0x7FFA, - fill: Some(Fill { value: 0x00 }), + fill: Some(0x00), }, Segment { name: String::from("CHARS"), start: 0x0000, size: 0x2000, - fill: Some(Fill { value: 0x00 }), + fill: Some(0x00), } ]; } @@ -44,9 +38,10 @@ pub struct Segment { pub name: String, pub start: u16, pub size: usize, - pub fill: Option, + pub fill: Option, } +/* TODO #[derive(Debug)] pub struct Mapping { pub segments: Vec, @@ -90,9 +85,10 @@ impl Mapping { pub fn switch(&mut self, id: &PString) -> Result<()> { if !self.nodes.contains_key(&id.value) { - return Err( - id.parser_error(format!("segment '{}' has not been defined", id.value).as_str()) - ); + // TODO + // return Err( + // id.parser_error(format!("segment '{}' has not been defined", id.value).as_str()) + // ); } id.value.clone_into(&mut self.current); @@ -114,3 +110,4 @@ impl Mapping { } } } +*/ -- cgit v1.2.3