1
0
mirror of https://github.com/fadden/6502bench.git synced 2024-06-11 17:29:29 +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
// is non-addressable. Duplicates of user labels will be rejected. Note the
// references will appear on the line for the next file offset, not the pre-label
// itself, because we need to associated it with a file offset.
foreach (AddressMap.AddressMapEntry ent in AddrMap) {
if (!string.IsNullOrEmpty(ent.PreLabel)) {
// Add all valid address region pre-labels. Duplicates of user labels will be
// rejected. Note the references will appear on the line for the next file offset,
// not the pre-label itself, because we need to associate it with a file offset.
IEnumerator<AddressMap.AddressChange> addrIter = AddrMap.AddressChangeIterator;
while (addrIter.MoveNext()) {
AddressMap.AddressChange change = addrIter.Current;
if (!change.IsStart) {
continue;
}
if (change.Region.HasValidPreLabel) {
try {
labelList.Add(ent.PreLabel, ent.Offset);
labelList.Add(change.Region.PreLabel, change.Region.Offset);
} catch (ArgumentException ex) {
Debug.WriteLine("Xref ignoring pre-label duplicate '" + ent.PreLabel +
"': " + ex.Message);
Debug.WriteLine("Xref ignoring pre-label duplicate '" +
change.Region.PreLabel + "': " + ex.Message);
}
}
}
@ -1635,13 +1640,20 @@ namespace SourceGen {
// Is this a reference to a label?
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) {
Messages.Add(new MessageList.MessageEntry(
MessageList.MessageEntry.SeverityLevel.Warning,
offset,
MessageList.MessageEntry.MessageType.NonAddrLabelRef,
dfd.SymbolRef.Label,
MessageList.MessageEntry.ProblemResolution.None));
if (mAnattribs[symOffset].Symbol != null &&
mAnattribs[symOffset].Symbol.Label == dfd.SymbolRef.Label) {
Messages.Add(new MessageList.MessageEntry(
MessageList.MessageEntry.SeverityLevel.Warning,
offset,
MessageList.MessageEntry.MessageType.NonAddrLabelRef,
dfd.SymbolRef.Label,
MessageList.MessageEntry.ProblemResolution.None));
}
}
// Compute adjustment.

View File

@ -1603,9 +1603,9 @@ namespace SourceGen {
break;
case CodeListColumn.Opcode:
if (IsPlbInstruction(line) && CanEditDataBank()) {
// Special handling for PLB instruction, so you can update the bank
// value just be double-clicking on it. Only used for PLBs without
// user- or auto-assigned bank changes.
// Special handling for PLB instruction, so you can update the bank
// value just by double-clicking on it. Only used for PLBs without
// user- or auto-assigned bank changes.
EditDataBank();
} else {
JumpToOperandTarget(line, false);
@ -3178,6 +3178,10 @@ namespace SourceGen {
mLineType = LineListGen.Line.Type.Unclassified;
mEntityCounts = new EntityCounts();
}
public override string ToString() {
return "SelState: numSel=" + mNumItemsSelected + " type=" + mLineType;
}
}
/// <summary>
@ -3946,10 +3950,45 @@ namespace SourceGen {
const string CRLF = "\r\n";
mMainWin.ClearInfoPanel();
if (mMainWin.CodeListView_GetSelectionCount() != 1) {
// Nothing selected, or multiple lines selected.
int selCount = mMainWin.CodeListView_GetSelectionCount();
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;
}
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();
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_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_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_InitialParameters">Default settings:</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");
public static string INFO_LINE_SUM_SINGULAR_FMT =
(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 =
(string)Application.Current.FindResource("str_InitialExtensionScripts");
public static string INITIAL_PARAMETERS =

View File

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