1 19 20 25 26 27 package soot.jimple.internal; 28 29 import soot.tagkit.*; 30 import soot.*; 31 import soot.jimple.*; 32 import soot.baf.*; 33 import soot.util.*; 34 import java.util.*; 35 36 public class JimpleLocal implements Local, ConvertToBaf 37 { 38 String name; 39 Type type; 40 41 int fixedHashCode; 42 boolean isHashCodeChosen; 43 44 45 public JimpleLocal(String name, Type t) 46 { 47 this.name = name; 48 this.type = t; 49 Scene.v().getLocalNumberer().add( this ); 50 } 51 52 53 public boolean equivTo(Object o) 54 { 55 return this.equals( o ); 56 } 57 58 59 public int equivHashCode() 60 { 61 return name.hashCode() * 101 + type.hashCode() * 17; 62 } 63 64 65 public Object clone() 66 { 67 return new JimpleLocal(name, type); 68 } 69 70 71 public String getName() 72 { 73 return name; 74 } 75 76 77 public void setName(String name) 78 { 79 this.name = name; 80 } 81 82 83 public int hashCode() 84 { 85 if(!isHashCodeChosen) 86 { 87 89 if(name != null & type != null) 90 fixedHashCode = name.hashCode() + 19 * type.hashCode(); 91 else if(name != null) 92 fixedHashCode = name.hashCode(); 93 else if(type != null) 94 fixedHashCode = type.hashCode(); 95 else 96 fixedHashCode = 1; 97 98 isHashCodeChosen = true; 99 } 100 101 return fixedHashCode; 102 } 103 104 105 public Type getType() 106 { 107 return type; 108 } 109 110 111 public void setType(Type t) 112 { 113 this.type = t; 114 } 115 116 public String toString() 117 { 118 return getName(); 119 } 120 121 public void toString(UnitPrinter up) { 122 up.local(this); 123 } 124 125 public List getUseBoxes() 126 { 127 return AbstractUnit.emptyList; 128 } 129 130 public void apply(Switch sw) 131 { 132 ((JimpleValueSwitch) sw).caseLocal(this); 133 } 134 135 public void convertToBaf(JimpleToBafContext context, List out) 136 { 137 Unit u = Baf.v().newLoadInst(getType(),context.getBafLocalOfJimpleLocal(this)); 138 out.add(u); 139 Iterator it = context.getCurrentUnit().getTags().iterator(); 140 while(it.hasNext()) { 141 u.addTag((Tag) it.next()); 142 } 143 } 144 public final int getNumber() { return number; } 145 public final void setNumber( int number ) { this.number = number; } 146 147 private int number = 0; 148 } 149 150 | Popular Tags |