1
0
mirror of https://github.com/fadden/6502bench.git synced 2026-04-21 10:16:42 +00:00

Replace character operand output method

The previous code output a character in single-quotes if it was
standard ASCII, double-quotes if high ASCII, or hex if it was neither
of those.  If a flag was set, high ASCII would also be output as
hex.

The new system takes the character value and an encoding identifier.
The identifier selects the character converter and delimiter
pattern, and puts the two together to generate the operand.

While doing this I realized that I could trivially support high
ASCII character arguments in all assemblers by setting the delimiter
pattern to "'#' | $80".

In FormatDescriptor, I had previously renamed the "Ascii" sub-type
"LowAscii" so it wouldn't be confused, but I dislike filling the
project file with "LowAscii" when "Ascii" is more accurate and less
confusing.  So I switched it back, and we now check the project
file version number when deciding what to do with an ASCII item.
The CharEncoding tests/converters were also renamed.

Moved the default delimiter patterns to the string table.

Widened the delimiter pattern input fields slightly.  Added a read-
only TextBox with assorted non-typewriter quotes and things so
people have something to copy text from.
This commit is contained in:
Andy McFadden
2019-08-11 17:59:20 -07:00
parent 068b3a44c7
commit f33cd7d8a6
22 changed files with 227 additions and 167 deletions
+8 -4
View File
@@ -495,7 +495,7 @@ namespace SourceGen {
if (!CreateSymbol(kvp.Value, report, out Symbol sym)) {
continue;
}
if (!CreateFormatDescriptor(kvp.Value.DataDescriptor, report,
if (!CreateFormatDescriptor(kvp.Value.DataDescriptor, spf._ContentVersion, report,
out FormatDescriptor dfd)) {
continue;
}
@@ -618,7 +618,8 @@ namespace SourceGen {
continue;
}
if (!CreateFormatDescriptor(kvp.Value, report, out FormatDescriptor dfd)) {
if (!CreateFormatDescriptor(kvp.Value, spf._ContentVersion, report,
out FormatDescriptor dfd)) {
continue;
}
if (intKey < 0 || intKey + dfd.Length > spf.FileDataLength) {
@@ -664,10 +665,11 @@ namespace SourceGen {
/// Creates a FormatDescriptor from a SerFormatDescriptor.
/// </summary>
/// <param name="sfd">Deserialized data.</param>
/// <param name="version">Serialization version (CONTENT_VERSION).</param>
/// <param name="report">Error report object.</param>
/// <param name="dfd">Created FormatDescriptor.</param>
/// <returns>True on success.</returns>
private static bool CreateFormatDescriptor(SerFormatDescriptor sfd,
private static bool CreateFormatDescriptor(SerFormatDescriptor sfd, int version,
FileLoadReport report, out FormatDescriptor dfd) {
dfd = null;
FormatDescriptor.Type format;
@@ -676,6 +678,7 @@ namespace SourceGen {
if ("String".Equals(sfd.Format)) {
// File version 1 used a different set of enumerated values for defining strings.
// Parse it out here.
Debug.Assert(version <= 1);
subFormat = FormatDescriptor.SubType.ASCII_GENERIC;
if ("None".Equals(sfd.SubFormat)) {
format = FormatDescriptor.Type.StringGeneric;
@@ -707,10 +710,11 @@ namespace SourceGen {
try {
format = (FormatDescriptor.Type)Enum.Parse(
typeof(FormatDescriptor.Type), sfd.Format);
if ("Ascii".Equals(sfd.SubFormat)) {
if (version <= 1 && "Ascii".Equals(sfd.SubFormat)) {
// File version 1 used "Ascii" for all character data in numeric operands.
// It applied to both low and high ASCII.
subFormat = FormatDescriptor.SubType.ASCII_GENERIC;
Debug.WriteLine("Found v1 char, fmt=" + sfd.Format + ", sub=" + sfd.SubFormat);
} else {
subFormat = (FormatDescriptor.SubType)Enum.Parse(
typeof(FormatDescriptor.SubType), sfd.SubFormat);