Skip to content

Commit 9f8c55e

Browse files
Support anonymous type names as seen in PS2 DWARF (#25)
1 parent 6b59c67 commit 9f8c55e

File tree

1 file changed

+28
-6
lines changed

1 file changed

+28
-6
lines changed

src/util/dwarf.rs

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1043,7 +1043,9 @@ fn structure_type_string(
10431043
include_anonymous_def: bool,
10441044
) -> Result<TypeString> {
10451045
let prefix = if let Some(name) = t.name.as_ref() {
1046-
if include_keyword {
1046+
if name.starts_with('@') {
1047+
struct_def_string(info, typedefs, t)?
1048+
} else if include_keyword {
10471049
match t.kind {
10481050
StructureKind::Struct => format!("struct {}", name),
10491051
StructureKind::Class => format!("class {}", name),
@@ -1075,7 +1077,9 @@ fn enumeration_type_string(
10751077
include_anonymous_def: bool,
10761078
) -> Result<TypeString> {
10771079
let prefix = if let Some(name) = t.name.as_ref() {
1078-
if include_keyword {
1080+
if name.starts_with('@') {
1081+
enum_def_string(t)?
1082+
} else if include_keyword {
10791083
format!("enum {}", name)
10801084
} else {
10811085
name.clone()
@@ -1098,7 +1102,9 @@ fn union_type_string(
10981102
include_anonymous_def: bool,
10991103
) -> Result<TypeString> {
11001104
let prefix = if let Some(name) = t.name.as_ref() {
1101-
if include_keyword {
1105+
if name.starts_with('@') {
1106+
union_def_string(info, typedefs, t)?
1107+
} else if include_keyword {
11021108
format!("union {}", name)
11031109
} else {
11041110
name.clone()
@@ -1411,7 +1417,11 @@ pub fn struct_def_string(
14111417
StructureKind::Class => "class".to_string(),
14121418
};
14131419
if let Some(name) = t.name.as_ref() {
1414-
write!(out, " {}", name)?;
1420+
if name.starts_with('@') {
1421+
write!(out, " /* {} */", name)?;
1422+
} else {
1423+
write!(out, " {}", name)?;
1424+
}
14151425
}
14161426
let mut wrote_base = false;
14171427
for base in &t.bases {
@@ -1468,7 +1478,13 @@ pub fn struct_def_string(
14681478

14691479
pub fn enum_def_string(t: &EnumerationType) -> Result<String> {
14701480
let mut out = match t.name.as_ref() {
1471-
Some(name) => format!("enum {} {{\n", name),
1481+
Some(name) => {
1482+
if name.starts_with('@') {
1483+
format!("enum /* {} */ {{\n", name)
1484+
} else {
1485+
format!("enum {} {{\n", name)
1486+
}
1487+
}
14721488
None => "enum {\n".to_string(),
14731489
};
14741490
for member in t.members.iter() {
@@ -1480,7 +1496,13 @@ pub fn enum_def_string(t: &EnumerationType) -> Result<String> {
14801496

14811497
pub fn union_def_string(info: &DwarfInfo, typedefs: &TypedefMap, t: &UnionType) -> Result<String> {
14821498
let mut out = match t.name.as_ref() {
1483-
Some(name) => format!("union {} {{\n", name),
1499+
Some(name) => {
1500+
if name.starts_with('@') {
1501+
format!("union /* {} */ {{\n", name)
1502+
} else {
1503+
format!("union {} {{\n", name)
1504+
}
1505+
}
14841506
None => "union {\n".to_string(),
14851507
};
14861508
let mut var_out = String::new();

0 commit comments

Comments
 (0)