Skip to content

Commit

Permalink
Also include enums in the depth ordering phase
Browse files Browse the repository at this point in the history
  • Loading branch information
ergrelet committed Mar 22, 2024
1 parent b443586 commit 263b53e
Showing 1 changed file with 26 additions and 21 deletions.
47 changes: 26 additions & 21 deletions resym_core/src/pdb_types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -501,59 +501,64 @@ impl Data<'_> {
&self,
fmt_configuration: &DataFormatConfiguration,
type_depth_map: &BTreeMap<usize, Vec<pdb::TypeIndex>>,
f: &mut impl std::fmt::Write,
output_writer: &mut impl std::fmt::Write,
) -> Result<()> {
// Types without definition
if !self.forward_references.is_empty() {
writeln!(f)?;
writeln!(output_writer)?;
}
for e in self.forward_references.values() {
e.reconstruct(fmt_configuration, f)?;
e.reconstruct(fmt_configuration, output_writer)?;
}

// Forward declarations
if !self.forward_declarations.is_empty() {
writeln!(f)?;
writeln!(output_writer)?;
}
for e in self.forward_declarations.values() {
e.reconstruct(fmt_configuration, f)?;
}

// Enum definitions
for e in self.enums.values() {
writeln!(f)?;
e.reconstruct(fmt_configuration, f)?;
e.reconstruct(fmt_configuration, output_writer)?;
}

if !type_depth_map.is_empty() {
// Follow type depth map order
for type_indices in type_depth_map.values().rev() {
for type_index in type_indices.iter() {
// Enum definitions
if let Some(e) = self.enums.get(type_index) {
writeln!(output_writer)?;
e.reconstruct(fmt_configuration, output_writer)?;
}
// Class definitions
if let Some(class) = self.classes.get(type_index) {
writeln!(f)?;
class.reconstruct(fmt_configuration, f)?;
else if let Some(c) = self.classes.get(type_index) {
writeln!(output_writer)?;
c.reconstruct(fmt_configuration, output_writer)?;
}
// Union definitions
else if let Some(union) = self.unions.get(type_index) {
writeln!(f)?;
union.reconstruct(fmt_configuration, f)?;
else if let Some(u) = self.unions.get(type_index) {
writeln!(output_writer)?;
u.reconstruct(fmt_configuration, output_writer)?;
}
}
}
} else {
// Follow type index order
//
// Enum definitions
for e in self.enums.values() {
writeln!(output_writer)?;
e.reconstruct(fmt_configuration, output_writer)?;
}

// Class/struct definitions
for class in self.classes.values() {
writeln!(f)?;
class.reconstruct(fmt_configuration, f)?;
writeln!(output_writer)?;
class.reconstruct(fmt_configuration, output_writer)?;
}

// Union definitions
for u in self.unions.values() {
writeln!(f)?;
u.reconstruct(fmt_configuration, f)?;
writeln!(output_writer)?;
u.reconstruct(fmt_configuration, output_writer)?;
}
}

Expand Down

0 comments on commit 263b53e

Please sign in to comment.