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. 51
      jode/jode/decompiler/LocalVariableHash.java

@ -1,44 +1,41 @@
package jode;
import sun.tools.java.Type;
import sun.tools.java.Identifier;
import java.util.Hashtable;
import java.util.Enumeration;
public class LocalVariableHash implements LocalVariable {
Hashtable locals;
int slot;
public LocalVariableHash(int slot) {
locals = new Hashtable();
this.slot = slot;
}
private find(int addr) {
public LocalInfo getInfo(int addr) {
LocalInfo li = (LocalInfo) locals.get(new Integer(addr));
if (li == null) {
li = new LocalInfo();
System.err.println("creating "+slot+": "+addr);
li = new LocalInfo(slot);
locals.put(new Integer(addr), 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) {
LocalInfo li1 = find(addr1);
LocalInfo li2 = find(addr2);
li1.type = UnknownType.commonType(li1.type, li2.type);
Enumeration keys = locals.keys();
while (keys.hasMoreElements()) {
Object key = keys.nextElement();
if (locals.get(key) == li2)
locals.put(key, li1);
}
System.err.println("combining "+slot+": "+addr1+" and "+addr2);
LocalInfo li1 = getInfo(addr1);
LocalInfo li2 = (LocalInfo) locals.get(new Integer(addr2));
if (li2 != null) {
li1.type = UnknownType.commonType(li1.type, li2.type);
Enumeration keys = locals.keys();
while (keys.hasMoreElements()) {
Object key = keys.nextElement();
if (locals.get(key) == li2)
locals.put(key, li1);
}
} else
locals.put(new Integer(addr2), li1);
}
}

Loading…
Cancel
Save