1
0
mirror of https://github.com/fadden/6502bench.git synced 2025-10-03 13:16:24 +00:00

ORG rework, part 5

Updated project file format to save the new map entries.

Tweaked appearance of .arend directives to show the .arstart address
in the operand field.  This makes it easier to match them up on screen.
Also, add a synthetic comment on auto-generated .arstart entries.

Added .arstart/.arend to the things that respond to Jump to Operand
(Ctrl+J).  Selecting one jumps to the other end.  (Well, it jumps
to the code nearest the other, which will do for now.)

Added a menu item to display a text rendering of the address map.
Helpful when things get complicated.

Modified the linear map iterator to return .arend items with the offset
of the last byte in the region, rather than the first byte of the
following region.  While the "exclusive end" approach is pretty
common, it caused problems when updating the line list, because it
meant that the .arend directives were outside the range of offsets
being updated (and, for directives at the end of the file, outside
the file itself).  This was painful to deal with for partial updates.
Changing this required some relatively subtle changes and annoyed some
of the debug assertions, such as the one where all Line items have
offsets that match the start of a line, but it's the cleaner approach.
This commit is contained in:
Andy McFadden
2021-09-27 17:02:18 -07:00
parent 3a2c4fa6d2
commit 2fed19ac47
12 changed files with 373 additions and 84 deletions

View File

@@ -20,7 +20,6 @@ using System.Diagnostics;
using System.IO;
using System.Text;
using System.Web.Script.Serialization;
using System.Windows.Media;
using CommonUtil;
@@ -53,7 +52,7 @@ namespace SourceGen {
// ignore stuff that's in one side but not the other. However, if we're opening a
// newer file in an older program, it's worth letting the user know that some stuff
// may get lost as soon as they save the file.
public const int CONTENT_VERSION = 4;
public const int CONTENT_VERSION = 5;
private static readonly bool ADD_CRLF = true;
@@ -238,15 +237,24 @@ namespace SourceGen {
SmartPlbHandling = src.SmartPlbHandling;
}
}
public class SerAddressMap {
public class SerAddressMapEntry {
public int Offset { get; set; }
public int Addr { get; set; }
// Length is computed field, no need to serialize
public int Length { get; set; }
public string PreLabel { get; set; }
public bool IsRelative { get; set; }
public SerAddressMap() { }
public SerAddressMap(AddressMap.AddressMapEntry ent) {
public SerAddressMapEntry() {
// Before v1.8, Length was always floating.
Length = CommonUtil.AddressMap.FLOATING_LEN;
PreLabel = string.Empty;
}
public SerAddressMapEntry(AddressMap.AddressMapEntry ent) {
Offset = ent.Offset;
Addr = ent.Address;
Length = ent.Length;
PreLabel = ent.PreLabel;
IsRelative = ent.IsRelative;
}
}
public class SerTypeHintRange {
@@ -421,7 +429,7 @@ namespace SourceGen {
public int FileDataLength { get; set; }
public int FileDataCrc32 { get; set; }
public SerProjectProperties ProjectProps { get; set; }
public List<SerAddressMap> AddressMap { get; set; }
public List<SerAddressMapEntry> AddressMap { get; set; }
public List<SerTypeHintRange> TypeHints { get; set; }
public Dictionary<string, int> StatusFlagOverrides { get; set; }
public Dictionary<string, string> Comments { get; set; }
@@ -453,10 +461,12 @@ namespace SourceGen {
spf.FileDataLength = proj.FileDataLength;
spf.FileDataCrc32 = (int)proj.FileDataCrc32;
// Convert AddressMap to serializable form.
spf.AddressMap = new List<SerAddressMap>();
// Convert AddressMap to serializable form. (AddressMapEntry objects are now
// serializable, so this is a bit redundant, but isolating project I/O from
// internal data structures is still useful.)
spf.AddressMap = new List<SerAddressMapEntry>();
foreach (AddressMap.AddressMapEntry ent in proj.AddrMap) {
spf.AddressMap.Add(new SerAddressMap(ent));
spf.AddressMap.Add(new SerAddressMapEntry(ent));
}
// Reduce analyzer tags (formerly known as "type hints") to a collection of ranges.
@@ -669,16 +679,14 @@ namespace SourceGen {
// Deserialize address map.
proj.AddrMap.Clear();
foreach (SerAddressMap addr in spf.AddressMap) {
// TODO(org): serialize length, isRelative, and preLabel
int length = CommonUtil.AddressMap.FLOATING_LEN;
foreach (SerAddressMapEntry addr in spf.AddressMap) {
AddressMap.AddResult addResult = proj.AddrMap.AddEntry(addr.Offset,
length, addr.Addr);
addr.Length, addr.Addr, addr.PreLabel, addr.IsRelative);
if (addResult != CommonUtil.AddressMap.AddResult.Okay) {
string msg = "off=+" + addr.Offset.ToString("x6") + " addr=$" +
addr.Addr.ToString("x4") + " len=" +
(length == CommonUtil.AddressMap.FLOATING_LEN ? "(floating)" : length.ToString());
string msg = "off=+" + addr.Offset.ToString("x6") + " len=" +
(addr.Length == CommonUtil.AddressMap.FLOATING_LEN ?
"(floating)" : addr.Length.ToString() +
" addr=$" + addr.Addr.ToString("x4"));
string errMsg = string.Format(Res.Strings.ERR_BAD_ADDRESS_REGION_FMT, msg);
report.Add(FileLoadItem.Type.Warning, errMsg);
}