From 4eac3b281effa4075de73b286cc3f99a45ccf4b2 Mon Sep 17 00:00:00 2001 From: jochen Date: Tue, 6 Jul 1999 18:04:33 +0000 Subject: [PATCH] simplify also successing flow blocks on simplify() git-svn-id: https://svn.code.sf.net/p/jode/code/trunk@1033 379699f6-c40d-0410-875b-85095c16579e --- jode/jode/flow/FlowBlock.java | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/jode/jode/flow/FlowBlock.java b/jode/jode/flow/FlowBlock.java index e30c6ab..e932ea5 100644 --- a/jode/jode/flow/FlowBlock.java +++ b/jode/jode/flow/FlowBlock.java @@ -32,9 +32,13 @@ import jode.util.SimpleSet; ///#ifdef JDK12 ///import java.util.Map; ///import java.util.Iterator; +///import java.util.Set; +///import java.util.SimpleSet; ///#else import jode.util.Map; import jode.util.Iterator; +import jode.util.Set; +import jode.util.SimpleSet; ///#endif @@ -1520,8 +1524,29 @@ public class FlowBlock { block.makeDeclaration(declared); } - public void simplify() { + /** + * Simplify all reachable flowblocks, that are not already + * simplified, i.e. that don't occur in doneSet. + */ + private void simplify(Set doneSet) { + if (doneSet.contains(this)) + return; + doneSet.add(this); block.simplify(); + Iterator iter = successors.keySet().iterator(); + while (iter.hasNext()) { + FlowBlock succ = (FlowBlock)iter.next(); + succ.simplify(doneSet); + } + } + + public void simplify() { + if (successors.size() == 0) { + // optimize default path. + block.simplify(); + return; + } + simplify(new SimpleSet()); } /**