bug fixes, cleanups, and more generics

git-svn-id: https://wala.svn.sourceforge.net/svnroot/wala/trunk@1013 f5eafffb-2e1d-0410-98e4-8ec43c5233c4
This commit is contained in:
sjfink 2007-04-26 17:29:29 +00:00
parent 47df58f051
commit 4f9d62784e
2 changed files with 30 additions and 10 deletions

View File

@ -52,8 +52,17 @@ public final class GotoInstruction extends Instruction {
return label[0];
}
public Instruction redirectTargets(int[] targetMap) {
return make(targetMap[label[0]]);
/*
* (non-Javadoc)
*
* @see com.ibm.wala.shrikeBT.Instruction#redirectTargets(int[])
*/
public Instruction redirectTargets(int[] targetMap) throws IllegalArgumentException {
try {
return make(targetMap[label[0]]);
} catch (ArrayIndexOutOfBoundsException e) {
throw new IllegalArgumentException("Illegal target map", e);
}
}
public boolean equals(Object o) {
@ -76,7 +85,10 @@ public final class GotoInstruction extends Instruction {
public void visit(Visitor v) {
v.visitGoto(this);
}
/* (non-Javadoc)
/*
* (non-Javadoc)
*
* @see com.ibm.domo.cfg.IInstruction#isPEI()
*/
public boolean isPEI() {

View File

@ -17,6 +17,7 @@ import java.util.Arrays;
*/
public final class SwitchInstruction extends Instruction {
private int[] casesAndLabels;
private int defaultLabel;
protected SwitchInstruction(short opcode, int[] casesAndLabels, int defaultLabel) {
@ -83,13 +84,17 @@ public final class SwitchInstruction extends Instruction {
return r;
}
public Instruction redirectTargets(int[] targetMap) {
int[] cs = new int[casesAndLabels.length];
for (int i = 0; i < cs.length; i += 2) {
cs[i] = casesAndLabels[i];
cs[i + 1] = targetMap[casesAndLabels[i + 1]];
public Instruction redirectTargets(int[] targetMap) throws IllegalArgumentException {
try {
int[] cs = new int[casesAndLabels.length];
for (int i = 0; i < cs.length; i += 2) {
cs[i] = casesAndLabels[i];
cs[i + 1] = targetMap[casesAndLabels[i + 1]];
}
return make(cs, targetMap[defaultLabel]);
} catch (ArrayIndexOutOfBoundsException e) {
throw new IllegalArgumentException("Illegal target map", e);
}
return make(cs, targetMap[defaultLabel]);
}
public boolean equals(Object o) {
@ -127,7 +132,10 @@ public final class SwitchInstruction extends Instruction {
public void visit(Visitor v) {
v.visitSwitch(this);
}
/* (non-Javadoc)
/*
* (non-Javadoc)
*
* @see com.ibm.domo.cfg.IInstruction#isPEI()
*/
public boolean isPEI() {