public void DontSimplifySegmentStruct() { StructureType s = new StructureType(null, 0) { Fields = { { 0, PrimitiveType.Int32 } } }; s.IsSegment = true; DataType dt = s.Simplify(); Assert.AreEqual("(segment (0 int32 dw0000))", dt.ToString()); }
public DataType VisitStructure(StructureType str) { if (visitedTypes.Contains(str)) { return(str); } visitedTypes.Add(str); foreach (var field in str.Fields) { field.DataType = field.DataType.Accept(this); } StructureType strNew = MergeStructureFields(str); if (strNew.Fields.Count != str.Fields.Count) { Changed = true; } MergeStaggeredArrays(strNew); DataType dt = strNew.Simplify(); if (dt != strNew) { Changed = true; } return(dt); }
public DataType VisitStructure(StructureType str) { // Do not transform user-defined types if (str.UserDefined) { return(str); } if (visitedTypes.Contains(str)) { return(str); } visitedTypes.Add(str); foreach (var field in str.Fields) { field.DataType = field.DataType.Accept(this); } StructureType strNew = MergeStructureFields(str); if (strNew.Fields.Count != str.Fields.Count) { Changed = true; } MergeStaggeredArrays(strNew); if (ShouldSimplify(strNew)) { DataType dt = strNew.Simplify(); if (dt != strNew) { Changed = true; } return(dt); } return(strNew); }
public void SimplifyNonSimpleStruct() { StructureType s = new StructureType(null, 0) { Fields = { { 4, PrimitiveType.Int32 } } }; DataType dt = s.Simplify(); Assert.AreEqual("(struct (4 int32 dw0004))", dt.ToString()); }
public void SimplifySimpleStruct() { StructureType s = new StructureType(null, 0) { Fields = { { 0, PrimitiveType.Int32 } } }; DataType dt = s.Simplify(); Assert.AreEqual("int32", dt.ToString()); }
public void DontSimplifySegmentStruct() { StructureType s = new StructureType(null, 0) { Fields = { { 0, PrimitiveType.Int32 } } }; s.IsSegment = true; DataType dt = s.Simplify(); Assert.AreEqual("(segment (0 int32 dw0000))", dt.ToString()); }
public void SimplifyNonSimpleStruct() { StructureType s = new StructureType(null, 0) { Fields = { { 4, PrimitiveType.Int32 } } }; DataType dt = s.Simplify(); Assert.AreEqual("(struct (4 int32 dw0004))", dt.ToString()); }
public void SimplifySimpleStruct() { StructureType s = new StructureType(null, 0) { Fields = { { 0, PrimitiveType.Int32 } } }; DataType dt = s.Simplify(); Assert.AreEqual("int32", dt.ToString()); }