Another bug fix for declarations

git-svn-id: https://svn.code.sf.net/p/jode/code/trunk@685 379699f6-c40d-0410-875b-85095c16579e
stable
jochen 26 years ago
parent 8e74989f48
commit 2cd4d25792
  1. 16
      jode/jode/flow/InstructionBlock.java
  2. 14
      jode/jode/flow/SequentialBlock.java

@ -102,11 +102,11 @@ public class InstructionBlock extends InstructionContainer {
* variable. In that case mark this as declaration and return the
* variable.
*/
public LocalInfo checkDeclaration(VariableSet done) {
public void checkDeclaration(VariableSet declareSet) {
if (instr.getOperator() instanceof LocalStoreOperator) {
LocalInfo local =
((LocalStoreOperator) instr.getOperator()).getLocalInfo();
if (!done.contains(local)) {
if (declareSet.contains(local)) {
/* Special case: This is a variable assignment, and
* the variable has not been declared before. We can
* change this to a initializing variable declaration.
@ -115,10 +115,9 @@ public class InstructionBlock extends InstructionContainer {
if (instr instanceof ComplexExpression)
((ComplexExpression) instr)
.getSubExpressions()[0].makeInitializer();
return local;
declareSet.removeElement(local);
}
}
return null;
}
/**
@ -128,13 +127,8 @@ public class InstructionBlock extends InstructionContainer {
* @param done The set of the already declare variables.
*/
public void makeDeclaration(VariableSet done) {
LocalInfo local = checkDeclaration(done);
if (local != null) {
done.addElement(local);
super.makeDeclaration(done);
done.removeElement(local);
} else
super.makeDeclaration(done);
super.makeDeclaration(done);
checkDeclaration(declare);
}
public void dumpInstruction(TabbedPrintWriter writer)

@ -166,21 +166,13 @@ public class SequentialBlock extends StructuredBlock {
* @param done The set of the already declare variables.
*/
public void makeDeclaration(VariableSet done) {
super.makeDeclaration(done);
if (subBlocks[0] instanceof InstructionBlock) {
/* Special case: If the first block is an InstructionBlock,
* it can declare the variable it writes to in a special way
* and that declaration will last for the second sub block.
* it can declare the variable it writes to in a special way.
*/
LocalInfo local =
((InstructionBlock) subBlocks[0]).checkDeclaration(done);
if (local != null) {
done.addElement(local);
super.makeDeclaration(done);
done.removeElement(local);
return;
}
((InstructionBlock) subBlocks[0]).checkDeclaration(this.declare);
}
super.makeDeclaration(done);
}
public void dumpInstruction(TabbedPrintWriter writer)

Loading…
Cancel
Save