git-svn-id: https://svn.code.sf.net/p/jode/code/trunk@3 379699f6-c40d-0410-875b-85095c16579estable
parent
55a5ea33d9
commit
78bb1b0a22
@ -1,44 +1,41 @@ |
|||||||
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; |
||||||
|
|
||||||
|
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)); |
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); |
||||||
li1.type = UnknownType.commonType(li1.type, li2.type); |
LocalInfo li2 = (LocalInfo) locals.get(new Integer(addr2)); |
||||||
Enumeration keys = locals.keys(); |
if (li2 != null) { |
||||||
while (keys.hasMoreElements()) { |
li1.type = UnknownType.commonType(li1.type, li2.type); |
||||||
Object key = keys.nextElement(); |
Enumeration keys = locals.keys(); |
||||||
if (locals.get(key) == li2) |
while (keys.hasMoreElements()) { |
||||||
locals.put(key, li1); |
Object key = keys.nextElement(); |
||||||
} |
if (locals.get(key) == li2) |
||||||
|
locals.put(key, li1); |
||||||
|
} |
||||||
|
} else |
||||||
|
locals.put(new Integer(addr2), li1); |
||||||
} |
} |
||||||
} |
} |
||||||
|
Loading…
Reference in new issue