destinations are FlowBlocks, not addresses

git-svn-id: https://svn.code.sf.net/p/jode/code/trunk@464 379699f6-c40d-0410-875b-85095c16579e
stable
jochen 26 years ago
parent df363d6ed0
commit 8768f0e902
  1. 16
      jode/jode/flow/SwitchBlock.java

@ -31,31 +31,33 @@ implements BreakableBlock {
VariableStack breakedStack; VariableStack breakedStack;
public SwitchBlock(Expression instr, public SwitchBlock(Expression instr,
int[] cases, int[] dests) { int[] cases, FlowBlock[] dests) {
super(instr); super(instr);
/* First remove all dests that jump to the default dest. */ /* First remove all dests that jump to the default dest. */
int numCases = dests.length; int numCases = dests.length;
int defaultDest = dests[cases.length]; FlowBlock defaultDest = dests[cases.length];
for (int i=0; i< cases.length; i++) { for (int i=0; i< cases.length; i++) {
if (dests[i] == defaultDest) { if (dests[i] == defaultDest) {
dests[i] = -1; dests[i] = null;
numCases--; numCases--;
} }
} }
caseBlocks = new CaseBlock[numCases]; caseBlocks = new CaseBlock[numCases];
int lastDest = -1; FlowBlock lastDest = null;
for (int i=numCases-1; i>=0; i--) { for (int i=numCases-1; i>=0; i--) {
/** /**
* Sort the destinations by finding the greatest destAddr * Sort the destinations by finding the greatest destAddr
*/ */
int index = 0; int index = 0;
for (int j=1; j<dests.length; j++) { for (int j=1; j<dests.length; j++) {
if (dests[j] >= dests[index]) if (dests[j] != null
&& (dests[index] == null
|| dests[j].getAddr() >= dests[index].getAddr()))
index = j; index = j;
} }
/* assert(dests[index] != -1) */ /* assert(dests[index] != null) */
int value; int value;
if (index == cases.length) if (index == cases.length)
@ -70,7 +72,7 @@ implements BreakableBlock {
new Jump(dests[index])); new Jump(dests[index]));
caseBlocks[i].outer = this; caseBlocks[i].outer = this;
lastDest = dests[index]; lastDest = dests[index];
dests[index] = -1; dests[index] = null;
if (index == cases.length) if (index == cases.length)
caseBlocks[i].isDefault = true; caseBlocks[i].isDefault = true;
} }

Loading…
Cancel
Save