1
0
mirror of https://github.com/fadden/6502bench.git synced 2026-04-22 01:16:42 +00:00

Tweak def symbol sort order

The list of EQUs at the top of the file is sorted, by type, then
value, then name.  This adds width as an additional check, so that
if you have overlapping items the widest comes first.

This is nice when you have a general entry for a block of data, and
then specific entries for some locations within the block.
This commit is contained in:
Andy McFadden
2020-01-04 15:11:59 -08:00
parent 5548469ba1
commit 422af1193c
5 changed files with 21 additions and 5 deletions
+17 -1
View File
@@ -1673,7 +1673,7 @@ namespace SourceGen {
// Sort order:
// - constants appear before addresses
// - ascending numeric value
// - ascending numeric value, wider items first
// - ascending label
ActiveDefSymbolList.Sort(delegate (DefSymbol a, DefSymbol b) {
// Put constants first.
@@ -1687,11 +1687,27 @@ namespace SourceGen {
return -1;
} else if (a.Value > b.Value) {
return 1;
} else if (IsWider(a, b)) {
return -1;
} else if (IsWider(b, a)) {
return 1;
}
return Asm65.Label.LABEL_COMPARER.Compare(a.Label, b.Label);
});
}
private bool IsWider(DefSymbol a, DefSymbol b) {
if (!a.HasWidth && !b.HasWidth) {
return false;
} else if (a.HasWidth && !b.HasWidth) {
return true;
} else if (!a.HasWidth && !b.HasWidth) {
return true;
} else {
return a.DataDescriptor.Length > b.DataDescriptor.Length;
}
}
#endregion Analysis