Needs more thought, but a few bug were fixed.

git-svn-id: https://svn.code.sf.net/p/jode/code/trunk@75 379699f6-c40d-0410-875b-85095c16579e
stable
jochen 26 years ago
parent c25b9e7cb4
commit 5b9cf9ff27
  1. 47
      jode/jode/flow/FlowBlock.java

@ -206,16 +206,15 @@ public class FlowBlock {
(loopBlock.jumpMayBeChanged() (loopBlock.jumpMayBeChanged()
|| loopBlock.getNextFlowBlock() == successor)) { || loopBlock.getNextFlowBlock() == successor)) {
loopBlock.setCondition(instr.negate());
loopBlock.moveDefinitions(cb, null);
cb.removeBlock();
if (loopBlock.jumpMayBeChanged()) { if (loopBlock.jumpMayBeChanged()) {
loopBlock.moveJump(jump); loopBlock.moveJump(jump);
jumps.push(jump); jumps.push(jump);
continue; } else
} jump.prev.removeJump();
jump.prev.removeJump();
loopBlock.setCondition(instr.negate());
loopBlock.moveDefinitions(cb, null);
cb.removeBlock();
continue; continue;
} }
@ -241,18 +240,16 @@ public class FlowBlock {
(loopBlock.jumpMayBeChanged() (loopBlock.jumpMayBeChanged()
|| loopBlock.getNextFlowBlock() == successor)) { || loopBlock.getNextFlowBlock() == successor)) {
loopBlock.setType(LoopBlock.DOWHILE);
loopBlock.setCondition(instr.negate());
loopBlock.moveDefinitions(cb, null);
cb.removeBlock();
if (loopBlock.jumpMayBeChanged()) { if (loopBlock.jumpMayBeChanged()) {
loopBlock.moveJump(jump); loopBlock.moveJump(jump);
jumps.push(jump); jumps.push(jump);
continue; } else
} jump.prev.removeJump();
jump.prev.removeJump(); loopBlock.setType(LoopBlock.DOWHILE);
loopBlock.setCondition(instr.negate());
loopBlock.moveDefinitions(cb, null);
cb.removeBlock();
continue; continue;
} }
} }
@ -472,7 +469,7 @@ public class FlowBlock {
* @return The variables that must be defined in this block. * @return The variables that must be defined in this block.
*/ */
void updateInOut (FlowBlock successor, boolean t1Transformation, void updateInOut (FlowBlock successor, boolean t1Transformation,
Stack jumps) { Stack jumps) {
/* First get the out vectors of all jumps to successor and /* First get the out vectors of all jumps to successor and
* calculate the intersection. * calculate the intersection.
*/ */
@ -1066,7 +1063,10 @@ public class FlowBlock {
} }
public void removeJSR(FlowBlock subRoutine) { public void removeJSR(FlowBlock subRoutine) {
Enumeration enum = ((Stack)successors.remove(subRoutine)).elements(); Stack jumps = (Stack)successors.remove(subRoutine);
if (jumps == null)
return;
Enumeration enum = jumps.elements();
while (enum.hasMoreElements()) { while (enum.hasMoreElements()) {
Jump jump = (Jump)enum.nextElement(); Jump jump = (Jump)enum.nextElement();
@ -1468,8 +1468,10 @@ public class FlowBlock {
.jump.destination.predecessors.removeElement(catchFlow); .jump.destination.predecessors.removeElement(catchFlow);
subRoutine.analyzeSubRoutine(addr+length, end); subRoutine.analyzeSubRoutine(addr+length, end);
updateInOut(subRoutine, true, Stack jumps = (Stack)successors.get(subRoutine);
(Stack)successors.get(subRoutine)); if (jumps != null)
updateInOut(subRoutine, true, jumps);
if (subRoutine.successors.size() != 0) if (subRoutine.successors.size() != 0)
throw new AssertError("Jump inside subroutine"); throw new AssertError("Jump inside subroutine");
length += subRoutine.length; length += subRoutine.length;
@ -1480,6 +1482,7 @@ public class FlowBlock {
newBlock.setTryBlock(tryFlow.block); newBlock.setTryBlock(tryFlow.block);
mergeSuccessors(tryFlow); mergeSuccessors(tryFlow);
newBlock.setFinallyBlock(subRoutine.block); newBlock.setFinallyBlock(subRoutine.block);
mergeSuccessors(subRoutine);
newBlock.moveJump(rawBlock.jump); newBlock.moveJump(rawBlock.jump);
lastModified = newBlock; lastModified = newBlock;
changed = true; changed = true;
@ -1625,8 +1628,8 @@ public class FlowBlock {
updateInOut(nextFlow, true, lastJumps); updateInOut(nextFlow, true, lastJumps);
lastJumps.pop(); lastJumps.pop();
lastFlow.optimizeJumps(jumps); lastFlow.optimizeJumps(lastJumps);
lastFlow.resolveRemaining(jumps); lastFlow.resolveRemaining(lastJumps);
} else } else
updateInOut(nextFlow, true, jumps); updateInOut(nextFlow, true, jumps);

Loading…
Cancel
Save