public override BoogieType GetBoogieType(ITypeReference type) { if (type.TypeCode.Equals(PrimitiveTypeCode.String)) { return(BoogieType.Ref); } if (type.TypeCode.Equals(PrimitiveTypeCode.NotPrimitive)) { return(BoogieType.Ref); } if (type.TypeCode.Equals(PrimitiveTypeCode.Reference)) { // manuel: we type a reference accordingly to its target type // we just support reference writes/reads for arguments // void foo (ref int x) -> writes/reads to x are supported // { // .... // ref int y = ...; -> writes/reads to y are not supported // ... // } // this is how bct works. // x is considered as a variable with the target type and then is returned and assigned after the invokation // call arg1 := foo(arg1); IManagedPointerType t = type as IManagedPointerType; Contract.Assume(t != null); return(GetBoogieType(t.TargetType)); } return(base.GetBoogieType(type)); }
public static INamedTypeReference CanonicalizeTypeReference(ITypeReference type) { while (type != null) { IModifiedTypeReference modifiedType = type as IModifiedTypeReference; IPointerTypeReference ptrType = type as IPointerTypeReference; IManagedPointerType refType = type as IManagedPointerType; IArrayTypeReference arrType = type as IArrayTypeReference; IGenericTypeInstanceReference genType = type as IGenericTypeInstanceReference; ISpecializedNestedTypeReference nestedType = type as ISpecializedNestedTypeReference; // TODO: Why doesn't ISpecializedNestedTypeDefinition derive from ISpecializedNestedTypeReference? ISpecializedNestedTypeDefinition nestedTypeDef = type as ISpecializedNestedTypeDefinition; if (modifiedType != null) { type = modifiedType.UnmodifiedType; } else if (ptrType != null) { type = ptrType.TargetType; } else if (refType != null) { type = refType.TargetType; } else if (arrType != null) { type = arrType.ElementType; } else if (genType != null) { type = genType.GenericType; } else if (nestedType != null) { type = nestedType.UnspecializedVersion; } else if (nestedTypeDef != null) { type = nestedTypeDef.UnspecializedVersion; } else /* ITypeDefinition */ { break; } } return(type as INamedTypeReference); }