mirror of
https://github.com/fadden/6502bench.git
synced 2024-05-31 22:41:37 +00:00
Highlight local variable uses
When a single line is selected in a local variable table, highlight the operands of every instruction that references that variable.
This commit is contained in:
parent
b942c24ef2
commit
865a5e58f7
|
@ -1633,8 +1633,7 @@ namespace SourceGen {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public DefSymbol GetLocalVariableFromLine(int lineIndex) {
|
public DefSymbol GetLocalVariableFromLine(Line line) {
|
||||||
Line line = this[lineIndex];
|
|
||||||
int offset = line.FileOffset;
|
int offset = line.FileOffset;
|
||||||
if (!mProject.LvTables.TryGetValue(offset, out LocalVariableTable lvt)) {
|
if (!mProject.LvTables.TryGetValue(offset, out LocalVariableTable lvt)) {
|
||||||
Debug.Assert(false);
|
Debug.Assert(false);
|
||||||
|
@ -1661,7 +1660,6 @@ namespace SourceGen {
|
||||||
// You can't have an end followed by a start, because that would mean the regions
|
// You can't have an end followed by a start, because that would mean the regions
|
||||||
// overlap. If there's both start and end present, we have a 1-byte region.
|
// overlap. If there's both start and end present, we have a 1-byte region.
|
||||||
int offset = line.FileOffset;
|
int offset = line.FileOffset;
|
||||||
List<AddressMap.AddressMapEntry> entries = mProject.AddrMap.GetEntries(offset);
|
|
||||||
|
|
||||||
IEnumerator<AddressMap.AddressChange> addrIter = mProject.AddrMap.AddressChangeIterator;
|
IEnumerator<AddressMap.AddressChange> addrIter = mProject.AddrMap.AddressChangeIterator;
|
||||||
while (addrIter.MoveNext()) {
|
while (addrIter.MoveNext()) {
|
||||||
|
|
|
@ -3437,8 +3437,21 @@ namespace SourceGen {
|
||||||
}
|
}
|
||||||
mUpdatingSelectionHighlight = true;
|
mUpdatingSelectionHighlight = true;
|
||||||
|
|
||||||
int targetIndex = FindSelectionAddrHighlight(out bool isSingleCodeData,
|
//
|
||||||
out int selIndex);
|
// Start with the target address highlight, for branches and in-file memory accesses.
|
||||||
|
//
|
||||||
|
|
||||||
|
int targetIndex = -1;
|
||||||
|
LineListGen.Line selectedLine = null;
|
||||||
|
if (mMainWin.CodeListView_GetSelectionCount() == 1) {
|
||||||
|
int selIndex = mMainWin.CodeListView_GetFirstSelectedIndex();
|
||||||
|
selectedLine = CodeLineList[selIndex];
|
||||||
|
if (selectedLine.IsCodeOrData) {
|
||||||
|
Debug.Assert(selectedLine.FileOffset >= 0);
|
||||||
|
targetIndex = FindSelectionAddrHighlight(selectedLine);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (mTargetHighlightIndex != targetIndex) {
|
if (mTargetHighlightIndex != targetIndex) {
|
||||||
Debug.WriteLine("Target highlight moving from " + mTargetHighlightIndex +
|
Debug.WriteLine("Target highlight moving from " + mTargetHighlightIndex +
|
||||||
" to " + targetIndex);
|
" to " + targetIndex);
|
||||||
|
@ -3459,15 +3472,25 @@ namespace SourceGen {
|
||||||
mTargetHighlightIndex = targetIndex;
|
mTargetHighlightIndex = targetIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Now do the source operand highlight, to see what refers to the current address.
|
||||||
|
//
|
||||||
|
|
||||||
|
// Un-highlight anything we had highlighted previously.
|
||||||
if (mOperandHighlights.Count > 0) {
|
if (mOperandHighlights.Count > 0) {
|
||||||
foreach (int index in mOperandHighlights) {
|
foreach (int index in mOperandHighlights) {
|
||||||
mMainWin.CodeListView_RemoveSelectionOperHighlight(index);
|
mMainWin.CodeListView_RemoveSelectionOperHighlight(index);
|
||||||
}
|
}
|
||||||
mOperandHighlights.Clear();
|
mOperandHighlights.Clear();
|
||||||
}
|
}
|
||||||
if (isSingleCodeData) {
|
if (selectedLine != null) {
|
||||||
LineListGen.Line line = CodeLineList[selIndex];
|
XrefSet xrefs = null;
|
||||||
XrefSet xrefs = mProject.GetXrefSet(line.FileOffset);
|
if (selectedLine.IsCodeOrData) {
|
||||||
|
xrefs = mProject.GetXrefSet(selectedLine.FileOffset);
|
||||||
|
} else if (selectedLine.LineType == LineListGen.Line.Type.LocalVariableTable) {
|
||||||
|
DefSymbol defSym = CodeLineList.GetLocalVariableFromLine(selectedLine);
|
||||||
|
xrefs = (defSym == null) ? null : defSym.Xrefs;
|
||||||
|
}
|
||||||
if (xrefs != null) {
|
if (xrefs != null) {
|
||||||
foreach (XrefSet.Xref xr in xrefs) {
|
foreach (XrefSet.Xref xr in xrefs) {
|
||||||
int refIndex = CodeLineList.FindCodeDataIndexByOffset(xr.Offset);
|
int refIndex = CodeLineList.FindCodeDataIndexByOffset(xr.Offset);
|
||||||
|
@ -3480,21 +3503,7 @@ namespace SourceGen {
|
||||||
mUpdatingSelectionHighlight = false;
|
mUpdatingSelectionHighlight = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int FindSelectionAddrHighlight(out bool isSingleCodeData, out int selIndex) {
|
private int FindSelectionAddrHighlight(LineListGen.Line line) {
|
||||||
if (mMainWin.CodeListView_GetSelectionCount() != 1) {
|
|
||||||
isSingleCodeData = false;
|
|
||||||
selIndex = -1;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
selIndex = mMainWin.CodeListView_GetFirstSelectedIndex();
|
|
||||||
LineListGen.Line line = CodeLineList[selIndex];
|
|
||||||
if (!line.IsCodeOrData) {
|
|
||||||
isSingleCodeData = false;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
Debug.Assert(line.FileOffset >= 0);
|
|
||||||
isSingleCodeData = true;
|
|
||||||
|
|
||||||
// Does this have an operand with an in-file target offset?
|
// Does this have an operand with an in-file target offset?
|
||||||
// TODO: may not work correctly with reloc data?
|
// TODO: may not work correctly with reloc data?
|
||||||
Anattrib attr = mProject.GetAnattrib(line.FileOffset);
|
Anattrib attr = mProject.GetAnattrib(line.FileOffset);
|
||||||
|
@ -3898,7 +3907,7 @@ namespace SourceGen {
|
||||||
|
|
||||||
// Find the appropriate xref set.
|
// Find the appropriate xref set.
|
||||||
if (type == LineListGen.Line.Type.LocalVariableTable) {
|
if (type == LineListGen.Line.Type.LocalVariableTable) {
|
||||||
DefSymbol defSym = CodeLineList.GetLocalVariableFromLine(lineIndex);
|
DefSymbol defSym = CodeLineList.GetLocalVariableFromLine(CodeLineList[lineIndex]);
|
||||||
xrefs = (defSym == null) ? null : defSym.Xrefs;
|
xrefs = (defSym == null) ? null : defSym.Xrefs;
|
||||||
} else {
|
} else {
|
||||||
int offset = CodeLineList[lineIndex].FileOffset;
|
int offset = CodeLineList[lineIndex].FileOffset;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user