Ejemplo n.º 1
0
    public virtual Differences VisitSwitchCase(SwitchCase switchCase1, SwitchCase switchCase2){
      Differences differences = new Differences(switchCase1, switchCase2);
      if (switchCase1 == null || switchCase2 == null){
        if (switchCase1 != switchCase2) differences.NumberOfDifferences++; else differences.NumberOfSimilarities++;
        return differences;
      }
      SwitchCase changes = (SwitchCase)switchCase2.Clone();
      SwitchCase deletions = (SwitchCase)switchCase2.Clone();
      SwitchCase insertions = (SwitchCase)switchCase2.Clone();

      Differences diff = this.VisitBlock(switchCase1.Body, switchCase2.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(switchCase1.Label, switchCase2.Label);
      if (diff == null){Debug.Assert(false); return differences;}
      changes.Label = diff.Changes as Expression;
      deletions.Label = diff.Deletions as Expression;
      insertions.Label = diff.Insertions as Expression;
      Debug.Assert(diff.Changes == changes.Label && diff.Deletions == deletions.Label && diff.Insertions == insertions.Label);
      differences.NumberOfDifferences += diff.NumberOfDifferences;
      differences.NumberOfSimilarities += diff.NumberOfSimilarities;

      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;
    }
Ejemplo n.º 2
0
 public override SwitchCase VisitSwitchCase(SwitchCase switchCase)
 {
     if (switchCase == null) return null;
     return base.VisitSwitchCase((SwitchCase)switchCase.Clone());
 }