public virtual Differences VisitForEach(ForEach forEach1, ForEach forEach2){
      Differences differences = new Differences(forEach1, forEach2);
      if (forEach1 == null || forEach2 == null){
        if (forEach1 != forEach2) differences.NumberOfDifferences++; else differences.NumberOfSimilarities++;
        return differences;
      }
      ForEach changes = (ForEach)forEach2.Clone();
      ForEach deletions = (ForEach)forEach2.Clone();
      ForEach insertions = (ForEach)forEach2.Clone();

      Differences diff = this.VisitBlock(forEach1.Body, forEach2.Body);
      if (diff == null){Debug.Assert(false); return differences;}
      changes.Body = diff.Changes as Block;
      deletions.Body = diff.Deletions as Block;
      insertions.Body = diff.Insertions as Block;
      Debug.Assert(diff.Changes == changes.Body && diff.Deletions == deletions.Body && diff.Insertions == insertions.Body);
      differences.NumberOfDifferences += diff.NumberOfDifferences;
      differences.NumberOfSimilarities += diff.NumberOfSimilarities;

      diff = this.VisitExpression(forEach1.SourceEnumerable, forEach2.SourceEnumerable);
      if (diff == null){Debug.Assert(false); return differences;}
      changes.SourceEnumerable = diff.Changes as Expression;
      deletions.SourceEnumerable = diff.Deletions as Expression;
      insertions.SourceEnumerable = diff.Insertions as Expression;
      Debug.Assert(diff.Changes == changes.SourceEnumerable && diff.Deletions == deletions.SourceEnumerable && diff.Insertions == insertions.SourceEnumerable);
      differences.NumberOfDifferences += diff.NumberOfDifferences;
      differences.NumberOfSimilarities += diff.NumberOfSimilarities;

      diff = this.VisitExpressionList(forEach1.Invariants, forEach2.Invariants, out changes.Invariants, out deletions.Invariants, out insertions.Invariants);
      if (diff == null){Debug.Assert(false); return differences;}
      differences.NumberOfDifferences += diff.NumberOfDifferences;
      differences.NumberOfSimilarities += diff.NumberOfSimilarities;

      diff = this.VisitExpression(forEach1.InductionVariable, forEach2.InductionVariable);
      if (diff == null){Debug.Assert(false); return differences;}
      changes.InductionVariable = diff.Changes as Expression;
      deletions.InductionVariable = diff.Deletions as Expression;
      insertions.InductionVariable = diff.Insertions as Expression;
      Debug.Assert(diff.Changes == changes.InductionVariable && diff.Deletions == deletions.InductionVariable && diff.Insertions == insertions.InductionVariable);
      differences.NumberOfDifferences += diff.NumberOfDifferences;
      differences.NumberOfSimilarities += diff.NumberOfSimilarities;

      diff = this.VisitExpression(forEach1.TargetVariable, forEach2.TargetVariable);
      if (diff == null){Debug.Assert(false); return differences;}
      changes.TargetVariable = diff.Changes as Expression;
      deletions.TargetVariable = diff.Deletions as Expression;
      insertions.TargetVariable = diff.Insertions as Expression;
      Debug.Assert(diff.Changes == changes.TargetVariable && diff.Deletions == deletions.TargetVariable && diff.Insertions == insertions.TargetVariable);
      differences.NumberOfDifferences += diff.NumberOfDifferences;
      differences.NumberOfSimilarities += diff.NumberOfSimilarities;

      diff = this.VisitTypeNode(forEach1.TargetVariableType, forEach2.TargetVariableType);
      if (diff == null){Debug.Assert(false); return differences;}
      changes.TargetVariableType = diff.Changes as TypeNode;
      deletions.TargetVariableType = diff.Deletions as TypeNode;
      insertions.TargetVariableType = diff.Insertions as TypeNode;
      //Debug.Assert(diff.Changes == changes.TargetVariableType && diff.Deletions == deletions.TargetVariableType && diff.Insertions == insertions.TargetVariableType);
      differences.NumberOfDifferences += diff.NumberOfDifferences;
      differences.NumberOfSimilarities += diff.NumberOfSimilarities;

      if (forEach1.StatementTerminatesNormallyIfEnumerableIsNull == forEach2.StatementTerminatesNormallyIfEnumerableIsNull) differences.NumberOfSimilarities++; else differences.NumberOfDifferences++;
      if (forEach1.StatementTerminatesNormallyIfEnumeratorIsNull == forEach2.StatementTerminatesNormallyIfEnumeratorIsNull) differences.NumberOfSimilarities++; else differences.NumberOfDifferences++;

      if (differences.NumberOfDifferences == 0){
        differences.Changes = null;
        differences.Deletions = null;
        differences.Insertions = null;
      }else{
        differences.Changes = changes;
        differences.Deletions = deletions;
        differences.Insertions = insertions;
      }
      return differences;
    }
Exemple #2
0
 public override Statement VisitForEach(ForEach forEach)
 {
     if (forEach == null) return null;
     return base.VisitForEach((ForEach)forEach.Clone());
 }