diff --git a/DwarfOne2C/CWriter/CWriter.cs b/DwarfOne2C/CWriter/CWriter.cs index 8336b27..9e2a27d 100644 --- a/DwarfOne2C/CWriter/CWriter.cs +++ b/DwarfOne2C/CWriter/CWriter.cs @@ -80,7 +80,10 @@ public void GenerateCode(CompilationUnit unit) continue; if(current.comment != null) - code.Add("// " + current.comment); + code.Add($"// {current.comment}"); + + if(current.location != -1) + code.Add($"// Location: 0x{current.location:X}"); (string part1, string part2) = GetType( allTags, @@ -101,7 +104,10 @@ public void GenerateCode(CompilationUnit unit) code.Add("// Local to compilation unit"); if(current.comment != null) - code.Add("// " + current.comment); + code.Add($"// {current.comment}"); + + if(current.location != -1) + code.Add($"// Location: 0x{current.location:X}"); (string part1, string part2) = GetType( allTags, diff --git a/DwarfOne2C/Parsing/BlockParser.cs b/DwarfOne2C/Parsing/BlockParser.cs index 736a016..d4d88ed 100644 --- a/DwarfOne2C/Parsing/BlockParser.cs +++ b/DwarfOne2C/Parsing/BlockParser.cs @@ -264,7 +264,7 @@ private Tag ParseLocalVariable( if(!ParseName(line, tag) && !ParseTypes(line, tag) - && !line.StartsWith("AT_location")) + && !ParseLocation(line, tag)) Console.Error.WriteLine("Unknown attribute: " + line + " @" + current); } @@ -358,7 +358,7 @@ private Tag ParseGlobalVariable( if(!ParseName(line, tag) && !ParseTypes(line, tag) && !ParseLoUser(line, tag) - && !line.StartsWith("AT_location")) + && !ParseLocation(line, tag)) Console.Error.WriteLine("Unknown attribute: " + line + " @" + current); } diff --git a/DwarfOne2C/Tags.cs b/DwarfOne2C/Tags.cs index a6eddf8..7f05928 100644 --- a/DwarfOne2C/Tags.cs +++ b/DwarfOne2C/Tags.cs @@ -114,7 +114,10 @@ public enum TagType // Inheritance // Member // Typedef (indirect) - public int location = -1; // for class member ordering + // ^^^ For class member ordering ^^^ + // Global variables + // CULocal variables + public int location = -1; // Member (union) public int bitSize = -1, bitOffset = -1;