Compare commits

...

2 Commits

Author SHA1 Message Date
Luke Street 038354a37e Version 0.6.1 2023-11-22 13:01:42 -05:00
Luke Street e3d6ef8492 dwarf dump: Fix padding handling within tag children
Fixes #9
2023-11-22 12:59:03 -05:00
3 changed files with 15 additions and 13 deletions

2
Cargo.lock generated
View File

@ -295,7 +295,7 @@ dependencies = [
[[package]] [[package]]
name = "decomp-toolkit" name = "decomp-toolkit"
version = "0.6.0" version = "0.6.1"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"ar", "ar",

View File

@ -3,7 +3,7 @@ name = "decomp-toolkit"
description = "Yet another GameCube/Wii decompilation toolkit." description = "Yet another GameCube/Wii decompilation toolkit."
authors = ["Luke Street <luke@street.dev>"] authors = ["Luke Street <luke@street.dev>"]
license = "MIT OR Apache-2.0" license = "MIT OR Apache-2.0"
version = "0.6.0" version = "0.6.1"
edition = "2021" edition = "2021"
publish = false publish = false
repository = "https://github.com/encounter/decomp-toolkit" repository = "https://github.com/encounter/decomp-toolkit"

View File

@ -373,20 +373,19 @@ impl Tag {
pub fn children<'a>(&self, tags: &'a TagMap) -> Vec<&'a Tag> { pub fn children<'a>(&self, tags: &'a TagMap) -> Vec<&'a Tag> {
let sibling = self.next_sibling(tags); let sibling = self.next_sibling(tags);
let mut children = Vec::new(); let mut children = Vec::new();
let (_, mut child) = match tags.range(self.key + 1..).next() { let mut child = match self.next_tag(tags) {
Some(child) => child, Some(child) => child,
None => return children, None => return children,
}; };
if child.kind == TagKind::Padding {
return children;
}
loop { loop {
if let Some(end) = sibling { if let Some(end) = sibling {
if child.key == end.key { if child.key == end.key {
break; break;
} }
} }
children.push(child); if child.kind != TagKind::Padding {
children.push(child);
}
match child.next_sibling(tags) { match child.next_sibling(tags) {
Some(next) => child = next, Some(next) => child = next,
None => break, None => break,
@ -395,15 +394,18 @@ impl Tag {
children children
} }
/// Returns the next sibling tag, if any
pub fn next_sibling<'a>(&self, tags: &'a TagMap) -> Option<&'a Tag> { pub fn next_sibling<'a>(&self, tags: &'a TagMap) -> Option<&'a Tag> {
if let Some(key) = self.reference_attribute(AttributeKind::Sibling) { if let Some(key) = self.reference_attribute(AttributeKind::Sibling) {
if let Some(next) = tags.get(&key) { tags.get(&key)
if next.kind != TagKind::Padding { } else {
return Some(next); self.next_tag(tags)
}
}
} }
None }
/// Returns the next tag sequentially, if any
pub fn next_tag<'a>(&self, tags: &'a TagMap) -> Option<&'a Tag> {
tags.range(self.key + 1..).next().map(|(_, tag)| tag)
} }
} }