summaryrefslogtreecommitdiff
path: root/src/source_hierarchy.rs
diff options
context:
space:
mode:
authorBen Bridle <bridle.benjamin@gmail.com>2025-02-10 11:56:58 +1300
committerBen Bridle <bridle.benjamin@gmail.com>2025-02-10 11:56:58 +1300
commitfd6b4471955dac64b7d40b7c31992c15d52b2460 (patch)
tree5b2561150e0eac0922a8ff40dd34da6a3ca76f7c /src/source_hierarchy.rs
parent2d67476d48fcb33cd1c59cbc2e0f82872bc0c217 (diff)
downloadassembler-fd6b4471955dac64b7d40b7c31992c15d52b2460.zip
Move report-printing structs to separate module
Diffstat (limited to 'src/source_hierarchy.rs')
-rw-r--r--src/source_hierarchy.rs58
1 files changed, 0 insertions, 58 deletions
diff --git a/src/source_hierarchy.rs b/src/source_hierarchy.rs
deleted file mode 100644
index 9478c56..0000000
--- a/src/source_hierarchy.rs
+++ /dev/null
@@ -1,58 +0,0 @@
-use crate::*;
-
-use ansi::*;
-
-
-pub struct SourceHierarchy<'a> {
- pub resolver: &'a Resolver,
-}
-
-impl<'a> SourceHierarchy<'a> {
- pub fn report(&self) {
- eprintln!(".");
- let len = self.resolver.root_unit_ids.len();
- for (i, id) in self.resolver.root_unit_ids.iter().enumerate() {
- let end = i + 1 == len;
- self.report_leaf(*id, Vec::new(), end);
- }
- }
-
- fn report_leaf(&self, id: usize, mut levels: Vec<bool>, end: bool) {
- // A level entry is true if all entries in that level have been printed.
- for level in &levels {
- match level {
- false => eprint!("│ "),
- true => eprint!(" "),
- }
- }
- // The end value is true if all siblings of this entry have been printed.
- match end {
- false => eprint!("├── "),
- true => eprint!("└── "),
- }
- if let Some(unit) = self.resolver.source_units.get(id) {
- let path_str = &unit.source_unit.main.path.as_os_str().to_string_lossy();
- if let Some(name_str) = unit.source_unit.name() {
- eprint!("{name_str}{BLUE}");
- if unit.source_unit.head.is_some() { eprint!(" +head") }
- if unit.source_unit.tail.is_some() { eprint!(" +tail") }
- let mut unresolved = 0;
- for symbol in &self.resolver.unresolved {
- if symbol.source_id == id { unresolved += 1; }
- }
- if unresolved > 0 { eprint!("{RED} ({unresolved})"); }
- eprintln!("{NORMAL} {DIM}({path_str}){NORMAL}");
- } else {
- eprintln!("{path_str}");
- }
- levels.push(end);
- let len = unit.child_ids.len();
- for (i, id) in unit.child_ids.iter().enumerate() {
- let end = i + 1 == len;
- self.report_leaf(*id, levels.clone(), end);
- }
- } else {
- eprintln!("<error loading source unit details>");
- }
- }
-}