Skip to content

Commit

Permalink
Add function to find a Node by tag ID
Browse files Browse the repository at this point in the history
For CWriter, which needs it to find tag types and cross compilation unit
references.
  • Loading branch information
RA-Kooi committed Oct 11, 2022
1 parent a54b691 commit 578e614
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions DwarfOne2C/Parsing/CompilationUnit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,24 @@ public Node(Tag tag)
this.tag = tag;
children = new();
}

public Node Find(int tagID)
{
Node result = children.Find(n => n.tag.ID == tagID);

if(result != null)
return result;

foreach(Node child in children)
{
result = child.Find(tagID);

if(result != null)
return result;
}

return null;
}
}

public class CompilationUnit
Expand Down

0 comments on commit 578e614

Please sign in to comment.