diff --git a/jode/jode/flow/InstructionBlock.java b/jode/jode/flow/InstructionBlock.java index 6e4cc8c..762ee68 100644 --- a/jode/jode/flow/InstructionBlock.java +++ b/jode/jode/flow/InstructionBlock.java @@ -102,11 +102,11 @@ public class InstructionBlock extends InstructionContainer { * variable. In that case mark this as declaration and return the * variable. */ - public LocalInfo checkDeclaration(VariableSet done) { + public void checkDeclaration(VariableSet declareSet) { if (instr.getOperator() instanceof LocalStoreOperator) { LocalInfo local = ((LocalStoreOperator) instr.getOperator()).getLocalInfo(); - if (!done.contains(local)) { + if (declareSet.contains(local)) { /* Special case: This is a variable assignment, and * the variable has not been declared before. We can * change this to a initializing variable declaration. @@ -115,10 +115,9 @@ public class InstructionBlock extends InstructionContainer { if (instr instanceof ComplexExpression) ((ComplexExpression) instr) .getSubExpressions()[0].makeInitializer(); - return local; + declareSet.removeElement(local); } } - return null; } /** @@ -128,13 +127,8 @@ public class InstructionBlock extends InstructionContainer { * @param done The set of the already declare variables. */ public void makeDeclaration(VariableSet done) { - LocalInfo local = checkDeclaration(done); - if (local != null) { - done.addElement(local); - super.makeDeclaration(done); - done.removeElement(local); - } else - super.makeDeclaration(done); + super.makeDeclaration(done); + checkDeclaration(declare); } public void dumpInstruction(TabbedPrintWriter writer) diff --git a/jode/jode/flow/SequentialBlock.java b/jode/jode/flow/SequentialBlock.java index a6053de..28b7a54 100644 --- a/jode/jode/flow/SequentialBlock.java +++ b/jode/jode/flow/SequentialBlock.java @@ -166,21 +166,13 @@ public class SequentialBlock extends StructuredBlock { * @param done The set of the already declare variables. */ public void makeDeclaration(VariableSet done) { + super.makeDeclaration(done); if (subBlocks[0] instanceof InstructionBlock) { /* Special case: If the first block is an InstructionBlock, - * it can declare the variable it writes to in a special way - * and that declaration will last for the second sub block. + * it can declare the variable it writes to in a special way. */ - LocalInfo local = - ((InstructionBlock) subBlocks[0]).checkDeclaration(done); - if (local != null) { - done.addElement(local); - super.makeDeclaration(done); - done.removeElement(local); - return; - } + ((InstructionBlock) subBlocks[0]).checkDeclaration(this.declare); } - super.makeDeclaration(done); } public void dumpInstruction(TabbedPrintWriter writer)