From 0e55e234a6f82b8a919c66bc432a4f9586a9d55e Mon Sep 17 00:00:00 2001 From: jochen Date: Fri, 12 Feb 1999 15:32:32 +0000 Subject: [PATCH] reworked the local variable declaration git-svn-id: https://svn.code.sf.net/p/jode/code/trunk@271 379699f6-c40d-0410-875b-85095c16579e --- jode/jode/flow/SequentialBlock.java | 30 +++++++++++++---------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/jode/jode/flow/SequentialBlock.java b/jode/jode/flow/SequentialBlock.java index 7f86a36..49b0445 100644 --- a/jode/jode/flow/SequentialBlock.java +++ b/jode/jode/flow/SequentialBlock.java @@ -96,26 +96,22 @@ public class SequentialBlock extends StructuredBlock { * @param done The set of the already declare variables. */ public void makeDeclaration(VariableSet done) { - /* A sequential block is special, since it doesn't declare - * any local Variable, but lets the first sub block do this. - */ - 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; if (subBlocks[0] instanceof InstructionBlock) { - /* Now add the variables used in the first block to the done + /* 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. */ - doneFirst = (VariableSet) done.clone(); - doneFirst.unionExact(subBlocks[0].used); + * declared them. + */ + declare = new VariableSet(); + + subBlocks[0].makeDeclaration(done); + done.unionExact(subBlocks[0].declare); + subBlocks[1].makeDeclaration(done); + done.subtractExact(subBlocks[0].declare); } else - doneFirst = done; - subBlocks[1].makeDeclaration(doneFirst); + super.makeDeclaration(done); } public void dumpInstruction(TabbedPrintWriter writer)