getUsed vs. propagateUsage

git-svn-id: https://svn.code.sf.net/p/jode/code/trunk@817 379699f6-c40d-0410-875b-85095c16579e
stable
jochen 25 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(); elseBlock.removePush();
} }
public VariableSet propagateUsage() { public VariableSet getUsed() {
if (used == null) used = new VariableSet();
used = new VariableSet(); /*XXX*/
cond.fillInGenSet(null, used); cond.fillInGenSet(null, used);
return super.propagateUsage(); return used;
} }
/** /**

@ -69,12 +69,11 @@ public abstract class InstructionContainer extends StructuredBlock {
instr.fillInGenSet(in, gen); instr.fillInGenSet(in, gen);
} }
public VariableSet propagateUsage() { public VariableSet getUsed() {
if (used == null) used = new VariableSet();
used = new VariableSet(); /*XXX*/
if (instr != null) if (instr != null)
instr.fillInGenSet(null, used); instr.fillInGenSet(null, used);
return super.propagateUsage(); return used;
} }
public boolean doTransformations() { public boolean doTransformations() {

@ -211,18 +211,15 @@ public class LoopBlock extends StructuredBlock implements BreakableBlock {
} }
} }
public VariableSet propagateUsage() { public VariableSet getUsed() {
if (used == null) used = new VariableSet();
used = new VariableSet(); /*XXX*/
if (type == FOR) { if (type == FOR) {
incrInstr.fillInGenSet(null, used); incrInstr.fillInGenSet(null, used);
if (initInstr != null) if (initInstr != null)
initInstr.fillInGenSet(null, used); initInstr.fillInGenSet(null, used);
} }
cond.fillInGenSet(null, used); cond.fillInGenSet(null, used);
VariableSet allUse = (VariableSet) used.clone(); return used;
allUse.unionExact(bodyBlock.propagateUsage());
return allUse;
} }
/** /**

@ -58,11 +58,10 @@ public class RetBlock extends StructuredBlock {
return null; return null;
} }
public VariableSet propagateUsage() { public VariableSet getUsed() {
if (used == null) used = new VariableSet();
used = new VariableSet(); /*XXX*/
used.addElement(local); used.addElement(local);
return super.propagateUsage(); return used;
} }
public void dumpInstruction(jode.decompiler.TabbedPrintWriter writer) 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). * block (this is <i>not</i> the used set).
*/ */
public VariableSet propagateUsage() { public VariableSet propagateUsage() {
if (used == null) used = new VariableSet();
used = new VariableSet();/*XXX*/
VariableSet allUse = new VariableSet(); VariableSet allUse = new VariableSet();
VariableSet childUse0 = subBlocks[0].propagateUsage(); VariableSet childUse0 = subBlocks[0].propagateUsage();
VariableSet childUse1 = subBlocks[1].propagateUsage(); VariableSet childUse1 = subBlocks[1].propagateUsage();
/* All variables used somewhere inside both sub blocks, are /* All variables used somewhere inside both sub blocks, are
* used in this block, too. * used in this block, too.
* Also the variables used in first block are used in this * Also the variables used in first block are used in this
* block two, except when it can be declared locally. * block, except when it can be declared locally. (Note that
* (Note that subBlocks[0].used != childUse0) * subBlocks[0].used != childUse0) */
*/
used.unionExact(subBlocks[0].used); used.unionExact(subBlocks[0].used);
if (subBlocks[0] instanceof LoopBlock) if (subBlocks[0] instanceof LoopBlock)
((LoopBlock) subBlocks[0]).removeLocallyDeclareable(used); ((LoopBlock) subBlocks[0]).removeLocallyDeclareable(used);

@ -339,18 +339,20 @@ public abstract class StructuredBlock {
return false; return false;
} }
public VariableSet getUsed() {
return new VariableSet();
}
/** /**
* Propagate the used set. Initially the used block contains the * Propagate the used set. Initially the used block contains the
* local that are in some expression directly in this block. This * local that are used in some expression directly in this block.
* will extend the set, so that a variable is used if it is used in * This will extend the set, so that a variable is used if it is
* at least two sub blocks. * used in at least two sub blocks.
* *
* @return all locals that are used in this block or in some sub * @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() { public VariableSet propagateUsage() {
if (used == null) used = getUsed();
used = new VariableSet(); /*XXX*/
StructuredBlock[] subs = getSubBlocks(); StructuredBlock[] subs = getSubBlocks();
VariableSet allUse = (VariableSet) used.clone(); VariableSet allUse = (VariableSet) used.clone();
for (int i=0; i<subs.length; i++) { for (int i=0; i<subs.length; i++) {

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

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

Loading…
Cancel
Save