diff --git a/jode/jode/flow/FlowBlock.java b/jode/jode/flow/FlowBlock.java index c1912bb..bfb5478 100644 --- a/jode/jode/flow/FlowBlock.java +++ b/jode/jode/flow/FlowBlock.java @@ -217,7 +217,7 @@ public class FlowBlock { elseBlock.outer instanceof SequentialBlock && elseBlock.outer.getSubBlocks()[0] instanceof IfThenElseBlock && (elseBlock.outer.getNextFlowBlock() == successor || - elseBlock.outer.jumpMayBeChanged()) { + elseBlock.outer.jumpMayBeChanged())) { IfThenElseBlock ifBlock = (IfThenElseBlock)elseBlock.outer.getSubBlocks()[0]; if (ifBlock.getElseBlock() == null) { @@ -228,7 +228,7 @@ public class FlowBlock { } else { jump.parent.removeJump(); } - ifBlock.replace(elseBlock.outer) + ifBlock.replace(elseBlock.outer); ifBlock.setElseBlock(elseBlock); if (appendBlock = elseBlock.outer) appendBlock = ifBlock; @@ -238,55 +238,55 @@ public class FlowBlock { return appendBlock; } - /** - * Updates the in/out-Vectors of the structured block of the + /** + * Updates the in/out-Vectors of the structured block of the * successing flow block simultanous to a T1 transformation. * @param successor The flow block which is unified with this flow * block. */ - void updateInOut (FlowBlock successor, boolean t1Transformation) { - /* First get the out vectors of all jumps to successor and - * calculate the intersection. - */ - VariableSet allOuts = new VariableSet(); - VariableSet intersectOut = null; - Enumeration enum = successors; - while (enum.hasMoreElement()) { - Jump jump = (Jump) enum.nextElement(); - if (jump == null || jump.destination != successor) - continue; - - allOuts.union(jump.parent.out); - if (intersectOut == null) - intersectOut = jump.parent.out; - else - intersectOut = intersectOut.intersect(jump.parent.out); - } - - /* Now work on each block of the successor */ - Stack todo = new Stack(); - todo.push(successor.block); - while (!todo.empty()) { - StructuredBlock block = (StructuredBlock) todo.pop(); - StructuredBlock[] subBlocks = block.getSubBlocks(); - for (int i=0; i - * - * This isn't easy to prove, it has a lot to do with the - * transformation in optimizeJump and the fact that - * appendBlock was the innermost Block containing all jumps - * and lastModified. - */ + /* Now unify the blocks: Create a new SequentialBlock + * containing appendBlock and successor.block. Then replace + * appendBlock with the new sequential block. + */ + StructuredBlock outer = appendBlock.outer; + StructuredBlock sequBlock = + new SequentialBlock(appendBlock, switchBlock); + outer.replaceSubBlock(appendBlock, sequBlock); + sequBlock.outer = outer; + } + + /* Try to eliminate as many jumps as possible. + */ + + optimizeJumps(succ, appendBlock); + + /* Now remove the jump of the appendBlock if it points to successor. + */ + + if (appendBlock.jump == succ) + appendBlock.removeJump(); - /* Set last modified to correct value. */ - lastModified = succ.lastModified; - } + /* If there are further jumps, put a do/while(0) block around + * appendBlock and replace every remaining jump with a break + * to the do/while block. + */ + + /* Merge the sucessors from the successing flow block + */ + enum = succ.successors.elements(); + while (enum.hasMoreElements()) { + successors.addElement(enum.nextElement()); + } + + /* Believe it or not: Now the rule, that the first part of a + * SequentialBlock shouldn't be another SequentialBlock is + * fulfilled.

+ * + * This isn't easy to prove, it has a lot to do with the + * transformation in optimizeJump and the fact that + * appendBlock was the innermost Block containing all jumps + * and lastModified. + */ + + /* Set last modified to correct value. */ + lastModified = succ.lastModified; + } public boolean doT2() { /* If there are no jumps to the beginning of this flow block @@ -501,7 +508,3 @@ public class FlowBlock { successors.setElementAt(null, successors.indexOf(jump)); } } - - - - diff --git a/jode/jode/flow/StructuredBlock.java b/jode/jode/flow/StructuredBlock.java index 18fa67a..cf25948 100644 --- a/jode/jode/flow/StructuredBlock.java +++ b/jode/jode/flow/StructuredBlock.java @@ -236,6 +236,21 @@ public abstract class StructuredBlock { return false; } + /** + * Get the unique predecessor which mustn't be a conditional jump + * @return the predecessor or null if there isn't a such a thing + */ + public StructuredBlock getSimpleUniquePredecessor() { + SequentialBlock sequ; + if (outer instanceof SequentialBlock) { + if (outer.getSubBlocks()[1] == this) + return outer.getSubBlocks()[0]; + else if (outer.outer instanceof SequentialBlock) + return outer.outer.getSubBlocks[0]; + } + return null; + } + /** * Print the source code for this structured block. This may be * called only once, because it remembers which local variables diff --git a/jode/jode/flow/jode.ppl b/jode/jode/flow/jode.ppl index 826cd2b..0389c32 100755 --- a/jode/jode/flow/jode.ppl +++ b/jode/jode/flow/jode.ppl @@ -35,4 +35,5 @@ auf klo 1998-09-17 17:11:45 ei 1998-09-17 17:49:35 ecd - \ No newline at end of file +1998-09-19 10:46:01 bcd +1998-09-19 11:00:08 ecd \ No newline at end of file