git-svn-id: https://svn.code.sf.net/p/jode/code/trunk@3 379699f6-c40d-0410-875b-85095c16579e
stable
jochen 27 years ago
parent 55a5ea33d9
commit 78bb1b0a22
  1. 37
      jode/jode/decompiler/LocalVariableHash.java

@ -1,38 +1,33 @@
package jode; package jode;
import sun.tools.java.Type; import sun.tools.java.Type;
import sun.tools.java.Identifier; import sun.tools.java.Identifier;
import java.util.Hashtable;
import java.util.Enumeration;
public class LocalVariableHash implements LocalVariable { public class LocalVariableHash implements LocalVariable {
Hashtable locals; Hashtable locals;
int slot;
private find(int addr) { public LocalVariableHash(int slot) {
locals = new Hashtable();
this.slot = slot;
}
public LocalInfo getInfo(int addr) {
LocalInfo li = (LocalInfo) locals.get(new Integer(addr)); LocalInfo li = (LocalInfo) locals.get(new Integer(addr));
if (li == null) { if (li == null) {
li = new LocalInfo(); System.err.println("creating "+slot+": "+addr);
li = new LocalInfo(slot);
locals.put(new Integer(addr), li); locals.put(new Integer(addr), li);
} }
return li; return li;
} }
public Identifier getName(int addr) {
LocalInfo li = find(addr);
return li.name;
}
public Type getType(int addr) {
LocalInfo li = find(addr);
return li.type;
}
public Type setType(int addr, Type type) {
LocalInfo li = find(addr);
li.type = UnknownType.commonType(li.type, type);
return li.type;
}
public void combine(int addr1, int addr2) { public void combine(int addr1, int addr2) {
LocalInfo li1 = find(addr1); System.err.println("combining "+slot+": "+addr1+" and "+addr2);
LocalInfo li2 = find(addr2); LocalInfo li1 = getInfo(addr1);
LocalInfo li2 = (LocalInfo) locals.get(new Integer(addr2));
if (li2 != null) {
li1.type = UnknownType.commonType(li1.type, li2.type); li1.type = UnknownType.commonType(li1.type, li2.type);
Enumeration keys = locals.keys(); Enumeration keys = locals.keys();
while (keys.hasMoreElements()) { while (keys.hasMoreElements()) {
@ -40,5 +35,7 @@ public class LocalVariableHash implements LocalVariable {
if (locals.get(key) == li2) if (locals.get(key) == li2)
locals.put(key, li1); locals.put(key, li1);
} }
} else
locals.put(new Integer(addr2), li1);
} }
} }

Loading…
Cancel
Save