1 package com.sun.org.apache.bcel.internal.generic; 2 3 56 57 70 public interface InstructionComparator { 71 public static final InstructionComparator DEFAULT = 72 new InstructionComparator() { 73 public boolean equals(Instruction i1, Instruction i2) { 74 if(i1.opcode == i2.opcode) { 75 if(i1 instanceof Select) { 76 InstructionHandle[] t1 = ((Select)i1).getTargets(); 77 InstructionHandle[] t2 = ((Select)i2).getTargets(); 78 79 if(t1.length == t2.length) { 80 for(int i = 0; i < t1.length; i++) { 81 if(t1[i] != t2[i]) { 82 return false; 83 } 84 } 85 86 return true; 87 } 88 } else if(i1 instanceof BranchInstruction) { 89 return ((BranchInstruction)i1).target == 90 ((BranchInstruction)i2).target; 91 } else if(i1 instanceof ConstantPushInstruction) { 92 return ((ConstantPushInstruction)i1).getValue(). 93 equals(((ConstantPushInstruction)i2).getValue()); 94 } else if(i1 instanceof IndexedInstruction) { 95 return ((IndexedInstruction)i1).getIndex() == 96 ((IndexedInstruction)i2).getIndex(); 97 } else if(i1 instanceof NEWARRAY) { 98 return ((NEWARRAY)i1).getTypecode() == ((NEWARRAY)i2).getTypecode(); 99 } else { 100 return true; 101 } 102 } 103 104 return false; 105 } 106 }; 107 108 public boolean equals(Instruction i1, Instruction i2); 109 } 110 | Popular Tags |