Ejemplo n.º 1
0
 public SerDefSymbol(DefSymbol defSym) : base(defSym)
 {
     DataDescriptor = new SerFormatDescriptor(defSym.DataDescriptor);
     Comment        = defSym.Comment;
     HasWidth       = defSym.HasWidth;
     Direction      = defSym.Direction.ToString();
     if (defSym.MultiMask != null)
     {
         MultiMask = new SerMultiMask(defSym.MultiMask);
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Creates a FormatDescriptor from a SerFormatDescriptor.
 /// </summary>
 /// <param name="sfd">Deserialized data.</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,
                                            FileLoadReport report, out FormatDescriptor dfd)
 {
     dfd = null;
     FormatDescriptor.Type    format;
     FormatDescriptor.SubType subFormat;
     try {
         format = (FormatDescriptor.Type)Enum.Parse(
             typeof(FormatDescriptor.Type), sfd.Format);
         subFormat = (FormatDescriptor.SubType)Enum.Parse(
             typeof(FormatDescriptor.SubType), sfd.SubFormat);
     } catch (ArgumentException) {
         report.Add(FileLoadItem.Type.Warning, Properties.Resources.ERR_BAD_FD_FORMAT +
                    ": " + sfd.Format + "/" + sfd.SubFormat);
         return(false);
     }
     if (sfd.SymbolRef == null)
     {
         dfd = FormatDescriptor.Create(sfd.Length, format, subFormat);
     }
     else
     {
         WeakSymbolRef.Part part;
         try {
             part = (WeakSymbolRef.Part)Enum.Parse(
                 typeof(WeakSymbolRef.Part), sfd.SymbolRef.Part);
         } catch (ArgumentException) {
             report.Add(FileLoadItem.Type.Warning,
                        Properties.Resources.ERR_BAD_SYMREF_PART +
                        ": " + sfd.SymbolRef.Part);
             return(false);
         }
         dfd = FormatDescriptor.Create(sfd.Length,
                                       new WeakSymbolRef(sfd.SymbolRef.Label, part),
                                       format == FormatDescriptor.Type.NumericBE);
     }
     return(true);
 }
Ejemplo n.º 3
0
 public SerDefSymbol(DefSymbol defSym) : base(defSym)
 {
     DataDescriptor = new SerFormatDescriptor(defSym.DataDescriptor);
     Comment        = defSym.Comment;
 }
Ejemplo n.º 4
0
        /// <summary>
        /// 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, int version,
                                                   FileLoadReport report, out FormatDescriptor dfd)
        {
            dfd = null;
            FormatDescriptor.Type    format;
            FormatDescriptor.SubType subFormat;

            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;
                }
                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 if ("DciReverse".Equals(sfd.SubFormat))
                {
                    // No longer supported.  Nobody ever used this but the regression tests,
                    // though, so there's no reason to handle this nicely.
                    format    = FormatDescriptor.Type.Dense;
                    subFormat = FormatDescriptor.SubType.None;
                }
                else
                {
                    // No idea what this is; 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(dfd != null);
            }

            try {
                format = (FormatDescriptor.Type)Enum.Parse(
                    typeof(FormatDescriptor.Type), sfd.Format);
                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);
                }
            } catch (ArgumentException) {
                report.Add(FileLoadItem.Type.Warning, Res.Strings.ERR_BAD_FD_FORMAT +
                           ": " + sfd.Format + "/" + sfd.SubFormat);
                return(false);
            }
            if (sfd.SymbolRef == null)
            {
                dfd = FormatDescriptor.Create(sfd.Length, format, subFormat);
            }
            else
            {
                WeakSymbolRef.Part part;
                try {
                    part = (WeakSymbolRef.Part)Enum.Parse(
                        typeof(WeakSymbolRef.Part), sfd.SymbolRef.Part);
                } catch (ArgumentException) {
                    report.Add(FileLoadItem.Type.Warning,
                               Res.Strings.ERR_BAD_SYMREF_PART +
                               ": " + sfd.SymbolRef.Part);
                    return(false);
                }
                dfd = FormatDescriptor.Create(sfd.Length,
                                              new WeakSymbolRef(sfd.SymbolRef.Label, part),
                                              format == FormatDescriptor.Type.NumericBE);
            }
            return(dfd != null);
        }