コード例 #1
0
 /**
  * Does the current state of the algorithm optimistically assume that two nodes are congruent?
  * Note: this can return false even if the value numbers are currently the same.
  *
  * @param v1 first vertex
  * @param v2 second vertex
  * @return whether the notes are assumed to be congruent
  */
 private boolean checkCongruence(ValueGraphVertex v1, ValueGraphVertex v2) {
   if (v1 == v2) {
     return true;
   }
   // make sure the two nodes have the same label
   if (v1.getLabel() != v2.getLabel()) {
     return false;
   }
   // make sure that the operands match
   int arity = v1.getArity();
   for (int i = 0; i < arity; i++) {
     ValueGraphVertex target1 = v1.getTarget(i);
     ValueGraphVertex target2 = v2.getTarget(i);
     // if either target is null, then that particular control
     // flow path is never realized, so assume TOP
     if ((target1 == null) || (target2 == null)) {
       continue;
     }
     if (target1.getValueNumber() != target2.getValueNumber()) {
       return false;
     }
   }
   return true;
 }