Commit 9ff7bc37 authored by Jesse McGrew's avatar Jesse McGrew
Browse files

Zapf: Clean up PrintLabelAddresses a little.

parent 2ee93d6cb77c
...@@ -157,22 +157,23 @@ namespace Zapf ...@@ -157,22 +157,23 @@ namespace Zapf
Console.Error.WriteLine(); Console.Error.WriteLine();
var query = from s in ctx.GlobalSymbols.Values var query = from s in ctx.GlobalSymbols.Values
where s.Type == SymbolType.Function || s.Type == SymbolType.Label || let addr = s.Type switch
s.Type == SymbolType.String {
let addr = SymbolType.Label => s.Value,
(s.Type == SymbolType.Label) SymbolType.Function => s.Value * ctx.PackingDivisor + ctx.FunctionsOffset,
? s.Value SymbolType.String => s.Value * ctx.PackingDivisor + ctx.StringsOffset,
: (s.Type == SymbolType.Function) _ => (int?)null
? s.Value * ctx.PackingDivisor + ctx.FunctionsOffset }
: /* (s.Type == SymbolType.String) ? */ s.Value * ctx.PackingDivisor + ctx.StringsOffset where addr != null
orderby addr orderby addr.Value
select new { s.Name, Address = addr }; select new { s.Name, Address = addr.Value };
Console.WriteLine("{0,-32} {1,-6} {2,-6}", Console.WriteLine("{0,-32} {1,-6} {2,-6}",
"Name", "Name",
"Addr", "Addr",
"Length"); "Length");
// TODO: don't allocate an array for the label addresses
var entries = query.ToArray(); var entries = query.ToArray();
for (int i = 0; i < entries.Length; i++) for (int i = 0; i < entries.Length; i++)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment