From 328612fb073a7243aef1bacddbdb4c1160bac227 Mon Sep 17 00:00:00 2001 From: jochen Date: Fri, 14 May 1999 12:09:07 +0000 Subject: [PATCH] getUsed vs. propagateUsage git-svn-id: https://svn.code.sf.net/p/jode/code/trunk@817 379699f6-c40d-0410-875b-85095c16579e --- jode/jode/flow/IfThenElseBlock.java | 7 +++---- jode/jode/flow/InstructionContainer.java | 7 +++---- jode/jode/flow/LoopBlock.java | 9 +++------ jode/jode/flow/RetBlock.java | 7 +++---- jode/jode/flow/SequentialBlock.java | 8 +++----- jode/jode/flow/StructuredBlock.java | 16 +++++++++------- jode/jode/flow/SwitchBlock.java | 7 ------- jode/jode/flow/SynchronizedBlock.java | 13 +++++++------ 8 files changed, 31 insertions(+), 43 deletions(-) diff --git a/jode/jode/flow/IfThenElseBlock.java b/jode/jode/flow/IfThenElseBlock.java index c41b7cc..fd26542 100644 --- a/jode/jode/flow/IfThenElseBlock.java +++ b/jode/jode/flow/IfThenElseBlock.java @@ -131,11 +131,10 @@ public class IfThenElseBlock extends StructuredBlock { elseBlock.removePush(); } - public VariableSet propagateUsage() { - if (used == null) - used = new VariableSet(); /*XXX*/ + public VariableSet getUsed() { + used = new VariableSet(); cond.fillInGenSet(null, used); - return super.propagateUsage(); + return used; } /** diff --git a/jode/jode/flow/InstructionContainer.java b/jode/jode/flow/InstructionContainer.java index f647625..be3b1c5 100644 --- a/jode/jode/flow/InstructionContainer.java +++ b/jode/jode/flow/InstructionContainer.java @@ -69,12 +69,11 @@ public abstract class InstructionContainer extends StructuredBlock { instr.fillInGenSet(in, gen); } - public VariableSet propagateUsage() { - if (used == null) - used = new VariableSet(); /*XXX*/ + public VariableSet getUsed() { + used = new VariableSet(); if (instr != null) instr.fillInGenSet(null, used); - return super.propagateUsage(); + return used; } public boolean doTransformations() { diff --git a/jode/jode/flow/LoopBlock.java b/jode/jode/flow/LoopBlock.java index 6df978b..f4b3d09 100644 --- a/jode/jode/flow/LoopBlock.java +++ b/jode/jode/flow/LoopBlock.java @@ -211,18 +211,15 @@ public class LoopBlock extends StructuredBlock implements BreakableBlock { } } - public VariableSet propagateUsage() { - if (used == null) - used = new VariableSet(); /*XXX*/ + public VariableSet getUsed() { + used = new VariableSet(); if (type == FOR) { incrInstr.fillInGenSet(null, used); if (initInstr != null) initInstr.fillInGenSet(null, used); } cond.fillInGenSet(null, used); - VariableSet allUse = (VariableSet) used.clone(); - allUse.unionExact(bodyBlock.propagateUsage()); - return allUse; + return used; } /** diff --git a/jode/jode/flow/RetBlock.java b/jode/jode/flow/RetBlock.java index 18e6171..8bb6ba1 100644 --- a/jode/jode/flow/RetBlock.java +++ b/jode/jode/flow/RetBlock.java @@ -58,11 +58,10 @@ public class RetBlock extends StructuredBlock { return null; } - public VariableSet propagateUsage() { - if (used == null) - used = new VariableSet(); /*XXX*/ + public VariableSet getUsed() { + used = new VariableSet(); used.addElement(local); - return super.propagateUsage(); + return used; } public void dumpInstruction(jode.decompiler.TabbedPrintWriter writer) diff --git a/jode/jode/flow/SequentialBlock.java b/jode/jode/flow/SequentialBlock.java index c84042e..5a9b47d 100644 --- a/jode/jode/flow/SequentialBlock.java +++ b/jode/jode/flow/SequentialBlock.java @@ -168,17 +168,15 @@ public class SequentialBlock extends StructuredBlock { * block (this is not the used set). */ public VariableSet propagateUsage() { - if (used == null) - used = new VariableSet();/*XXX*/ + used = new VariableSet(); VariableSet allUse = new VariableSet(); VariableSet childUse0 = subBlocks[0].propagateUsage(); VariableSet childUse1 = subBlocks[1].propagateUsage(); /* All variables used somewhere inside both sub blocks, are * used in this block, too. * Also the variables used in first block are used in this - * block two, except when it can be declared locally. - * (Note that subBlocks[0].used != childUse0) - */ + * block, except when it can be declared locally. (Note that + * subBlocks[0].used != childUse0) */ used.unionExact(subBlocks[0].used); if (subBlocks[0] instanceof LoopBlock) ((LoopBlock) subBlocks[0]).removeLocallyDeclareable(used); diff --git a/jode/jode/flow/StructuredBlock.java b/jode/jode/flow/StructuredBlock.java index 7e49248..87e582d 100644 --- a/jode/jode/flow/StructuredBlock.java +++ b/jode/jode/flow/StructuredBlock.java @@ -339,18 +339,20 @@ public abstract class StructuredBlock { return false; } + public VariableSet getUsed() { + return new VariableSet(); + } + /** * Propagate the used set. Initially the used block contains the - * local that are in some expression directly in this block. This - * will extend the set, so that a variable is used if it is used in - * at least two sub blocks. + * local that are used in some expression directly in this block. + * This will extend the set, so that a variable is used if it is + * used in at least two sub blocks. * * @return all locals that are used in this block or in some sub - * block (this is not the used set). - */ + * block (this is not the used set). */ public VariableSet propagateUsage() { - if (used == null) - used = new VariableSet(); /*XXX*/ + used = getUsed(); StructuredBlock[] subs = getSubBlocks(); VariableSet allUse = (VariableSet) used.clone(); for (int i=0; i