Skip to content

Commit

Permalink
Fix the last CompilationUnit having an non-existent sibling
Browse files Browse the repository at this point in the history
  • Loading branch information
RA-Kooi committed Sep 13, 2022
1 parent 4fb14b7 commit 52862a2
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions DwarfOne2C/Parsing/DumpParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ private void ApplyFixes()
// but it isn't as thorough.
// Method 1 is the fastest, but is the least thorough.
// Going with method 1 for now until I find it breaks again.
int idx = 1;
void FixChain(Tag parent, ref int i, int depth)
{
int lastIdx = 0;
Expand All @@ -113,8 +112,16 @@ void FixChain(Tag parent, ref int i, int depth)

lastIdx = i;

if(current.tagType == TagType.End)
if(current.tagType == TagType.End && depth > 0)
return;
else if(current.tagType == TagType.End)
continue;

// Fixup the last compile unit having a sibling that doesn't
// exist.
if(current.tagType == TagType.CompileUnit
&& !IDToIndex.ContainsKey(current.sibling))
current.sibling = Tag.NoSibling;

if(prev.sibling != current.ID
&& prev.tagType != TagType.CompileUnit)
Expand All @@ -129,6 +136,7 @@ void FixChain(Tag parent, ref int i, int depth)
}
}

int idx = 0;
FixChain(allTags[0], ref idx, 0);

void Recurse(Tag parent, int depth)
Expand Down

0 comments on commit 52862a2

Please sign in to comment.