示例#1
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="label">Symbol's label.</param>
        /// <param name="value">Symbol's value.</param>
        /// <param name="source">Symbol source (general point of origin).</param>
        /// <param name="type">Symbol type.</param>
        /// <param name="formatSubType">Format descriptor sub-type, so we know how the
        ///   user wants the value to be displayed.</param>
        /// <param name="comment">End-of-line comment.</param>
        /// <param name="tag">Symbol tag, used for grouping platform symbols.</param>
        public DefSymbol(string label, int value, Source source, Type type,
                         FormatDescriptor.SubType formatSubType, string comment, string tag)
            : this(label, value, source, type)
        {
            Debug.Assert(comment != null);
            Debug.Assert(tag != null);

            // Length doesn't matter; use 1 to get prefab object.
            DataDescriptor = FormatDescriptor.Create(1,
                                                     FormatDescriptor.Type.NumericLE, formatSubType);

            Comment = comment;
            Tag     = tag;
        }
示例#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, 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(true);
 }