Else-Block Bug-Fix

git-svn-id: https://svn.code.sf.net/p/jode/code/trunk@29 379699f6-c40d-0410-875b-85095c16579e
stable
delwi 27 years ago
parent c451fada4a
commit ebb3fbd4cb
  1. 43
      jode/jode/flow/FlowBlock.java

@ -200,23 +200,34 @@ public class FlowBlock {
*/ */
StructuredBlock elseBlock = StructuredBlock elseBlock =
jump.prev.outer.getNextBlock(jump.prev); jump.prev.outer.getNextBlock(jump.prev);
if (elseBlock != null && if (elseBlock != null
elseBlock.outer != null && && elseBlock.outer != null
elseBlock.outer instanceof SequentialBlock && && elseBlock.outer instanceof SequentialBlock
elseBlock.outer.getSubBlocks()[0] instanceof IfThenElseBlock && && elseBlock.outer.getSubBlocks()[0] instanceof IfThenElseBlock
(elseBlock.outer.getNextFlowBlock() == successor || && (elseBlock.outer.getNextFlowBlock() == successor
elseBlock.outer.jumpMayBeChanged())) { || elseBlock.outer.jumpMayBeChanged())) {
IfThenElseBlock ifBlock = IfThenElseBlock ifBlock =
(IfThenElseBlock)elseBlock.outer.getSubBlocks()[0]; (IfThenElseBlock)elseBlock.outer.getSubBlocks()[0];
if (ifBlock.getSubBlocks().length == 1) { if (ifBlock.getSubBlocks().length == 1) {
elseBlock.outer.removeJump(); /* make sure that only sequential blocks are between
ifBlock.replace(elseBlock.outer, elseBlock); * jump.prev and the ifBlock
if (appendBlock == elseBlock.outer) */
appendBlock = ifBlock; StructuredBlock block = jump.prev.outer;
ifBlock.moveJump(jump.prev); while (block instanceof SequentialBlock)
ifBlock.setElseBlock(elseBlock); block = block.outer;
continue same_jump;
if (block == ifBlock) {
elseBlock.outer.removeJump();
ifBlock.replace(elseBlock.outer, elseBlock);
if (appendBlock == elseBlock.outer)
appendBlock = ifBlock;
ifBlock.moveJump(jump.prev);
ifBlock.setElseBlock(elseBlock);
continue same_jump;
}
} }
} }
@ -838,7 +849,7 @@ public class FlowBlock {
int continuelevel = 1; int continuelevel = 1;
for (StructuredBlock surrounder = jump.prev.outer; for (StructuredBlock surrounder = jump.prev.outer;
surrounder != null; surrounder != whileBlock;
surrounder = surrounder.outer) { surrounder = surrounder.outer) {
if (surrounder instanceof LoopBlock) { if (surrounder instanceof LoopBlock) {
continuelevel++; continuelevel++;
@ -878,6 +889,10 @@ public class FlowBlock {
return true; return true;
} }
public void makeDeclaration() {
block.makeDeclaration();
}
/** /**
* Resolves the destinations of all jumps. * Resolves the destinations of all jumps.
*/ */

Loading…
Cancel
Save