diff --git a/jode/jode/flow/FlowBlock.java b/jode/jode/flow/FlowBlock.java index 6ea775b..c927365 100644 --- a/jode/jode/flow/FlowBlock.java +++ b/jode/jode/flow/FlowBlock.java @@ -380,7 +380,7 @@ public class FlowBlock { * by this blocks */ VariableSet defineHere = successor.in.merge(allOuts); - defineHere.subtractIdentical(in); + defineHere.subtractExact(in); System.err.println(" defineHere : "+defineHere); if (t1Transformation) { @@ -889,10 +889,6 @@ public class FlowBlock { return true; } - public void makeDeclaration() { - block.makeDeclaration(); - } - /** * Resolves the destinations of all jumps. */ @@ -922,6 +918,11 @@ public class FlowBlock { successors.setElementAt(null, successors.indexOf(jump)); } + public void makeDeclaration(VariableSet param) { + in.merge(param); + in.subtract(param); + block.makeDeclaration(param); + } /** * Print the source code for this structured block. This handles @@ -939,14 +940,8 @@ public class FlowBlock { writer.tab(); } - if (jode.Decompiler.isDebugging) { - writer.print("in: "); - java.util.Enumeration enum = in.elements(); - while(enum.hasMoreElements()) { - writer.print(((jode.LocalInfo)enum.nextElement()).getName() - + " "); - } - writer.println(""); + if (!in.isEmpty()) { + writer.print("in: "+in); } block.dumpSource(writer); diff --git a/jode/jode/flow/InstructionContainer.java b/jode/jode/flow/InstructionContainer.java index e9c8328..e9bb350 100644 --- a/jode/jode/flow/InstructionContainer.java +++ b/jode/jode/flow/InstructionContainer.java @@ -27,12 +27,15 @@ public abstract class InstructionContainer extends StructuredBlock { public InstructionContainer(Instruction instr) { this.instr = instr; + if (instr instanceof LocalVarOperator) + used.addElement(((LocalVarOperator)instr).getLocalInfo()); } public InstructionContainer(Instruction instr, Jump jump) { this.instr = instr; if (instr instanceof LocalVarOperator) { LocalVarOperator varOp = (LocalVarOperator) instr; + used.addElement(varOp.getLocalInfo()); jump.out.addElement(varOp.getLocalInfo()); } setJump(jump); diff --git a/jode/jode/flow/StructuredBlock.java b/jode/jode/flow/StructuredBlock.java index c81f41b..58e0db3 100644 --- a/jode/jode/flow/StructuredBlock.java +++ b/jode/jode/flow/StructuredBlock.java @@ -61,11 +61,16 @@ public abstract class StructuredBlock { */ /** - * The variable set containing all variables that must be defined - * in this block (or maybe an outer block, this changes as the - * blocks are put together). + * The variable set containing all variables that are used in + * this block. */ - VariableSet defineHere = new VariableSet(); + VariableSet used = new VariableSet(); + + /** + * The variable set containing all variables we must declare. + * The analyzation is done in makeDeclaration + */ + VariableSet declare = new VariableSet(); /** * The surrounding structured block. If this is the outermost @@ -202,14 +207,14 @@ public abstract class StructuredBlock { /* define(...) will not move from blocks, that are not sub blocks, * so we do it by hand. */ - java.util.Enumeration enum = from.defineHere.elements(); + java.util.Enumeration enum = from.used.elements(); while (enum.hasMoreElements()) { LocalInfo var = ((LocalInfo) enum.nextElement()).getLocalInfo(); - defineHere.addElement(var); + used.addElement(var); var.setDefining(this); } - from.defineHere.removeAllElements(); + from.used.removeAllElements(); StructuredBlock[] subs = from.getSubBlocks(); for (int i=0; i