Beispiel #1
0
 public override Expression VisitBinaryExpression(BinaryExpression binaryExpression) {
   Expression result = base.VisitBinaryExpression(binaryExpression);
   SpecSharpCompilerOptions options = this.currentOptions as SpecSharpCompilerOptions;
   if (options != null && options.CheckContractAdmissibility) {
     if ((insideMethodContract || insideInvariant) &&
         (binaryExpression.NodeType == NodeType.Eq || binaryExpression.NodeType == NodeType.Ne) &&
           binaryExpression.Operand1 != null && binaryExpression.Operand1.Type != null &&
           !binaryExpression.Operand1.Type.IsValueType) {
       MightReturnNewlyAllocatedObjectVisitor visitor = new MightReturnNewlyAllocatedObjectVisitor(this);
       this.TransferStateTo(visitor);
       visitor.CurrentMethod = this.currentMethod;
       visitor.VisitExpression(binaryExpression.Operand1);
       if (visitor.IsMRNAO) {
         visitor.IsMRNAO = false;
         visitor.VisitExpression(binaryExpression.Operand2);
         if (visitor.IsMRNAO)
           this.HandleError(binaryExpression, Error.BothOperandsOfReferenceComparisonMightBeNewlyAllocated);
       }
     }
   }
   return result;
 }