1 17 package org.apache.bcel.generic; 18 19 32 public interface InstructionComparator { 33 34 public static final InstructionComparator DEFAULT = new InstructionComparator() { 35 36 public boolean equals( Instruction i1, Instruction i2 ) { 37 if (i1.opcode == i2.opcode) { 38 if (i1 instanceof Select) { 39 InstructionHandle[] t1 = ((Select) i1).getTargets(); 40 InstructionHandle[] t2 = ((Select) i2).getTargets(); 41 if (t1.length == t2.length) { 42 for (int i = 0; i < t1.length; i++) { 43 if (t1[i] != t2[i]) { 44 return false; 45 } 46 } 47 return true; 48 } 49 } else if (i1 instanceof BranchInstruction) { 50 return ((BranchInstruction) i1).target == ((BranchInstruction) i2).target; 51 } else if (i1 instanceof ConstantPushInstruction) { 52 return ((ConstantPushInstruction) i1).getValue().equals( 53 ((ConstantPushInstruction) i2).getValue()); 54 } else if (i1 instanceof IndexedInstruction) { 55 return ((IndexedInstruction) i1).getIndex() == ((IndexedInstruction) i2) 56 .getIndex(); 57 } else if (i1 instanceof NEWARRAY) { 58 return ((NEWARRAY) i1).getTypecode() == ((NEWARRAY) i2).getTypecode(); 59 } else { 60 return true; 61 } 62 } 63 return false; 64 } 65 }; 66 67 68 public boolean equals( Instruction i1, Instruction i2 ); 69 } 70 | Popular Tags |