1
0
mirror of https://github.com/fadden/6502bench.git synced 2025-09-25 03:27:01 +00:00

Fix various local variable de-duplication bugs

In 1.5.0-dev1, as part of changes to the way label localization
works, the local variable de-duplicator started checking against a
filtered copy of the symbol table.  Unfortunately it never
re-generated the table, so a long-lived LocalVariableLookup (like
the one used by LineListGen) would set up the dup map wrong and
be inconsistent with other parts of the program.

We now regenerate the table on every Reset().

The de-duplication stuff also had problems when opcodes and
operands were double-clicked on.  When the opcode is clicked, the
selection should jump to the appropriate variable declaration, but
it wasn't being found because the label generated in the list was
in its original form.  Fixed.

When an instruction operand is double-clicked, the instruction operand
editor opens with an "edit variable" shortcut.  This was showing
the de-duplicated name, which isn't necessarily a bad thing, but it
was passing that value on to the DefSymbol editor, which thought it
was being asked to create a new entry.  Fixed.  (Entering the editor
through the LvTable editor works correctly, with nary a de-duplicated
name in sight.  You'll be forced to rename it because it'll fail the
uniqueness test.)

References to de-duplicated local variables were getting lost when
the symbol's label was replaced (due largely to a convenient but
flawed shortcut: xrefs are attached to DefSymbol objects).  Fixed by
linking the XrefSets.

Given the many issues and their relative subtlety, I decided to make
the modified names more obvious, and went back to the "_DUPn" naming
strategy.  (I'm also considering just making it an error and
discarding conflicting entries during analysis... this is much more
complicated than I expected it to be.)

Quick tests can be performed in 2019-local-variables:
 - go to +000026, double-click on the opcode, confirm sel change
 - go to +000026, double-click on the operand, confirm orig name
   shown in shortcut and that shortcut opens editor with orig name
 - go to +00001a, down a line, click on PROJ_ZERO_DUP1 and confirm
   that it has a single reference (from +000026)
 - double-click on var table and confirm editing entry
This commit is contained in:
Andy McFadden
2020-01-13 17:54:47 -08:00
parent 422af1193c
commit b387298685
14 changed files with 149 additions and 70 deletions

View File

@@ -1397,13 +1397,13 @@ namespace SourceGen {
return FormattedParts.CreateLongComment("BAD INDEX +" + offset.ToString("x6") +
" sub=" + subLineIndex);
} else {
// We use the entry directly from the LvTable, without LvLookup processing.
// This is good, because the entries in the display list match what the editor
// shows, but not quite right, because labels that are duplicates of
// non-variables (which ideally wouldn't happen) won't show their de-duplicated
// form. I think this is fine.
DefSymbol defSym = lvt[subLineIndex];
// Use an operand length of 1 so things are shown as concisely as possible.
// Getting the symbol directly from the LvTable yields the original form,
// but we want the de-dup form.
//DefSymbol defSym = lvt[subLineIndex];
List<DefSymbol> lvars = mLvLookup.GetVariablesDefinedAtOffset(offset);
DefSymbol defSym = lvars[subLineIndex];
// Use an operand length of 1 so the value is shown as concisely as possible.
string addrStr = PseudoOp.FormatNumericOperand(mFormatter, mProject.SymbolTable,
null, defSym.DataDescriptor, defSym.Value, 1,
PseudoOp.FormatNumericOpFlags.None);
@@ -1433,7 +1433,10 @@ namespace SourceGen {
return null;
}
return lvt[tableIndex];
// Go through LvLookup to get de-dup form of labels.
//return lvt[tableIndex];
List<DefSymbol> lvars = mLvLookup.GetVariablesDefinedAtOffset(offset);
return lvars[tableIndex];
}
private FormattedParts[] GenerateStringLines(int offset, string popcode,