mirror of
https://github.com/fadden/6502bench.git
synced 2026-04-21 10:16:42 +00:00
Change the way string formats are defined
We used to use type="String", with the sub-type indicating whether the string was null-terminated, prefixed with a length, or whatever. This didn't leave much room for specifying a character encoding, which is orthogonal to the sub-type. What we actually want is to have the type specify the string type, and then have the sub-type determine the character encoding. These sub-types can also be used with the Numeric type to specify the encoding of character operands. This change updates the enum definitions and the various bits of code that use them, but does not add any code for working with non-ASCII character encodings. The project file version number was incremented to 2, since the new FormatDescriptor serialization is mildly incompatible with the old. (Won't explode, but it'll post a complaint and ignore the stuff it doesn't recognize.) While I was at it, I finished removing DciReverse. It's still part of the 2005-string-types regression test, which currently fails because the generated source doesn't match.
This commit is contained in:
@@ -52,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 = 1;
|
||||
public const int CONTENT_VERSION = 2;
|
||||
|
||||
private static readonly bool ADD_CRLF = true;
|
||||
|
||||
@@ -669,6 +669,33 @@ namespace SourceGen {
|
||||
dfd = null;
|
||||
FormatDescriptor.Type format;
|
||||
FormatDescriptor.SubType subFormat;
|
||||
|
||||
// File version 1 used a different set of enumerated values for defining strings.
|
||||
// Parse it out here.
|
||||
if ("String".Equals(sfd.Format)) {
|
||||
subFormat = FormatDescriptor.SubType.Ascii;
|
||||
if ("None".Equals(sfd.SubFormat)) {
|
||||
format = FormatDescriptor.Type.StringGeneric;
|
||||
} else if ("Reverse".Equals(sfd.SubFormat)) {
|
||||
format = FormatDescriptor.Type.StringReverse;
|
||||
} else if ("CString".Equals(sfd.SubFormat)) {
|
||||
format = FormatDescriptor.Type.StringNullTerm;
|
||||
} else if ("L8String".Equals(sfd.SubFormat)) {
|
||||
format = FormatDescriptor.Type.StringL8;
|
||||
} else if ("L16String".Equals(sfd.SubFormat)) {
|
||||
format = FormatDescriptor.Type.StringL16;
|
||||
} else if ("Dci".Equals(sfd.SubFormat)) {
|
||||
format = FormatDescriptor.Type.StringDci;
|
||||
} else {
|
||||
// DciReverse no longer supported; output as dense hex
|
||||
format = FormatDescriptor.Type.Dense;
|
||||
subFormat = FormatDescriptor.SubType.None;
|
||||
}
|
||||
Debug.WriteLine("Found v1 string, fmt=" + format + ", sub=" + subFormat);
|
||||
dfd = FormatDescriptor.Create(sfd.Length, format, subFormat);
|
||||
return true;
|
||||
}
|
||||
|
||||
try {
|
||||
format = (FormatDescriptor.Type)Enum.Parse(
|
||||
typeof(FormatDescriptor.Type), sfd.Format);
|
||||
|
||||
Reference in New Issue
Block a user