bug fix: Declaration in for blocksExpression rework (ComplexExpression removed)

git-svn-id: https://svn.code.sf.net/p/jode/code/trunk@776 379699f6-c40d-0410-875b-85095c16579e
stable
jochen 26 years ago
parent d162b4f6b4
commit f368f4ce33
  1. 26
      jode/jode/flow/SequentialBlock.java

@ -21,6 +21,7 @@ package jode.flow;
import jode.decompiler.TabbedPrintWriter; import jode.decompiler.TabbedPrintWriter;
import jode.decompiler.LocalInfo; import jode.decompiler.LocalInfo;
import jode.expr.LocalStoreOperator; import jode.expr.LocalStoreOperator;
import jode.expr.StoreInstruction;
/** /**
* A sequential block combines exactly two structured blocks to a new * A sequential block combines exactly two structured blocks to a new
@ -97,17 +98,17 @@ public class SequentialBlock extends StructuredBlock {
* return. * return.
*/ */
if (first.getInstruction().getOperator() if (first.getInstruction() instanceof StoreInstruction) {
instanceof LocalStoreOperator) { StoreInstruction store
LocalStoreOperator store = (LocalStoreOperator) = (StoreInstruction) first.getInstruction();
first.getInstruction().getOperator(); if (store.getLValue() instanceof LocalStoreOperator
if (store.getLocalInfo().getUseCount() == 2 && (((LocalStoreOperator) store.getLValue())
&& (second.getInstruction().canCombine .getLocalInfo().getUseCount() == 2)
(first.getInstruction()) > 0)) { && (second.getInstruction().canCombine(store) > 0)) {
System.err.println("before: "+first+second); System.err.println("before: "+first+second);
second.setInstruction(second.getInstruction() second.setInstruction(second.getInstruction()
.combine(first.getInstruction())); .combine(store));
System.err.println("after: "+second); System.err.println("after: "+second);
StructuredBlock sb = subBlocks[1]; StructuredBlock sb = subBlocks[1];
sb.moveDefinitions(this, sb); sb.moveDefinitions(this, sb);
@ -173,10 +174,13 @@ public class SequentialBlock extends StructuredBlock {
/* 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. (Note that subBlocks[0].used != childUse0) * block two, except when it can be declared locally.
* (Note that subBlocks[0].used != childUse0)
*/ */
used.unionExact(childUse0.intersectExact(childUse1));
used.unionExact(subBlocks[0].used); used.unionExact(subBlocks[0].used);
if (subBlocks[0] instanceof LoopBlock)
((LoopBlock) subBlocks[0]).removeLocallyDeclareable(used);
used.unionExact(childUse0.intersectExact(childUse1));
allUse.unionExact(childUse0); allUse.unionExact(childUse0);
allUse.unionExact(childUse1); allUse.unionExact(childUse1);
return allUse; return allUse;
@ -191,7 +195,7 @@ public class SequentialBlock extends StructuredBlock {
public void makeDeclaration(VariableSet done) { public void makeDeclaration(VariableSet done) {
super.makeDeclaration(done); super.makeDeclaration(done);
if (subBlocks[0] instanceof InstructionBlock) if (subBlocks[0] instanceof InstructionBlock)
/* A instruction block my declare a variable for us. /* An instruction block may declare a variable for us.
*/ */
((InstructionBlock) subBlocks[0]).checkDeclaration(this.declare); ((InstructionBlock) subBlocks[0]).checkDeclaration(this.declare);
} }

Loading…
Cancel
Save