Skip to content

Commit

Permalink
Parse global/static variable locations
Browse files Browse the repository at this point in the history
And output them
  • Loading branch information
RA-Kooi committed Jan 28, 2022
1 parent 594605e commit e02f24e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
10 changes: 8 additions & 2 deletions DwarfOne2C/CWriter/CWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions DwarfOne2C/Parsing/BlockParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);
}

Expand Down
5 changes: 4 additions & 1 deletion DwarfOne2C/Tags.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit e02f24e

Please sign in to comment.