1 19 20 package soot.dava.toolkits.base.finders; 21 22 import java.util.*; 23 import soot.toolkits.graph.*; 24 25 class SwitchNodeGraph implements DirectedGraph 26 { 27 private LinkedList body, heads, tails; 28 private HashMap binding; 29 30 31 public SwitchNodeGraph( List body) 32 { 33 this.body = new LinkedList(); 34 this.body.addAll( body); 35 36 binding = new HashMap(); 37 38 heads = new LinkedList(); 39 tails = new LinkedList(); 40 41 Iterator it = body.iterator(); 42 while (it.hasNext()) { 43 SwitchNode sn = (SwitchNode) it.next(); 44 45 binding.put( sn.get_AugStmt().bsuccs.get(0), sn); 46 sn.reset(); 47 } 48 49 it = body.iterator(); 50 while (it.hasNext()) 51 ((SwitchNode) it.next()).setup_Graph( binding); 52 53 it = body.iterator(); 54 while (it.hasNext()) { 55 SwitchNode sn = (SwitchNode) it.next(); 56 57 if (sn.get_Preds().isEmpty()) 58 heads.add( sn); 59 60 if (sn.get_Succs().isEmpty()) 61 tails.add( sn); 62 } 63 } 64 65 public int size() 66 { 67 return body.size(); 68 } 69 70 public List getHeads() 71 { 72 return heads; 73 } 74 75 public List getTails() 76 { 77 return tails; 78 } 79 80 public List getPredsOf( Object o) 81 { 82 return ((SwitchNode) o).get_Preds(); 83 } 84 85 public List getSuccsOf( Object o) 86 { 87 return ((SwitchNode) o).get_Succs(); 88 } 89 90 public Iterator iterator() 91 { 92 return body.iterator(); 93 } 94 95 public List getBody() 96 { 97 return body; 98 } 99 } 100 | Popular Tags |