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

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

Loading…
Cancel
Save