|
|
@ -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) { |
|
|
|
|
|
|
|
super (slot); |
|
|
|
|
|
|
|
startAddr = s; |
|
|
|
|
|
|
|
endAddr = e; |
|
|
|
|
|
|
|
setName(n); |
|
|
|
|
|
|
|
setType(t); |
|
|
|
|
|
|
|
next = null; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MyLocalInfo list = null; |
|
|
|
|
|
|
|
int slot; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LocalVariableRangeList(int slot) { |
|
|
|
LocalVariableRangeList() { |
|
|
|
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); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|