|
|
@ -25,7 +25,11 @@ import jode.decompiler.LocalInfo; |
|
|
|
import jode.decompiler.Declarable; |
|
|
|
import jode.decompiler.Declarable; |
|
|
|
import jode.util.SimpleSet; |
|
|
|
import jode.util.SimpleSet; |
|
|
|
|
|
|
|
|
|
|
|
import java.util.Enumeration; |
|
|
|
///#ifdef JDK12
|
|
|
|
|
|
|
|
///import java.util.Iterator;
|
|
|
|
|
|
|
|
///#else
|
|
|
|
|
|
|
|
import jode.util.Iterator; |
|
|
|
|
|
|
|
///#endif
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* A structured block is the building block of the source programm. |
|
|
|
* A structured block is the building block of the source programm. |
|
|
@ -364,7 +368,6 @@ public abstract class StructuredBlock { |
|
|
|
/* All variables used in more than one sub blocks, are |
|
|
|
/* All variables used in more than one sub blocks, are |
|
|
|
* used in this block, too. |
|
|
|
* used in this block, too. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
Enumeration enum = childUse.elements(); |
|
|
|
|
|
|
|
SimpleSet intersection = new SimpleSet(); |
|
|
|
SimpleSet intersection = new SimpleSet(); |
|
|
|
intersection.addAll(childUse); |
|
|
|
intersection.addAll(childUse); |
|
|
|
intersection.retainAll(allUse); |
|
|
|
intersection.retainAll(allUse); |
|
|
@ -441,14 +444,12 @@ public abstract class StructuredBlock { |
|
|
|
* @param done The set of the already declare variables. |
|
|
|
* @param done The set of the already declare variables. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void makeDeclaration(SimpleSet done) { |
|
|
|
public void makeDeclaration(SimpleSet done) { |
|
|
|
// System.err.println("makeDeclaration: done = "+done);
|
|
|
|
|
|
|
|
this.done = (SimpleSet) done.clone(); |
|
|
|
this.done = (SimpleSet) done.clone(); |
|
|
|
declare = new SimpleSet(); |
|
|
|
declare = new SimpleSet(); |
|
|
|
java.util.Enumeration enum = used.elements(); |
|
|
|
Iterator iter = used.iterator(); |
|
|
|
// System.err.println("makeDeclaration: used = "+used);
|
|
|
|
|
|
|
|
next_used: |
|
|
|
next_used: |
|
|
|
while (enum.hasMoreElements()) { |
|
|
|
while (iter.hasNext()) { |
|
|
|
Declarable declarable = (Declarable) enum.nextElement(); |
|
|
|
Declarable declarable = (Declarable) iter.next(); |
|
|
|
|
|
|
|
|
|
|
|
// Check if this is already declared.
|
|
|
|
// Check if this is already declared.
|
|
|
|
if (done.contains(declarable)) |
|
|
|
if (done.contains(declarable)) |
|
|
@ -465,9 +466,9 @@ public abstract class StructuredBlock { |
|
|
|
|
|
|
|
|
|
|
|
// Merge with all locals in this block, that use the same
|
|
|
|
// Merge with all locals in this block, that use the same
|
|
|
|
// slot and have compatible types and names.
|
|
|
|
// slot and have compatible types and names.
|
|
|
|
Enumeration doneEnum = done.elements(); |
|
|
|
Iterator doneIter = done.iterator(); |
|
|
|
while (doneEnum.hasMoreElements()) { |
|
|
|
while (doneIter.hasNext()) { |
|
|
|
Declarable previous = (Declarable) doneEnum.nextElement(); |
|
|
|
Declarable previous = (Declarable) doneIter.next(); |
|
|
|
if (!(previous instanceof LocalInfo)) |
|
|
|
if (!(previous instanceof LocalInfo)) |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
LocalInfo prevLocal = (LocalInfo) previous; |
|
|
|
LocalInfo prevLocal = (LocalInfo) previous; |
|
|
@ -501,9 +502,9 @@ public abstract class StructuredBlock { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (declarable.getName() != null) { |
|
|
|
if (declarable.getName() != null) { |
|
|
|
Enumeration doneEnum = done.elements(); |
|
|
|
Iterator doneIter = done.iterator(); |
|
|
|
while (doneEnum.hasMoreElements()) { |
|
|
|
while (doneIter.hasNext()) { |
|
|
|
Declarable previous = (Declarable) doneEnum.nextElement(); |
|
|
|
Declarable previous = (Declarable) doneIter.next(); |
|
|
|
if (declarable.getName().equals(previous.getName())) { |
|
|
|
if (declarable.getName().equals(previous.getName())) { |
|
|
|
/* A name conflict happened. */ |
|
|
|
/* A name conflict happened. */ |
|
|
|
declarable.makeNameUnique(); |
|
|
|
declarable.makeNameUnique(); |
|
|
@ -513,7 +514,6 @@ public abstract class StructuredBlock { |
|
|
|
done.add(declarable); |
|
|
|
done.add(declarable); |
|
|
|
declare.add(declarable); |
|
|
|
declare.add(declarable); |
|
|
|
} |
|
|
|
} |
|
|
|
// System.err.println("makeDeclaration: declare = "+declare);
|
|
|
|
|
|
|
|
StructuredBlock[] subs = getSubBlocks(); |
|
|
|
StructuredBlock[] subs = getSubBlocks(); |
|
|
|
for (int i=0; i<subs.length; i++) |
|
|
|
for (int i=0; i<subs.length; i++) |
|
|
|
subs[i].makeDeclaration(done); |
|
|
|
subs[i].makeDeclaration(done); |
|
|
@ -604,9 +604,9 @@ public abstract class StructuredBlock { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (declare != null) { |
|
|
|
if (declare != null) { |
|
|
|
java.util.Enumeration enum = declare.elements(); |
|
|
|
Iterator iter = declare.iterator(); |
|
|
|
while (enum.hasMoreElements()) { |
|
|
|
while (iter.hasNext()) { |
|
|
|
Declarable decl = (Declarable) enum.nextElement(); |
|
|
|
Declarable decl = (Declarable) iter.next(); |
|
|
|
decl.dumpDeclaration(writer); |
|
|
|
decl.dumpDeclaration(writer); |
|
|
|
writer.println(";"); |
|
|
|
writer.println(";"); |
|
|
|
} |
|
|
|
} |
|
|
|