public void CmpRecursiveNotEqualStructs() { // struct str1{struct *str2; int f1} != struct str2{struct *str1; float f2} DataType u32 = PrimitiveType.UInt32; DataType r32 = PrimitiveType.Real32; StructureType s1 = new StructureType(); StructureType s2 = new StructureType(); s1.Fields.Add(0, new Pointer(s2, 32)); s1.Fields.Add(4, u32); s2.Fields.Add(0, new Pointer(s1, 32)); s2.Fields.Add(4, r32); DataTypeComparer c = new DataTypeComparer(); Assert.AreNotEqual(0, c.Compare(s1, s2)); Assert.AreNotEqual(0, c.Compare(r32, u32)); }
public void CmpRecursiveNotEqualStructs() { // struct str1{struct *str2; int f1} != struct str2{struct *str1; float f2} DataType u32 = PrimitiveType.UInt32; DataType r32 = PrimitiveType.Real32; StructureType s1 = new StructureType(); StructureType s2 = new StructureType(); s1.Fields.Add(0, new Pointer(s2, 4)); s1.Fields.Add(4, u32); s2.Fields.Add(0, new Pointer(s1, 4)); s2.Fields.Add(4, r32); DataTypeComparer c = new DataTypeComparer(); Assert.AreNotEqual(0, c.Compare(s1, s2)); Assert.AreNotEqual(0, c.Compare(r32, u32)); }
public void CmpPtrIntPtrInt() { Pointer p1 = new Pointer(PrimitiveType.Int32, 4); Pointer p2 = new Pointer(PrimitiveType.Int32, 4); DataTypeComparer c = new DataTypeComparer(); Assert.AreEqual(0, c.Compare(p1, p2)); }
public void CmpPtrIntPtrInt() { Pointer p1 = new Pointer(PrimitiveType.Int32, 32); Pointer p2 = new Pointer(PrimitiveType.Int32, 32); DataTypeComparer c = new DataTypeComparer(); Assert.AreEqual(0, c.Compare(p1, p2)); }
private bool TypesAreCompatible(DataType dtSrc, DataType dtDst) { if (compTypes.Compare(dtSrc, dtDst) == 0) { return(true); } return(unifier.AreCompatible(dtSrc, dtDst)); }
public void CmpRecursiveEqualStructs() { // struct str1{struct *str2} == struct str2{struct *str1} StructureType s1 = new StructureType(); StructureType s2 = new StructureType(); s1.Fields.Add(0, new Pointer(s2, 32)); s2.Fields.Add(0, new Pointer(s1, 32)); DataTypeComparer c = new DataTypeComparer(); Assert.AreEqual(0, c.Compare(s1, s2)); }
public void CmpRecursiveEqualStructs() { // struct str1{struct *str2} == struct str2{struct *str1} StructureType s1 = new StructureType(); StructureType s2 = new StructureType(); s1.Fields.Add(0, new Pointer(s2, 4)); s2.Fields.Add(0, new Pointer(s1, 4)); DataTypeComparer c = new DataTypeComparer(); Assert.AreEqual(0, c.Compare(s1, s2)); }
public void CmpUnionToUnion() { //Warning : inner types were selected in such a way as to force UnionAlternativeCollection // to place them in provided order. DataType inner1 = PrimitiveType.UInt32; DataType inner2 = PrimitiveType.UInt16; DataType inner3 = PrimitiveType.UInt8; UnionType u1 = new UnionType("Union1",inner1,inner3,inner1); UnionType u2 = new UnionType("Union1",inner1,inner3,inner2); DataTypeComparer c = new DataTypeComparer(); Assert.AreNotEqual(0, c.Compare(u1, u2)); }
public void Dtcmp_Functions() { var sig1 = new FunctionType( new Identifier("", PrimitiveType.Int32, null), new Identifier("arg1", PrimitiveType.Real64, null)); var sig2 = new FunctionType( new Identifier("", PrimitiveType.Int32, null), new Identifier("arg1", PrimitiveType.Real64, null)); var dtcmp = new DataTypeComparer(); Assert.AreEqual(dtcmp.GetHashCode(sig1), dtcmp.GetHashCode(sig2)); Assert.AreEqual(0, dtcmp.Compare(sig1, sig2)); }
public void CmpUnionToUnion() { //Warning : inner types were selected in such a way as to force UnionAlternativeCollection // to place them in provided order. DataType inner1 = PrimitiveType.UInt32; DataType inner2 = PrimitiveType.UInt16; DataType inner3 = PrimitiveType.UInt8; UnionType u1 = new UnionType("Union1", inner1, inner3, inner1); UnionType u2 = new UnionType("Union1", inner1, inner3, inner2); DataTypeComparer c = new DataTypeComparer(); Assert.AreNotEqual(0, c.Compare(u1, u2)); }
private Expression RewritePointer(DataType dtPtr, DataType dtPointee, DataType dtPointeeOriginal) { if (seenPtr) { return(complexExp); } seenPtr = true; Expression result; if (dtPointee is PrimitiveType || dtPointee is Pointer || dtPointee is MemberPointer || dtPointee is CodeType || comp.Compare(dtPtr, dtResult) == 0) { if (dtPointee.Size == 0) { Debug.Print("WARNING: {0} has size 0, which should be impossible", dtPointee); } if (offset == 0 || dtPointee is ArrayType || dtPointee.Size > 0 && offset % dtPointee.Size == 0) { int idx = (offset == 0 || dtPointee is ArrayType) ? 0 : offset / dtPointee.Size; if (idx == 0 && this.indexExp == null) { if (Dereferenced) { result = CreateDereference(dtPointee, complexExp); } else { result = CreateUnreferenced(dtPointee, complexExp); } } else { result = CreateArrayAccess(dtPointee, dtPtr, idx, indexExp, Dereferenced); } } else { result = new PointerAddition(dtPtr, complexExp, offset); } } else { // Drill down. dtOriginal = dtPointeeOriginal; complexExp = CreateDereference(dtPointee, complexExp); bool deref = Dereferenced; //$REVIEW: causes problems with arrayType Dereferenced = true; //$REVUEW: causes problems with arrayType basePointer = null; result = dtPointee.Accept(this); if (!deref) { result = new UnaryExpression(UnaryOperator.AddrOf, dtPtr, result); } Dereferenced = deref; //$REVIEW: causes problems with arrayType } seenPtr = false; return(result); }