1
0
mirror of https://github.com/fadden/6502bench.git synced 2024-12-01 22:50:35 +00:00

Various tweaks

Changed the code that generates cross-references for pre-labels to
ignore labels in regions with non-addressable parents.  Also, changed
the code that complains about references to labels in non-addressable
areas to ignore pre-labels, because it was complaining about references
to pre-labels on region starts that were followed by a non-addressable
region start.

In the address region edit dialog, split up the descriptive text for
the "resize" option to make it easier to see the new end offset and
length.  It doesn't look quite right because it's not using the mono
font like the text near the top, but it'll do.

When multiple lines are selected, the Info window now shows the first
line/offset, last line/offset, and bytes spanned by the selection.
This is helpful if you're trying to figure out how big something is.
This commit is contained in:
Andy McFadden 2021-10-11 14:44:44 -07:00
parent 387b50d827
commit 6df29e562f
5 changed files with 85 additions and 24 deletions

View File

@ -1573,18 +1573,23 @@ namespace SourceGen {
} }
} }
} }
// Add all address region pre-labels, regardless of whether or not their parent // Add all valid address region pre-labels. Duplicates of user labels will be
// is non-addressable. Duplicates of user labels will be rejected. Note the // rejected. Note the references will appear on the line for the next file offset,
// references will appear on the line for the next file offset, not the pre-label // not the pre-label itself, because we need to associate it with a file offset.
// itself, because we need to associated it with a file offset. IEnumerator<AddressMap.AddressChange> addrIter = AddrMap.AddressChangeIterator;
foreach (AddressMap.AddressMapEntry ent in AddrMap) { while (addrIter.MoveNext()) {
if (!string.IsNullOrEmpty(ent.PreLabel)) { AddressMap.AddressChange change = addrIter.Current;
try { if (!change.IsStart) {
labelList.Add(ent.PreLabel, ent.Offset); continue;
} catch (ArgumentException ex) {
Debug.WriteLine("Xref ignoring pre-label duplicate '" + ent.PreLabel +
"': " + ex.Message);
} }
if (change.Region.HasValidPreLabel) {
try {
labelList.Add(change.Region.PreLabel, change.Region.Offset);
} catch (ArgumentException ex) {
Debug.WriteLine("Xref ignoring pre-label duplicate '" +
change.Region.PreLabel + "': " + ex.Message);
}
} }
} }
@ -1635,7 +1640,13 @@ namespace SourceGen {
// Is this a reference to a label? // Is this a reference to a label?
if (labelList.TryGetValue(dfd.SymbolRef.Label, out int symOffset)) { if (labelList.TryGetValue(dfd.SymbolRef.Label, out int symOffset)) {
// Post a warning if the reference is to a non-addressable offset,
// unless the label in question is a pre-label. We need to ignore
// those because it's valid to have a pre-label on an addressable
// region that shares a start point with a non-addressable child.
if (mAnattribs[symOffset].IsNonAddressable) { if (mAnattribs[symOffset].IsNonAddressable) {
if (mAnattribs[symOffset].Symbol != null &&
mAnattribs[symOffset].Symbol.Label == dfd.SymbolRef.Label) {
Messages.Add(new MessageList.MessageEntry( Messages.Add(new MessageList.MessageEntry(
MessageList.MessageEntry.SeverityLevel.Warning, MessageList.MessageEntry.SeverityLevel.Warning,
offset, offset,
@ -1643,6 +1654,7 @@ namespace SourceGen {
dfd.SymbolRef.Label, dfd.SymbolRef.Label,
MessageList.MessageEntry.ProblemResolution.None)); MessageList.MessageEntry.ProblemResolution.None));
} }
}
// Compute adjustment. // Compute adjustment.
int adj = 0; int adj = 0;

View File

@ -1604,7 +1604,7 @@ namespace SourceGen {
case CodeListColumn.Opcode: case CodeListColumn.Opcode:
if (IsPlbInstruction(line) && CanEditDataBank()) { if (IsPlbInstruction(line) && CanEditDataBank()) {
// Special handling for PLB instruction, so you can update the bank // Special handling for PLB instruction, so you can update the bank
// value just be double-clicking on it. Only used for PLBs without // value just by double-clicking on it. Only used for PLBs without
// user- or auto-assigned bank changes. // user- or auto-assigned bank changes.
EditDataBank(); EditDataBank();
} else { } else {
@ -3178,6 +3178,10 @@ namespace SourceGen {
mLineType = LineListGen.Line.Type.Unclassified; mLineType = LineListGen.Line.Type.Unclassified;
mEntityCounts = new EntityCounts(); mEntityCounts = new EntityCounts();
} }
public override string ToString() {
return "SelState: numSel=" + mNumItemsSelected + " type=" + mLineType;
}
} }
/// <summary> /// <summary>
@ -3946,10 +3950,45 @@ namespace SourceGen {
const string CRLF = "\r\n"; const string CRLF = "\r\n";
mMainWin.ClearInfoPanel(); mMainWin.ClearInfoPanel();
if (mMainWin.CodeListView_GetSelectionCount() != 1) { int selCount = mMainWin.CodeListView_GetSelectionCount();
// Nothing selected, or multiple lines selected. if (selCount < 1) {
// Nothing selected.
return;
} else if (selCount > 1) {
// Multiple lines selected.
mMainWin.InfoLineDescrText = string.Format(Res.Strings.INFO_MULTI_LINE_SUM_FMT,
selCount);
int firstIndex = mMainWin.CodeListView_GetFirstSelectedIndex();
int lastIndex = mMainWin.CodeListView_GetLastSelectedIndex();
int firstOffset = CodeLineList[firstIndex].FileOffset;
int nextOffset = CodeLineList[lastIndex].FileOffset +
CodeLineList[lastIndex].OffsetSpan;
if (firstOffset == nextOffset) {
return; // probably selected a bunch of lines from a long comment or note
}
if (firstOffset < 0 || nextOffset < 0) {
// We're in the header comment or .equ area.
return; return;
} }
if (CodeLineList[lastIndex].LineType == LineListGen.Line.Type.ArEndDirective) {
nextOffset++;
}
StringBuilder msb = new StringBuilder();
msb.AppendFormat(Res.Strings.INFO_MULTI_LINE_START_FMT, firstIndex,
mFormatter.FormatOffset24(firstOffset));
msb.Append(CRLF);
msb.AppendFormat(Res.Strings.INFO_MULTI_LINE_END_FMT, lastIndex,
mFormatter.FormatOffset24(nextOffset - 1));
msb.Append(CRLF);
int len = nextOffset - firstOffset;
string lenStr = len.ToString() + " (" + mFormatter.FormatHexValue(len, 2) + ")";
msb.AppendFormat(Res.Strings.INFO_MULTI_LINE_LEN_FMT, lenStr);
mMainWin.InfoPanelDetail1 = msb.ToString();
return;
}
int lineIndex = mMainWin.CodeListView_GetFirstSelectedIndex(); int lineIndex = mMainWin.CodeListView_GetFirstSelectedIndex();
LineListGen.Line line = CodeLineList[lineIndex]; LineListGen.Line line = CodeLineList[lineIndex];

View File

@ -113,6 +113,10 @@ limitations under the License.
<system:String x:Key="str_InfoLineSumNonFmt">Line {0}: {1}</system:String> <system:String x:Key="str_InfoLineSumNonFmt">Line {0}: {1}</system:String>
<system:String x:Key="str_InfoLineSumPluralFmt">Line {0}: {1} bytes of {2}</system:String> <system:String x:Key="str_InfoLineSumPluralFmt">Line {0}: {1} bytes of {2}</system:String>
<system:String x:Key="str_InfoLineSumSingularFmt">Line {0}: {1} byte of {2}</system:String> <system:String x:Key="str_InfoLineSumSingularFmt">Line {0}: {1} byte of {2}</system:String>
<system:String x:Key="str_InfoMultiLineSumFmt">{0} lines selected</system:String>
<system:String x:Key="str_InfoMultiLineStartFmt">First: line {0} offset {1}</system:String>
<system:String x:Key="str_InfoMultiLineEndFmt">Last: line {0} offset {1}</system:String>
<system:String x:Key="str_InfoMultiLineLenFmt">Selection spans {0} bytes</system:String>
<system:String x:Key="str_InitialExtensionScripts">Extension scripts:</system:String> <system:String x:Key="str_InitialExtensionScripts">Extension scripts:</system:String>
<system:String x:Key="str_InitialParameters">Default settings:</system:String> <system:String x:Key="str_InitialParameters">Default settings:</system:String>
<system:String x:Key="str_InitialSymbolFiles">Symbol files:</system:String> <system:String x:Key="str_InitialSymbolFiles">Symbol files:</system:String>

View File

@ -207,6 +207,14 @@ namespace SourceGen.Res {
(string)Application.Current.FindResource("str_InfoLineSumPluralFmt"); (string)Application.Current.FindResource("str_InfoLineSumPluralFmt");
public static string INFO_LINE_SUM_SINGULAR_FMT = public static string INFO_LINE_SUM_SINGULAR_FMT =
(string)Application.Current.FindResource("str_InfoLineSumSingularFmt"); (string)Application.Current.FindResource("str_InfoLineSumSingularFmt");
public static string INFO_MULTI_LINE_SUM_FMT =
(string)Application.Current.FindResource("str_InfoMultiLineSumFmt");
public static string INFO_MULTI_LINE_START_FMT =
(string)Application.Current.FindResource("str_InfoMultiLineStartFmt");
public static string INFO_MULTI_LINE_END_FMT =
(string)Application.Current.FindResource("str_InfoMultiLineEndFmt");
public static string INFO_MULTI_LINE_LEN_FMT =
(string)Application.Current.FindResource("str_InfoMultiLineLenFmt");
public static string INITIAL_EXTENSION_SCRIPTS = public static string INITIAL_EXTENSION_SCRIPTS =
(string)Application.Current.FindResource("str_InitialExtensionScripts"); (string)Application.Current.FindResource("str_InitialExtensionScripts");
public static string INITIAL_PARAMETERS = public static string INITIAL_PARAMETERS =

View File

@ -48,10 +48,8 @@ limitations under the License.
<system:String x:Key="str_OptResizeSummary"> <system:String x:Key="str_OptResizeSummary">
Resize. Resize.
</system:String> </system:String>
<system:String x:Key="str_OptResize"> <system:String x:Key="str_OptResize" xml:space="preserve"
Edit the region's attributes, and resize it to the selection. The new >Edit the region's attributes, and resize it to the selection. The new end offset will be:&#x0a;End: {0}&#x0a;Length: {1}</system:String>
end offset will be {0}, for a length of {1}.
</system:String>
<system:String x:Key="str_OptResizeFail"> <system:String x:Key="str_OptResizeFail">
Resize not available: cannot resize to the selection. {0} Resize not available: cannot resize to the selection. {0}
</system:String> </system:String>