1 19 20 package jode.decompiler; 21 import jode.GlobalOptions; 22 import jode.type.Type; 23 24 public class LocalVariableRangeList { 25 26 LocalVarEntry list = null; 27 28 LocalVariableRangeList() { 29 } 30 31 private void add(LocalVarEntry li) { 32 LocalVarEntry prev = null; 33 LocalVarEntry next = list; 34 while (next != null && next.endAddr < li.startAddr) { 35 prev = next; 36 next = next.next; 37 } 38 40 if (next != null && li.endAddr >= next.startAddr) { 41 if (next.type.equals(li.type) 42 && next.name.equals(li.name)) { 43 47 next.startAddr = Math.min(next.startAddr, li.startAddr); 48 next.endAddr = Math.max(next.endAddr, li.endAddr); 49 return; 50 } 51 GlobalOptions.err.println("warning: non disjoint locals"); 52 } 53 li.next = next; 54 if (prev == null) 55 list = li; 56 else 57 prev.next = li; 58 } 59 60 private LocalVarEntry find(int addr) { 61 LocalVarEntry li = list; 62 while (li != null && li.endAddr < addr) 63 li = li.next; 64 if (li == null || li.startAddr > addr) { 65 return null; 66 } 67 return li; 68 } 69 70 public void addLocal(int startAddr, int endAddr, 71 String name, Type type) { 72 LocalVarEntry li = new LocalVarEntry(startAddr,endAddr,name,type); 73 add (li); 74 } 75 76 public LocalVarEntry getInfo(int addr) { 77 return find(addr); 78 } 79 } 80 | Popular Tags |