public ImageMapItem SetTypeAtAddressRange(Address address, string userText)
        {
            var dataType = HungarianParser.Parse(userText);

            if (dataType == null)
            {
                return(null);
            }
            if (dataType is ArrayType arr && arr.ElementType.Size != 0)
            {
                var range = control.MemoryView.GetAddressRange();
                if (range.IsValid)
                {
                    long size   = (range.End - range.Begin) + 1;
                    int  nElems = (int)(size / arr.ElementType.Size);
                    arr.Length = nElems;
                }
            }
            var arch = program.Architecture;
            var item = program.AddUserGlobalItem(arch, address, dataType);

            control.MemoryView.Invalidate();
            return(item);
        }
Esempio n. 2
0
        public void ParseChar()
        {
            var dt = HungarianParser.Parse("ch");        // 8-bit character

            Assert.AreEqual("char", dt.ToString());
        }
Esempio n. 3
0
        public void IncompleteArray_Fail()
        {
            var dt = HungarianParser.Parse("a");        // incomplete array, not a valid type

            Assert.AreEqual("(arr <unknown>)", dt.ToString());
        }
Esempio n. 4
0
        public void ParseArrayPrefix()
        {
            var dt = HungarianParser.Parse("ab");        // 'array of bytes' of unspecified length.

            Assert.AreEqual("(arr byte)", dt.ToString());
        }
Esempio n. 5
0
        public void ParseBool()
        {
            var dt = HungarianParser.Parse("f");     // 'f' for 'flag'.

            Assert.AreEqual("bool", dt.ToString());
        }
Esempio n. 6
0
        public void Parse_Pointer_To_Anything()
        {
            var dt = HungarianParser.Parse("p");

            Assert.AreEqual("ptr32", dt.ToString());
        }
Esempio n. 7
0
 public ImageMapItem SetTypeAtAddressRange(Address address, string userText)
 {
     var parser = new HungarianParser();
     var dataType = parser.Parse(userText);
     if (dataType == null)
         return null;
     var arr = dataType as ArrayType;
     if (arr != null && arr.ElementType.Size != 0)
     {
         var range = control.MemoryView.GetAddressRange();
         if (range.IsValid)
         {
             long size = (range.End - range.Begin) + 1;
             int nElems = (int)(size / arr.ElementType.Size);
             arr.Length = nElems;
         }
     }
     var item = program.AddUserGlobalItem(address, dataType);
     control.MemoryView.Invalidate();
     return item;
 }
Esempio n. 8
0
 public void Setup()
 {
     parser = new HungarianParser();
 }
Esempio n. 9
0
        public void Parse_signed_word()
        {
            var dt = HungarianParser.Parse("iw");

            Assert.AreEqual("int32", dt.ToString());
        }
Esempio n. 10
0
        public void Parse_ushort()
        {
            var dt = HungarianParser.Parse("us");

            Assert.AreEqual("uint16", dt.ToString());
        }
Esempio n. 11
0
        public void ParseWord()
        {
            var dt = HungarianParser.Parse("w");

            Assert.AreEqual("word32", dt.ToString());
        }
Esempio n. 12
0
        public void Length_Prefixed_byte_string()
        {
            var dt = HungarianParser.Parse("si8");

            Assert.AreEqual("(struct (0 int8 length) (1 (arr char) chars))", dt.ToString());
        }
Esempio n. 13
0
        public void Wide_Zero_Terminated_string()
        {
            var dt = HungarianParser.Parse("wsz");

            Assert.AreEqual("(str wchar_t)", dt.ToString());
        }
Esempio n. 14
0
        public void Array_Pointers_To_Functions()
        {
            var dt = HungarianParser.Parse("apfn");

            Assert.AreEqual("(arr (ptr32 code))", dt.ToString());
        }
Esempio n. 15
0
        public void Parse_Pointer_To_Integer()
        {
            var dt = HungarianParser.Parse("pi16");

            Assert.AreEqual("(ptr32 int16)", dt.ToString());
        }
Esempio n. 16
0
        public void ParseWideChar()
        {
            var dt = HungarianParser.Parse("wch");       // 16-bit character

            Assert.AreEqual("wchar_t", dt.ToString());
        }
Esempio n. 17
0
        public void Parse8bit_c_string()
        {
            var dt = HungarianParser.Parse("sz");       // zero-terminated string

            Assert.AreEqual("(str char)", dt.ToString());
        }
Esempio n. 18
0
        public void Parse_single_precision_real()
        {
            var dt = HungarianParser.Parse("r32");

            Assert.AreEqual("real32", dt.ToString());
        }
Esempio n. 19
0
 public void typeMarker_FormatType(object sender, TypeMarkerEventArgs e)
 {
     try
     {
         var parser = new HungarianParser();
         var dataType = parser.Parse(e.UserText);
         if (dataType == null)
             e.FormattedType = " - Null - ";
         else
             e.FormattedType = dataType.ToString();
     }
     catch
     {
         e.FormattedType = " - Error - ";
     }
 }
Esempio n. 20
0
        public void ParseEmpty()
        {
            DataType dt = HungarianParser.Parse("");

            Assert.AreEqual("<unknown>", dt.ToString());
        }
Esempio n. 21
0
 public string FormatType(string text)
 {
     try
     {
         var parser = new HungarianParser();
         var dataType = parser.Parse(text);
         if (dataType == null)
             return " - Null - ";
         else
             return dataType.ToString();
     }
     catch
     {
         return " - Error - ";
     }
 }
Esempio n. 22
0
        public void ParseI32()
        {
            var dt = HungarianParser.Parse("i32");

            Assert.AreEqual("int32", dt.ToString());
        }