reworked the local variable declaration

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

@ -96,26 +96,22 @@ public class SequentialBlock extends StructuredBlock {
* @param done The set of the already declare variables. * @param done The set of the already declare variables.
*/ */
public void makeDeclaration(VariableSet done) { public void makeDeclaration(VariableSet done) {
/* A sequential block is special, since it doesn't declare if (subBlocks[0] instanceof InstructionBlock) {
* any local Variable, but lets the first sub block do this. /* Special case: If the first block is an InstructionBlock,
* it can declare the variable it uses for us.
*
* Now add the variables used in the first block to the done
* set of the second block, since the first sub block has
* declared them.
*/ */
declare = new VariableSet(); declare = new VariableSet();
/* Second, tell the first sub block that he must declare all
* variables _we_ use.
*/
subBlocks[0].used.unionExact(used);
subBlocks[0].makeDeclaration(done);
VariableSet doneFirst; subBlocks[0].makeDeclaration(done);
if (subBlocks[0] instanceof InstructionBlock) { done.unionExact(subBlocks[0].declare);
/* Now add the variables used in the first block to the done subBlocks[1].makeDeclaration(done);
* set of the second block, since the first sub block has done.subtractExact(subBlocks[0].declare);
* declared them. */
doneFirst = (VariableSet) done.clone();
doneFirst.unionExact(subBlocks[0].used);
} else } else
doneFirst = done; super.makeDeclaration(done);
subBlocks[1].makeDeclaration(doneFirst);
} }
public void dumpInstruction(TabbedPrintWriter writer) public void dumpInstruction(TabbedPrintWriter writer)

Loading…
Cancel
Save