From e5eb445b7b2bc97a882f19de42e51c44a8fe1378 Mon Sep 17 00:00:00 2001 From: jochen Date: Fri, 5 Feb 1999 12:52:51 +0000 Subject: [PATCH] allow second block to see all variables declared in first block git-svn-id: https://svn.code.sf.net/p/jode/code/trunk@185 379699f6-c40d-0410-875b-85095c16579e --- jode/jode/flow/SequentialBlock.java | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/jode/jode/flow/SequentialBlock.java b/jode/jode/flow/SequentialBlock.java index 17184bb..4f9a30e 100644 --- a/jode/jode/flow/SequentialBlock.java +++ b/jode/jode/flow/SequentialBlock.java @@ -100,22 +100,18 @@ public class SequentialBlock extends StructuredBlock { * any local Variable, but lets the first sub block do this. */ declare = new VariableSet(); - /* First we can forget any variable that is already declared. - */ - used.subtractExact(done); /* Second, tell the first sub block that he must declare all - * variables _we_ use. */ + * variables _we_ use. + */ subBlocks[0].used.unionExact(used); subBlocks[0].makeDeclaration(done); - /* Now add the variables to the done set, since the first - * sub block has declared them. - */ - done.unionExact(used); - subBlocks[1].makeDeclaration(done); - /* Now undo the change to done. Note that the second instruction - * made done and used disjunct. - */ - done.subtractExact(used); + + /* 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. */ + VariableSet doneFirst = (VariableSet) done.clone(); + doneFirst.unionExact(subBlocks[0].used); + subBlocks[1].makeDeclaration(doneFirst); } public void dumpInstruction(TabbedPrintWriter writer)