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); } }
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()); }
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()); }
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 "); }
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"); }
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)); } }
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); } }
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 "); }
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"); }