Integrate all the progress into master #6

Merged
jaby merged 595 commits from ToolBox into main 2025-01-01 13:17:44 +00:00
1 changed files with 24 additions and 9 deletions
Showing only changes of commit 2ab4e8b155 - Show all commits

View File

@ -7,17 +7,32 @@ pub fn scan<F: FnMut() -> Option<String>>(mut next_line: F) -> Result<MemoryMap,
const SECTION_IDENTIFIER:&'static str = "Sections:";
const SYMBOL_TABLE_IDENTIFIER:&'static str = "SYMBOL TABLE:";
while let Some(line) = next_line() {
if line == SECTION_IDENTIFIER {
scan_sections(&mut next_line)?;
}
let mut memory_map = MemoryMap::default();
if line == SYMBOL_TABLE_IDENTIFIER {}
while let Some(mut line) = next_line() {
loop {
// loop so we pick-up changes of line
if line == SECTION_IDENTIFIER {
line = scan_sections(&mut next_line, &mut memory_map.sections)?;
continue;
}
if line == SYMBOL_TABLE_IDENTIFIER {
// Process Symbol table here
}
break;
}
}
// Print them off for now!
for section in memory_map.sections {
println!("Name: {}", section.name);
}
Err(Error::not_implemented("scan"))
}
fn scan_sections<F: FnMut() -> Option<String>>(next_line: &mut F) -> Result<Vec<Section>, Error> {
fn scan_sections<F: FnMut() -> Option<String>>(next_line: &mut F, sections: &mut Vec<Section>) -> Result<String, Error> {
while let Some(_) = next_line() {
// We read every other line
let line = next_line().ok_or(Error::from_str("Failed skipping section line"))?;
@ -27,15 +42,15 @@ fn scan_sections<F: FnMut() -> Option<String>>(next_line: &mut F) -> Result<Vec<
let size = split_line_radix(&mut split_line, 16, "Section Size")?;
let adr = split_line_radix(&mut split_line, 16, "Section Address")?;
println!("\"{}\" @0x{:X} -> 0x{:X}", name, adr, (adr + size));
sections.push(Section::new(name.to_string(), adr, size as usize));
}
else {
return Err(Error::from_str("<No proper return value yet>"));
return Ok(line);
}
}
Err(Error::not_implemented("scan"))
Err(Error::not_implemented("Failed obtaining complete section"))
}
fn split_line_radix<'a>(split_line: &mut std::str::SplitWhitespace<'a>, radix: u32, value_name: &str) -> Result<u64, Error> {