diff --git a/jode/jode/flow/CatchBlock.java b/jode/jode/flow/CatchBlock.java index 0fdd650..133a1cf 100644 --- a/jode/jode/flow/CatchBlock.java +++ b/jode/jode/flow/CatchBlock.java @@ -48,8 +48,6 @@ public class CatchBlock extends StructuredBlock { public CatchBlock(Type type, LocalInfo local) { exceptionType = type; exceptionLocal = local; - if (local != null) - used.addElement(exceptionLocal); } public Type getExceptionType() { @@ -115,13 +113,19 @@ public class CatchBlock extends StructuredBlock { } public void removePush() { - if (pushedLocal != null) { + if (pushedLocal != null) exceptionLocal = pushedLocal; - used.addElement(pushedLocal); - } super.removePush(); } + public VariableSet propagateUsage() { + if (used == null) + used = new VariableSet(); /*XXX*/ + if (exceptionLocal != null) + used.addElement(exceptionLocal); + return super.propagateUsage(); + } + /** * Print the code for the declaration of a local variable. * @param writer The tabbed print writer, where we print to. diff --git a/jode/jode/flow/ConditionalBlock.java b/jode/jode/flow/ConditionalBlock.java index 4ef8edf..a47a5f7 100644 --- a/jode/jode/flow/ConditionalBlock.java +++ b/jode/jode/flow/ConditionalBlock.java @@ -112,7 +112,7 @@ public class ConditionalBlock extends InstructionContainer { public void removePush() { if (stack != null) - instr = stack.mergeIntoExpression(instr, used); + instr = stack.mergeIntoExpression(instr); trueBlock.removePush(); } diff --git a/jode/jode/flow/CreateCheckNull.java b/jode/jode/flow/CreateCheckNull.java index 6d81e3b..185f28e 100644 --- a/jode/jode/flow/CreateCheckNull.java +++ b/jode/jode/flow/CreateCheckNull.java @@ -63,7 +63,6 @@ public class CreateCheckNull { LocalInfo li = new LocalInfo(); ic.setInstruction(new CheckNullOperator(Type.tUObject, li)); - ic.used.addElement(li); last.replace(last.outer); return true; } @@ -94,7 +93,6 @@ public class CreateCheckNull { LocalInfo li = new LocalInfo(); InstructionContainer ic = new InstructionBlock(new CheckNullOperator(Type.tUObject, li)); - ic.used.addElement(li); ifBlock.flowBlock.removeSuccessor(ifBlock.thenBlock.jump); ic.moveJump(ifBlock.jump); if (last == ifBlock) { diff --git a/jode/jode/flow/IfThenElseBlock.java b/jode/jode/flow/IfThenElseBlock.java index a010277..c41b7cc 100644 --- a/jode/jode/flow/IfThenElseBlock.java +++ b/jode/jode/flow/IfThenElseBlock.java @@ -125,12 +125,19 @@ public class IfThenElseBlock extends StructuredBlock { public void removePush() { if (condStack != null) - cond = condStack.mergeIntoExpression(cond, used); + cond = condStack.mergeIntoExpression(cond); thenBlock.removePush(); if (elseBlock != null) elseBlock.removePush(); } + public VariableSet propagateUsage() { + if (used == null) + used = new VariableSet(); /*XXX*/ + cond.fillInGenSet(null, used); + return super.propagateUsage(); + } + /** * 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/InstructionBlock.java b/jode/jode/flow/InstructionBlock.java index 099cd5b..0455a5b 100644 --- a/jode/jode/flow/InstructionBlock.java +++ b/jode/jode/flow/InstructionBlock.java @@ -77,13 +77,12 @@ public class InstructionBlock extends InstructionContainer { public void removePush() { if (stack != null) - instr = stack.mergeIntoExpression(instr, used); + instr = stack.mergeIntoExpression(instr); if (pushedLocal != null) { Expression store = new StoreInstruction (new LocalStoreOperator (pushedLocal.getType(), pushedLocal)).addOperand(instr); instr = store; - used.addElement(pushedLocal); } super.removePush(); } diff --git a/jode/jode/flow/InstructionContainer.java b/jode/jode/flow/InstructionContainer.java index 912c243..f647625 100644 --- a/jode/jode/flow/InstructionContainer.java +++ b/jode/jode/flow/InstructionContainer.java @@ -33,19 +33,16 @@ public abstract class InstructionContainer extends StructuredBlock { public InstructionContainer(Expression instr) { this.instr = instr; - if (instr != null) - instr.fillInGenSet(null, used); } public InstructionContainer(Expression instr, Jump jump) { this(instr); setJump(jump); - } - - public void setJump(Jump jump) { - super.setJump(jump); - jump.gen.add(used); - jump.kill.add(used); + if (instr != null) { + VariableSet gen = new VariableSet(); + instr.fillInGenSet(null, jump.gen); + instr.fillInGenSet(null, jump.kill); + } } /** @@ -72,6 +69,14 @@ public abstract class InstructionContainer extends StructuredBlock { instr.fillInGenSet(in, gen); } + public VariableSet propagateUsage() { + if (used == null) + used = new VariableSet(); /*XXX*/ + if (instr != null) + instr.fillInGenSet(null, used); + return super.propagateUsage(); + } + public boolean doTransformations() { StructuredBlock last = flowBlock.lastModified; return CreateNewConstructor.transform(this, last) diff --git a/jode/jode/flow/RetBlock.java b/jode/jode/flow/RetBlock.java index 2dfe12f..18e6171 100644 --- a/jode/jode/flow/RetBlock.java +++ b/jode/jode/flow/RetBlock.java @@ -35,7 +35,6 @@ public class RetBlock extends StructuredBlock { public RetBlock(LocalInfo local) { this.local = local; - used.addElement(local); } /** @@ -59,6 +58,13 @@ public class RetBlock extends StructuredBlock { return null; } + public VariableSet propagateUsage() { + if (used == null) + used = new VariableSet(); /*XXX*/ + used.addElement(local); + return super.propagateUsage(); + } + public void dumpInstruction(jode.decompiler.TabbedPrintWriter writer) throws java.io.IOException { diff --git a/jode/jode/flow/ReturnBlock.java b/jode/jode/flow/ReturnBlock.java index b6fd5d3..88605dc 100644 --- a/jode/jode/flow/ReturnBlock.java +++ b/jode/jode/flow/ReturnBlock.java @@ -60,7 +60,7 @@ public class ReturnBlock extends InstructionContainer { public void removePush() { if (stack != null) - instr = stack.mergeIntoExpression(instr, used); + instr = stack.mergeIntoExpression(instr); } /** diff --git a/jode/jode/flow/SequentialBlock.java b/jode/jode/flow/SequentialBlock.java index 1f6255d..c84042e 100644 --- a/jode/jode/flow/SequentialBlock.java +++ b/jode/jode/flow/SequentialBlock.java @@ -168,7 +168,9 @@ public class SequentialBlock extends StructuredBlock { * block (this is not the used set). */ public VariableSet propagateUsage() { - VariableSet allUse = (VariableSet) used.clone(); + if (used == null) + used = new VariableSet();/*XXX*/ + VariableSet allUse = new VariableSet(); VariableSet childUse0 = subBlocks[0].propagateUsage(); VariableSet childUse1 = subBlocks[1].propagateUsage(); /* All variables used somewhere inside both sub blocks, are diff --git a/jode/jode/flow/StructuredBlock.java b/jode/jode/flow/StructuredBlock.java index 471c26c..7e49248 100644 --- a/jode/jode/flow/StructuredBlock.java +++ b/jode/jode/flow/StructuredBlock.java @@ -64,9 +64,9 @@ public abstract class StructuredBlock { /** * The variable set containing all variables that are used in - * this block. + * this block. You must set this, before calling super.propagateUsage. */ - VariableSet used = new VariableSet(); + VariableSet used; /** * The variable set containing all variables we must declare. @@ -210,16 +210,16 @@ public abstract class StructuredBlock { * will be moved to this block (may be this). */ void moveDefinitions(StructuredBlock from, StructuredBlock sub) { - while (from != sub && from != this) { - used.unionExact(from.used); - from.used.removeAllElements(); - StructuredBlock[] subs = from.getSubBlocks(); - if (subs.length == 0) - return; - for (int i=0; inot the used set). */ public VariableSet propagateUsage() { + if (used == null) + used = new VariableSet(); /*XXX*/ StructuredBlock[] subs = getSubBlocks(); VariableSet allUse = (VariableSet) used.clone(); for (int i=0; i= 0; i--) { - if (!used.contains(stackMap[i])) - used.addElement(stackMap[i]); +// if (!used.contains(stackMap[i])) +// used.addElement(stackMap[i]); expr = expr.addOperand (new LocalLoadOperator(stackMap[i].getType(), null, stackMap[i]));