public void NotMatch()
        {
            TypeVariable     t1 = new TypeVariable(1);
            TypeVariable     t2 = new TypeVariable(2);
            EquivalenceClass c1 = new EquivalenceClass(t1);
            EquivalenceClass c2 = new EquivalenceClass(t2);

            c1.DataType = new StructureType {
                Fields = { { 4, PrimitiveType.Word16 } }
            };
            c2.DataType = new StructureType {
                Fields = { { 20, PrimitiveType.Word32 } }
            };
            t1.Class = c1;
            t2.Class = c2;

            UnionType u = new UnionType(null, null);

            u.Alternatives.Add(new Pointer(c1, 32));
            u.Alternatives.Add(new Pointer(PrimitiveType.Word16, 32));

            UnionPointersStructuresMatcher upsm = new UnionPointersStructuresMatcher();

            Assert.IsFalse(upsm.Match(u));
        }
Пример #2
0
        public void TwoPointers()
        {
            TypeVariable     t1 = new TypeVariable(1);
            TypeVariable     t2 = new TypeVariable(2);
            EquivalenceClass c1 = new EquivalenceClass(t1);
            EquivalenceClass c2 = new EquivalenceClass(t2);

            c1.DataType = new StructureType {
                Fields = { { 4, PrimitiveType.Word16 } }
            };
            c2.DataType = new StructureType {
                Fields = { { 20, PrimitiveType.Word32 } }
            };
            t1.Class = c1;
            t2.Class = c2;

            UnionType u = new UnionType(null, null);

            u.Alternatives.Add(new Pointer(c1, 4));
            u.Alternatives.Add(new Pointer(c2, 4));

            UnionPointersStructuresMatcher upsm = new UnionPointersStructuresMatcher();

            Assert.IsTrue(upsm.Match(u));
            Assert.AreEqual(2, upsm.EquivalenceClasses.Count);
            Assert.AreEqual(2, upsm.Structures.Count);
        }