mirror of
https://github.com/fadden/6502bench.git
synced 2024-11-17 09:04:43 +00:00
Tweak var table sort order
Still primarily ascending numeric order, but now we use the symbol type as the secondary sort instead of the label. Also, fix References crash on first line of empty var table.
This commit is contained in:
parent
4a02cb9846
commit
9e4949ab21
@ -1345,9 +1345,12 @@ namespace SourceGen {
|
||||
}
|
||||
int tableIndex = line.SubLineIndex;
|
||||
if (lvt.ClearPrevious) {
|
||||
if (--tableIndex < 0) {
|
||||
return null;
|
||||
tableIndex--;
|
||||
}
|
||||
if (tableIndex < 0 || tableIndex >= lvt.Count) {
|
||||
// Will be -1 on first line when ClearPrevious was set. Will be zero on
|
||||
// first line of empty table.
|
||||
return null;
|
||||
}
|
||||
|
||||
return lvt[tableIndex];
|
||||
|
@ -112,15 +112,22 @@ namespace SourceGen {
|
||||
|
||||
private void SortIfNeeded() {
|
||||
if (mNeedSort) {
|
||||
// Currently sorting primarily by value, secondarily by label. This ordering
|
||||
// determines how it appears in the code list. If we want to make it
|
||||
// Currently sorting primarily by value, secondarily by symbol type. This
|
||||
// ordering determines how it appears in the code list. If we want to make it
|
||||
// configurable we just need to replace the sort function.
|
||||
mVarByValue.Sort((a, b) => {
|
||||
// Numeric ascending.
|
||||
int diff = a.Value - b.Value;
|
||||
if (diff != 0) {
|
||||
return diff;
|
||||
}
|
||||
return a.Label.CompareTo(b.Label);
|
||||
// DP addr first, StackRel const second
|
||||
if (a.SymbolType == Symbol.Type.ExternalAddr) {
|
||||
return -1;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
//return a.Label.CompareTo(b.Label);
|
||||
});
|
||||
mNeedSort = false;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user