use SimpleMap instead of SimpleDictionary

git-svn-id: https://svn.code.sf.net/p/jode/code/trunk@936 379699f6-c40d-0410-875b-85095c16579e
stable
jochen 26 years ago
parent 2e002c0470
commit 6280493dc3
  1. 59
      jode/jode/flow/FlowBlock.java
  2. 41
      jode/jode/flow/TransformExceptionHandlers.java

@ -26,9 +26,18 @@ import jode.decompiler.MethodAnalyzer;
import jode.decompiler.LocalInfo;
import jode.expr.Expression;
import jode.expr.CombineableOperator;
import jode.util.SimpleDictionary;
import jode.util.SimpleMap;
import jode.util.SimpleSet;
///#ifdef JDK12
///import java.util.Map;
///import java.util.Iterator;
///#else
import jode.util.Map;
import jode.util.Iterator;
///#endif
/**
* A flow block is the structure of which the flow graph consists. A
* flow block contains structured code together with some conditional
@ -100,11 +109,11 @@ public class FlowBlock {
/**
* This contains a map of all successing flow blocks and there
* jumps. The key of this dictionary are the flow blocks, while
* jumps. The key of this map are the flow blocks, while
* the elements is the first jump to that flow block. The other
* jumps are accessible via the jump.next field.
*/
Dictionary successors = new SimpleDictionary();
Map successors = new SimpleMap();
/**
* This is a vector of flow blocks, which reference this block.
@ -566,11 +575,11 @@ public class FlowBlock {
void mergeSuccessors(FlowBlock succ) {
/* Merge the sucessors from the successing flow block
*/
Enumeration keys = succ.successors.keys();
Enumeration succs = succ.successors.elements();
while (keys.hasMoreElements()) {
FlowBlock dest = (FlowBlock) keys.nextElement();
Jump hisJumps = (Jump) succs.nextElement();
Iterator iter = succ.successors.entrySet().iterator();
while (iter.hasNext()) {
Map.Entry entry = (Map.Entry) iter.next();
FlowBlock dest = (FlowBlock) entry.getKey();
Jump hisJumps = (Jump) entry.getValue();
Jump myJumps = (Jump) successors.get(dest);
if (dest != END_OF_METHOD)
@ -646,9 +655,9 @@ public class FlowBlock {
/* The gen/kill sets must be updated for every jump
* in the other block */
Enumeration succSuccs = successor.successors.elements();
while (succSuccs.hasMoreElements()) {
Jump succJumps = (Jump) succSuccs.nextElement();
Iterator succSuccs = successor.successors.values().iterator();
while (succSuccs.hasNext()) {
Jump succJumps = (Jump) succSuccs.next();
for (; succJumps != null; succJumps = succJumps.next) {
succJumps.gen.mergeGenKill(gens, succJumps.kill);
@ -703,14 +712,14 @@ public class FlowBlock {
if (last.outer != null)
throw new AssertError("Inconsistency");
Enumeration keys = successors.keys();
Enumeration succs = successors.elements();
while (keys.hasMoreElements()) {
FlowBlock dest = (FlowBlock) keys.nextElement();
Iterator iter = successors.entrySet().iterator();
while (iter.hasNext()) {
Map.Entry entry = (Map.Entry) iter.next();
FlowBlock dest = (FlowBlock) entry.getKey();
if (dest.predecessors.contains(this) == (dest == END_OF_METHOD))
throw new AssertError("Inconsistency");
Jump jumps = (Jump)succs.nextElement();
Jump jumps = (Jump)entry.getValue();
if (jumps == null)
throw new AssertError("Inconsistency");
@ -1159,10 +1168,10 @@ public class FlowBlock {
*/
FlowBlock getSuccessor(int start, int end) {
/* search successor with smallest addr. */
Enumeration keys = successors.keys();
Iterator keys = successors.keySet().iterator();
FlowBlock succ = null;
while (keys.hasMoreElements()) {
FlowBlock fb = (FlowBlock) keys.nextElement();
while (keys.hasNext()) {
FlowBlock fb = (FlowBlock) keys.next();
if (fb.addr < start || fb.addr >= end || fb == this)
continue;
if (succ == null || fb.addr < succ.addr) {
@ -1451,9 +1460,9 @@ public class FlowBlock {
throw new jode.AssertError("initial stack is null");
stackMap = initialStack;
block.mapStackToLocal(initialStack);
Enumeration enum = successors.elements();
while (enum.hasMoreElements()) {
Jump jumps = (Jump) enum.nextElement();
Iterator iter = successors.values().iterator();
while (iter.hasNext()) {
Jump jumps = (Jump) iter.next();
VariableStack stack;
FlowBlock succ = jumps.destination;
if (succ == END_OF_METHOD)
@ -1477,9 +1486,9 @@ public class FlowBlock {
return;
stackMap = null;
block.removePush();
Enumeration enum = successors.keys();
while (enum.hasMoreElements()) {
FlowBlock succ = (FlowBlock)enum.nextElement();
Iterator iter = successors.keySet().iterator();
while (iter.hasNext()) {
FlowBlock succ = (FlowBlock)iter.next();
succ.removePush();
}
}

@ -24,7 +24,13 @@ import jode.type.Type;
import jode.decompiler.LocalInfo;
import jode.expr.*;
import java.util.Enumeration;
///#ifdef JDK12
///import java.util.Map;
///import java.util.Iterator;
///#else
import jode.util.Map;
import jode.util.Iterator;
///#endif
/**
*
@ -124,7 +130,7 @@ public class TransformExceptionHandlers {
* try {
* a = 5 / (a=0);
* } catch (DivideByZeroException ex) {
* System.err.println(a);
* System.out.println(a);
* }
* </pre>
*
@ -142,9 +148,9 @@ public class TransformExceptionHandlers {
/* The gen/kill sets must be updated for every jump
* in the catch block */
Enumeration succs = catchFlow.successors.elements();
while (succs.hasMoreElements()) {
for (Jump succJumps = (Jump) succs.nextElement();
Iterator succs = catchFlow.successors.values().iterator();
while (succs.hasNext()) {
for (Jump succJumps = (Jump) succs.next();
succJumps != null; succJumps = succJumps.next) {
succJumps.gen.mergeGenKill(gens, succJumps.kill);
}
@ -303,11 +309,11 @@ public class TransformExceptionHandlers {
}
public void checkAndRemoveJSR(FlowBlock tryFlow, FlowBlock subRoutine) {
Enumeration keys = tryFlow.successors.keys();
Enumeration succs = tryFlow.successors.elements();
while (keys.hasMoreElements()) {
Jump jumps = (Jump) succs.nextElement();
if (keys.nextElement() == subRoutine)
Iterator iter = tryFlow.successors.entrySet().iterator();
while (iter.hasNext()) {
Map.Entry entry = (Map.Entry) iter.next();
Jump jumps = (Jump) entry.getValue();
if (entry.getKey() == subRoutine)
continue;
for ( ; jumps != null; jumps = jumps.next) {
@ -379,10 +385,10 @@ public class TransformExceptionHandlers {
public void checkAndRemoveMonitorExit(FlowBlock tryFlow, LocalInfo local,
int startMonExit, int endMonExit) {
FlowBlock subRoutine = null;
Enumeration succs = tryFlow.successors.elements();
Iterator succs = tryFlow.successors.values().iterator();
dest_loop:
while (succs.hasMoreElements()) {
for (Jump jumps = (Jump) succs.nextElement();
while (succs.hasNext()) {
for (Jump jumps = (Jump) succs.next();
jumps != null; jumps = jumps.next) {
StructuredBlock prev = jumps.prev;
@ -724,16 +730,17 @@ public class TransformExceptionHandlers {
FlowBlock succ = (firstInstr.jump != null) ?
firstInstr.jump.destination : null;
boolean hasExit = false;
Enumeration keys = tryFlow.successors.keys();
while (keys.hasMoreElements()) {
Object key = keys.nextElement();
Iterator iter = tryFlow.successors.entrySet().iterator();
while (iter.hasNext()) {
Map.Entry entry = (Map.Entry) iter.next();
Object key = entry.getKey();
if (key == succ)
continue;
if (key != FlowBlock.END_OF_METHOD) {
/* There is another exit in the try block, bad */
return false;
}
for (Jump throwJumps = (Jump) tryFlow.successors.get(key);
for (Jump throwJumps = (Jump) entry.getValue();
throwJumps != null; throwJumps = throwJumps.next) {
if (!(throwJumps.prev instanceof ThrowBlock)) {
/* There is a return exit in the try block */

Loading…
Cancel
Save