new lvt handling

git-svn-id: https://svn.code.sf.net/p/jode/code/trunk@669 379699f6-c40d-0410-875b-85095c16579e
stable
jochen 26 years ago
parent e758d5a1a2
commit 91d56f235f
  1. 44
      jode/jode/decompiler/LocalVariableRangeList.java
  2. 6
      jode/jode/decompiler/LocalVariableTable.java

@ -23,31 +23,14 @@ import jode.type.Type;
public class LocalVariableRangeList { public class LocalVariableRangeList {
class MyLocalInfo extends LocalInfo { LocalVarEntry list = null;
int startAddr;
int endAddr;
MyLocalInfo next;
MyLocalInfo(int slot, int s, int e, String n, Type t) { LocalVariableRangeList() {
super (slot);
startAddr = s;
endAddr = e;
setName(n);
setType(t);
next = null;
}
}
MyLocalInfo list = null;
int slot;
LocalVariableRangeList(int slot) {
this.slot = slot;
} }
private void add(MyLocalInfo li) { private void add(LocalVarEntry li) {
MyLocalInfo prev = null; LocalVarEntry prev = null;
MyLocalInfo next = list; LocalVarEntry next = list;
while (next != null && next.endAddr < li.startAddr) { while (next != null && next.endAddr < li.startAddr) {
prev = next; prev = next;
next = next.next; next = next.next;
@ -55,8 +38,8 @@ public class LocalVariableRangeList {
/* prev.endAddr < li.startAddr <= next.endAddr /* prev.endAddr < li.startAddr <= next.endAddr
*/ */
if (next != null && li.endAddr >= next.startAddr) { if (next != null && li.endAddr >= next.startAddr) {
if (next.getType().equals(li.getType()) if (next.type.equals(li.type)
&& next.getName().equals(li.getName())) { && next.name.equals(li.name)) {
/* Same type, same name and overlapping range. /* Same type, same name and overlapping range.
* This is the same local: extend next to the common * This is the same local: extend next to the common
* range and don't add li. * range and don't add li.
@ -74,24 +57,23 @@ public class LocalVariableRangeList {
prev.next = li; prev.next = li;
} }
private LocalInfo find(int addr) { private LocalVarEntry find(int addr) {
MyLocalInfo li = list; LocalVarEntry li = list;
while (li != null && li.endAddr < addr) while (li != null && li.endAddr < addr)
li = li.next; li = li.next;
if (li == null || li.startAddr > addr /* XXX addr+1? weired XXX */) { if (li == null || li.startAddr > addr) {
LocalInfo temp = new LocalInfo(slot); return null;
return temp;
} }
return li; return li;
} }
public void addLocal(int startAddr, int endAddr, public void addLocal(int startAddr, int endAddr,
String name, Type type) { String name, Type type) {
MyLocalInfo li = new MyLocalInfo(slot,startAddr,endAddr,name,type); LocalVarEntry li = new LocalVarEntry(startAddr,endAddr,name,type);
add (li); add (li);
} }
public LocalInfo getInfo(int addr) { public LocalVarEntry getInfo(int addr) {
return find(addr); return find(addr);
} }
} }

@ -29,16 +29,16 @@ public class LocalVariableTable {
public LocalVariableTable(int maxLocals, LocalVariableInfo[] lvt) { public LocalVariableTable(int maxLocals, LocalVariableInfo[] lvt) {
locals = new LocalVariableRangeList[maxLocals]; locals = new LocalVariableRangeList[maxLocals];
for (int i=0; i < maxLocals; i++) for (int i=0; i < maxLocals; i++)
locals[i] = new LocalVariableRangeList(i); locals[i] = new LocalVariableRangeList();
for (int i=0; i<lvt.length; i++) for (int i=0; i<lvt.length; i++)
locals[lvt[i].slot].addLocal(lvt[i].start.addr, lvt[i].end.addr, locals[lvt[i].slot].addLocal(lvt[i].start.addr, lvt[i].end.addr,
lvt[i].name, Type.tType(lvt[i].type)); lvt[i].name, Type.tType(lvt[i].type));
} }
public LocalVariableRangeList getLocal(int slot) public LocalVarEntry getLocal(int slot, int addr)
throws ArrayIndexOutOfBoundsException throws ArrayIndexOutOfBoundsException
{ {
return locals[slot]; return locals[slot].getInfo(addr);
} }
} }

Loading…
Cancel
Save