startAddr/endAddr instead of start/length

git-svn-id: https://svn.code.sf.net/p/jode/code/trunk@658 379699f6-c40d-0410-875b-85095c16579e
stable
jochen 26 years ago
parent ffdd52fe6e
commit 2f565d8d73
  1. 50
      jode/jode/decompiler/LocalVariableRangeList.java

@ -24,14 +24,14 @@ import jode.type.Type;
public class LocalVariableRangeList { public class LocalVariableRangeList {
class MyLocalInfo extends LocalInfo { class MyLocalInfo extends LocalInfo {
int start; int startAddr;
int length; int endAddr;
MyLocalInfo next; MyLocalInfo next;
MyLocalInfo(int slot, int s, int l, String n, Type t) { MyLocalInfo(int slot, int s, int e, String n, Type t) {
super (slot); super (slot);
start = s; startAddr = s;
length = l; endAddr = e;
setName(n); setName(n);
setType(t); setType(t);
next = null; next = null;
@ -46,48 +46,48 @@ public class LocalVariableRangeList {
} }
private void add(MyLocalInfo li) { private void add(MyLocalInfo li) {
MyLocalInfo before = null; MyLocalInfo prev = null;
MyLocalInfo after = list; MyLocalInfo next = list;
while (after != null && after.start < li.start) { while (next != null && next.endAddr < li.startAddr) {
before = after; prev = next;
after = after.next; next = next.next;
} }
if (after != null && li.start + li.length > after.start) { /* prev.endAddr < li.startAddr <= next.endAddr
if (after.getType().equals(li.getType()) */
&& after.getName().equals(li.getName())) { if (next != null && li.endAddr >= next.startAddr) {
if (next.getType().equals(li.getType())
&& next.getName().equals(li.getName())) {
/* Same type, same name and overlapping range. /* Same type, same name and overlapping range.
* This is the same local: extend after 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.
*/ */
after.length += after.start - li.start; next.startAddr = Math.min(next.startAddr, li.startAddr);
after.start = li.start; next.endAddr = Math.max(next.endAddr, li.endAddr);
if (li.length > after.length)
after.length = li.length;
return; return;
} }
Decompiler.err.println("warning: non disjoint locals"); Decompiler.err.println("warning: non disjoint locals");
} }
li.next = after; li.next = next;
if (before == null) if (prev == null)
list = li; list = li;
else else
before.next = li; prev.next = li;
} }
private LocalInfo find(int addr) { private LocalInfo find(int addr) {
MyLocalInfo li = list; MyLocalInfo li = list;
while (li != null && addr >= li.start+li.length) while (li != null && li.endAddr < addr)
li = li.next; li = li.next;
if (li == null || li.start > addr+1 /* XXX weired XXX */) { if (li == null || li.startAddr > addr /* XXX addr+1? weired XXX */) {
LocalInfo temp = new LocalInfo(slot); LocalInfo temp = new LocalInfo(slot);
return temp; return temp;
} }
return li; return li;
} }
public void addLocal(int start, int length, public void addLocal(int startAddr, int endAddr,
String name, Type type) { String name, Type type) {
MyLocalInfo li = new MyLocalInfo(slot,start,length,name,type); MyLocalInfo li = new MyLocalInfo(slot,startAddr,endAddr,name,type);
add (li); add (li);
} }

Loading…
Cancel
Save