From eab76680841a242d29c25b865491676f7285302f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C3=ABl=20Kooi?= <48814281+RA-Kooi@users.noreply.github.com> Date: Fri, 28 Jan 2022 14:55:23 +0100 Subject: [PATCH] Parse function referenced variables --- DwarfOne2C/Parsing/BlockParser.cs | 4 ++-- DwarfOne2C/Parsing/Helpers.cs | 16 ++++++++++++++++ DwarfOne2C/Tags.cs | 4 ++++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/DwarfOne2C/Parsing/BlockParser.cs b/DwarfOne2C/Parsing/BlockParser.cs index d4d88ed..3c33e54 100644 --- a/DwarfOne2C/Parsing/BlockParser.cs +++ b/DwarfOne2C/Parsing/BlockParser.cs @@ -210,7 +210,7 @@ private Tag ParseFunction( if(!line.StartsWith("AT_low_pc") && !line.StartsWith("AT_high_pc") - && !line.StartsWith('(') + && !ParseReference(line, tag) && !ParseName(line, tag) && !ParseTypes(line, tag) && !ParseLoUser(line, tag) @@ -446,7 +446,7 @@ private Tag ParsePadding( && !ParseTypes(line, tag) && !ParseLoUser(line, tag) && !ParseAtMember(line, tag) - && !line.StartsWith('(') + && !ParseReference(line, tag) && !line.StartsWith("AT_location")) Console.Error.WriteLine("Unkown attribute: " + line + " @" + current); } diff --git a/DwarfOne2C/Parsing/Helpers.cs b/DwarfOne2C/Parsing/Helpers.cs index d8b5d53..de843df 100644 --- a/DwarfOne2C/Parsing/Helpers.cs +++ b/DwarfOne2C/Parsing/Helpers.cs @@ -325,5 +325,21 @@ private static bool ParseLoUser(string line, Tag tag) return false; } + + private static bool ParseReference(string line, Tag tag) + { + if(line.StartsWith('(')) + { + int reference = Convert.ToInt32( + line.Substring(1, line.Length - 2), + 16); + + tag.references.Add(reference); + + return true; + } + + return false; + } } } diff --git a/DwarfOne2C/Tags.cs b/DwarfOne2C/Tags.cs index 7f05928..04cfaf3 100644 --- a/DwarfOne2C/Tags.cs +++ b/DwarfOne2C/Tags.cs @@ -131,6 +131,10 @@ public enum TagType // Padding public bool isFunction = false; + + // Padding + // Function + public List references = new(); } public class Type