getUsed vs. propagateUsage

git-svn-id: https://svn.code.sf.net/p/jode/code/trunk@817 379699f6-c40d-0410-875b-85095c16579e
stable
jochen 26 years ago
parent f0aea2b5ad
commit 328612fb07
  1. 7
      jode/jode/flow/IfThenElseBlock.java
  2. 7
      jode/jode/flow/InstructionContainer.java
  3. 9
      jode/jode/flow/LoopBlock.java
  4. 7
      jode/jode/flow/RetBlock.java
  5. 8
      jode/jode/flow/SequentialBlock.java
  6. 16
      jode/jode/flow/StructuredBlock.java
  7. 7
      jode/jode/flow/SwitchBlock.java
  8. 13
      jode/jode/flow/SynchronizedBlock.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;
}
/**

@ -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() {

@ -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;
}
/**

@ -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)

@ -168,17 +168,15 @@ public class SequentialBlock extends StructuredBlock {
* block (this is <i>not</i> 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);

@ -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 <i>not</i> the used set).
*/
* block (this is <i>not</i> 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<subs.length; i++) {

@ -183,13 +183,6 @@ implements BreakableBlock {
return getNextFlowBlock();
}
public VariableSet propagateUsage() {
if (used == null)
used = new VariableSet(); /*XXX*/
instr.fillInGenSet(null, used);
return super.propagateUsage();
}
public void dumpInstruction(TabbedPrintWriter writer)
throws java.io.IOException
{

@ -70,12 +70,13 @@ public class SynchronizedBlock extends StructuredBlock {
return true;
}
public void dumpDeclaration(TabbedPrintWriter writer, LocalInfo local)
throws java.io.IOException
{
if (local.getLocalInfo() != this.local.getLocalInfo()
|| object == null)
super.dumpDeclaration(writer, local);
public VariableSet getUsed() {
VariableSet used = new VariableSet();
if (object != null)
object.fillInGenSet(null, used);
else
used.addElement(local);
return used;
}
public void dumpInstruction(TabbedPrintWriter writer)

Loading…
Cancel
Save