Exemplo n.º 1
0
 public override DataType VisitStructure(StructureType str)
 {
     // Do not transform user-defined types
     if (str.UserDefined)
     {
         return(str);
     }
     if (visitedTypes.Contains(str))
     {
         return(str);
     }
     visitedTypes.Add(str);
     if (++this.stackDepth > 50)
     {
         --this.stackDepth;
         return(str);
     }
     if (insideComplexType)
     {
         changed = true;
         NestedComplexTypeExtractor nctr = new NestedComplexTypeExtractor(factory, store);
         nctr.stackDepth = this.stackDepth;
         str.Accept(nctr);
         var dt = CreateEquivalenceClass(str);
         --this.stackDepth;
         return(dt);
     }
     else
     {
         insideComplexType = true;
         var dt = base.VisitStructure(str);
         --this.stackDepth;
         return(dt);
     }
 }
Exemplo n.º 2
0
 public void DTS_issue_113()
 {
     // This recursive structure shoudn't blow up the stack.
     var str = new StructureType("foo", 0);
     str.Fields.Add(0, new Pointer(str, 4), "bar");
     var sStr = str.Accept(new DataTypeSerializer());
     Assert.AreEqual("struct(foo, (0, bar, ptr(struct(foo, ))))", sStr.ToString());
 }
Exemplo n.º 3
0
        public void DTS_issue_113()
        {
            // This recursive structure shoudn't blow up the stack.
            var str = new StructureType("foo", 0);

            str.Fields.Add(0, new Pointer(str, 32), "bar");
            var sStr = str.Accept(new DataTypeSerializer());

            Assert.AreEqual("struct(foo, (0, bar, ptr(struct(foo, ))))", sStr.ToString());
        }
Exemplo n.º 4
0
        public void TtranNonUserStruct()
        {
            var t1 = new StructureType("T1", 4, true);
            var t2 = new StructureType("T2", 0, false)
            {
                Fields = { { 0, t1 } }
            };
            var ttran = new TypeTransformer(factory, store, null);
            var dt    = t2.Accept(ttran);

            Assert.AreSame(t1, dt, "Should reduce fields at offset 0 ");
        }
Exemplo n.º 5
0
        public void TtranUserStruct()
        {
            var t1 = new StructureType("T1", 4, true);
            var t2 = new StructureType("T2", 0, true)
            {
                Fields = { { 0, t1 } }
            };
            var ttran = new TypeTransformer(factory, store, null);
            var dt    = t2.Accept(ttran);

            Assert.AreSame(t2, dt, "Should not affect user-defined types");
        }
Exemplo n.º 6
0
 public override DataType VisitStructure(StructureType str)
 {
     if (visitedTypes.Contains(str))
     {
         return(str);
     }
     visitedTypes.Add(str);
     if (insideComplexType)
     {
         changed = true;
         NestedComplexTypeExtractor nctr = new NestedComplexTypeExtractor(factory, store);
         str.Accept(nctr);
         return(CreateEquivalenceClass(str));
     }
     else
     {
         insideComplexType = true;
         return(base.VisitStructure(str));
     }
 }
Exemplo n.º 7
0
		public override DataType VisitStructure(StructureType str)
		{
            // Do not transform user-defined types
            if (str.UserDefined)
                return str;
            if (visitedTypes.Contains(str))
                return str;
            visitedTypes.Add(str);
			if (insideComplexType)
			{
				changed = true;
				NestedComplexTypeExtractor nctr = new NestedComplexTypeExtractor(factory, store);
				str.Accept(nctr);
				return CreateEquivalenceClass(str);
			}
			else
			{
				insideComplexType = true;
				return base.VisitStructure(str);
			}
		}
Exemplo n.º 8
0
 public void TtranNonUserStruct()
 {
     var t1 = new StructureType("T1", 4, true);
     var t2 = new StructureType("T2", 0, false)
     {
         Fields = { { 0, t1 } }
     };
     var ttran = new TypeTransformer(factory, store, null);
     var dt = t2.Accept(ttran);
     Assert.AreSame(t1, dt, "Should reduce fields at offset 0 ");
 }
Exemplo n.º 9
0
 public void TtranUserStruct()
 {
     var t1 = new StructureType("T1", 4, true);
     var t2 = new StructureType("T2", 0, true)
     {
         Fields = { { 0, t1 } }
     };
     var ttran = new TypeTransformer(factory, store, null);
     var dt = t2.Accept(ttran);
     Assert.AreSame(t2, dt, "Should not affect user-defined types");
 }