diff --git a/jode/jode/flow/ConditionalBlock.java b/jode/jode/flow/ConditionalBlock.java index 40a76df..b1b7847 100644 --- a/jode/jode/flow/ConditionalBlock.java +++ b/jode/jode/flow/ConditionalBlock.java @@ -122,7 +122,7 @@ public class ConditionalBlock extends InstructionContainer { public void dumpInstruction(TabbedPrintWriter writer) throws java.io.IOException { - writer.println("IF ("+instr.simplify().toString()+")"); + writer.println("IF ("+instr.toString()+")"); writer.tab(); trueBlock.dumpSource(writer); writer.untab(); @@ -135,3 +135,4 @@ public class ConditionalBlock extends InstructionContainer { || CreateIfThenElseOperator.createFunny(this, last); } } + diff --git a/jode/jode/flow/IfThenElseBlock.java b/jode/jode/flow/IfThenElseBlock.java index 1e8f275..835789c 100644 --- a/jode/jode/flow/IfThenElseBlock.java +++ b/jode/jode/flow/IfThenElseBlock.java @@ -140,7 +140,7 @@ public class IfThenElseBlock extends StructuredBlock { throws java.io.IOException { boolean needBrace = thenBlock.needsBraces(); - writer.print("if ("+cond.simplify().toString()+")"); + writer.print("if ("+cond.toString()+")"); if (needBrace) writer.openBrace(); else @@ -194,6 +194,11 @@ public class IfThenElseBlock extends StructuredBlock { && (elseBlock.jump != null || elseBlock.jumpMayBeChanged()); } + public void simplify() { + cond = cond.simplify(); + super.simplify(); + } + public boolean doTransformations() { StructuredBlock last = flowBlock.lastModified; return CreateCheckNull.transformJikes(this, last) diff --git a/jode/jode/flow/InstructionContainer.java b/jode/jode/flow/InstructionContainer.java index 17ff813..5de3804 100644 --- a/jode/jode/flow/InstructionContainer.java +++ b/jode/jode/flow/InstructionContainer.java @@ -99,6 +99,12 @@ public abstract class InstructionContainer extends StructuredBlock { return instr; } + public void simplify() { + if (instr != null) + instr = instr.simplify(); + super.simplify(); + } + /** * Set the contained instruction. * @param instr the new instruction. diff --git a/jode/jode/flow/LoopBlock.java b/jode/jode/flow/LoopBlock.java index a112d37..1189299 100644 --- a/jode/jode/flow/LoopBlock.java +++ b/jode/jode/flow/LoopBlock.java @@ -246,7 +246,7 @@ public class LoopBlock extends StructuredBlock implements BreakableBlock { /* special syntax for endless loops: */ writer.print("for (;;)"); else - writer.print("while ("+cond.simplify().toString()+")"); + writer.print("while ("+cond.toString()+")"); break; case DOWHILE: writer.print("do"); @@ -259,11 +259,11 @@ public class LoopBlock extends StructuredBlock implements BreakableBlock { init.getInstruction().getOperator()) .getLocalInfo().getType().getHint() + " "); - writer.print(init.getInstruction().simplify().toString()); + writer.print(init.getInstruction().toString()); } else writer.print("/**/"); - writer.print("; "+cond.simplify().toString()+"; " - +incr.getInstruction().simplify().toString()+")"); + writer.print("; "+cond.toString()+"; " + +incr.getInstruction().toString()+")"); break; } if (needBrace) @@ -439,8 +439,19 @@ public class LoopBlock extends StructuredBlock implements BreakableBlock { return mayChangeJump; } + public void simplify() { + cond = cond.simplify(); + if (type == FOR) { + incr.simplify(); + if (init != null) + init.simplify(); + } + super.simplify(); + } + public boolean doTransformations() { return init == null && (type == FOR || type == POSSFOR) && CreateForInitializer.transform(this, flowBlock.lastModified); } } + diff --git a/jode/jode/flow/ReturnBlock.java b/jode/jode/flow/ReturnBlock.java index 9e50150..38e4dd9 100644 --- a/jode/jode/flow/ReturnBlock.java +++ b/jode/jode/flow/ReturnBlock.java @@ -75,6 +75,6 @@ public class ReturnBlock extends InstructionContainer { throws java.io.IOException { writer.println("return" + - (instr == null ? "" : " " + instr.simplify()) + ";"); + (instr == null ? "" : " " + instr) + ";"); } } diff --git a/jode/jode/flow/SwitchBlock.java b/jode/jode/flow/SwitchBlock.java index 5774f8a..54ea529 100644 --- a/jode/jode/flow/SwitchBlock.java +++ b/jode/jode/flow/SwitchBlock.java @@ -191,7 +191,7 @@ implements BreakableBlock { writer.println(label+":"); writer.tab(); } - writer.print("switch ("+instr.simplify()+")"); + writer.print("switch ("+instr+")"); writer.openBrace(); for (int i=0; i < caseBlocks.length; i++) caseBlocks[i].dumpSource(writer); diff --git a/jode/jode/flow/SynchronizedBlock.java b/jode/jode/flow/SynchronizedBlock.java index 1c426eb..760d3d6 100644 --- a/jode/jode/flow/SynchronizedBlock.java +++ b/jode/jode/flow/SynchronizedBlock.java @@ -85,7 +85,7 @@ public class SynchronizedBlock extends StructuredBlock { writer.println("MISSING MONITORENTER"); writer.print("synchronized (" + (object != null - ? object.simplify().toString() + ? object.toString() : local.getName()) + ")"); writer.openBrace(); writer.tab(); @@ -94,6 +94,13 @@ public class SynchronizedBlock extends StructuredBlock { writer.closeBrace(); } + public void simplify() { + if (object != null) + object = object.simplify(); + super.simplify(); + } + + public boolean doTransformations() { StructuredBlock last = flowBlock.lastModified; return (!isEntered && CompleteSynchronized.enter(this, last))