add some comments

tweak SSASwitchInstruction.toString()

git-svn-id: https://wala.svn.sourceforge.net/svnroot/wala/trunk@1469 f5eafffb-2e1d-0410-98e4-8ec43c5233c4
This commit is contained in:
sjfink 2007-07-13 21:34:04 +00:00
parent cb4012d939
commit 5c89985acf
2 changed files with 17 additions and 2 deletions

View File

@ -70,6 +70,10 @@ public class Util {
return null;
}
/**
* When the tested value of the switch statement in b has value c, which
* basic block does control transfer to.
*/
public static IBasicBlock resolveSwitch(ControlFlowGraph G, IBasicBlock b, int c) {
Assertions._assert(endsWithSwitch(G, b));
SSASwitchInstruction s = (SSASwitchInstruction) getLastInstruction(G, b);
@ -90,6 +94,11 @@ public class Util {
return G.getBlockForInstruction(sw.getDefault()).equals(s);
}
/**
* When a switch statement at the end of block b transfers control to block s,
* which case was taken?
* TODO: Is this correct? Can't we have multiple cases that apply? Check on this.
*/
public static int getSwitchLabel(ControlFlowGraph G, IBasicBlock b, IBasicBlock s) {
Assertions._assert(endsWithSwitch(G, b));
SSASwitchInstruction sw = (SSASwitchInstruction) getLastInstruction(G, b);

View File

@ -18,6 +18,8 @@ import com.ibm.wala.util.debug.Assertions;
import com.ibm.wala.util.intset.IntIterator;
/**
* SSA instruction representing a switch statement.
*
* @author sjfink
*
*/
@ -28,6 +30,10 @@ public class SSASwitchInstruction extends SSAInstruction {
private final int[] casesAndLabels;
/**
* The labels in casesAndLabels represent <em>instruction indices</em> in the IR that each
* switch case branches to.
*/
SSASwitchInstruction(int val, int defaultLabel, int[] casesAndLabels) {
super();
this.val = val;
@ -43,7 +49,7 @@ public class SSASwitchInstruction extends SSAInstruction {
@Override
public String toString(SymbolTable symbolTable, ValueDecorator d) {
return "switch " + getValueString(symbolTable, d, val);
return "switch " + getValueString(symbolTable, d, val) + " " + casesAndLabels;
}
/**
@ -116,7 +122,7 @@ public class SSASwitchInstruction extends SSAInstruction {
@Override
public int hashCode() {
return val * 1663 ^ 3499;
return val * 1663 + 3499;
}
/*