1 19 20 25 26 27 28 29 30 31 package soot.jimple.toolkits.scalar; 32 33 import soot.*; 34 import soot.jimple.toolkits.typing.*; 35 import soot.util.*; 36 import java.util.*; 37 38 public class LocalNameStandardizer extends BodyTransformer 39 { 40 public LocalNameStandardizer( Singletons.Global g ) {} 41 public static LocalNameStandardizer v() { return G.v().soot_jimple_toolkits_scalar_LocalNameStandardizer(); } 42 43 protected void internalTransform(Body body, String phaseName, Map options) 44 { 45 boolean onlyStackName = PhaseOptions.getBoolean(options, "only-stack-locals"); 46 47 { 49 int objectCount = 0; 50 int intCount = 0; 51 int longCount = 0; 52 int floatCount = 0; 53 int doubleCount = 0; 54 int addressCount = 0; 55 int errorCount = 0; 56 int nullCount = 0; 57 58 Iterator localIt = body.getLocals().iterator(); 59 60 while(localIt.hasNext()) 61 { 62 Local l = (Local) localIt.next(); 63 String prefix = ""; 64 65 if(l.getName().startsWith("$")) 66 prefix = "$"; 67 else 68 { 69 if (onlyStackName) 70 continue; 71 } 72 73 if(l.getType().equals(BooleanType.v())) 74 l.setName(prefix + "z" + intCount++); 75 else if(l.getType().equals(ByteType.v())) 76 l.setName(prefix + "b" + longCount++); 77 else if(l.getType().equals(ShortType.v())) 78 l.setName(prefix + "s" + longCount++); 79 else if(l.getType().equals(CharType.v())) 80 l.setName(prefix + "c" + longCount++); 81 else if(l.getType().equals(IntType.v())) 82 l.setName(prefix + "i" + longCount++); 83 else if(l.getType().equals(LongType.v())) 84 l.setName(prefix + "l" + longCount++); 85 else if(l.getType().equals(DoubleType.v())) 86 l.setName(prefix + "d" + doubleCount++); 87 else if(l.getType().equals(FloatType.v())) 88 l.setName(prefix + "f" + floatCount++); 89 else if(l.getType().equals(StmtAddressType.v())) 90 l.setName(prefix + "a" + addressCount++); 91 else if(l.getType().equals(ErroneousType.v()) || 92 l.getType().equals(UnknownType.v())) 93 { 94 l.setName(prefix + "e" + errorCount++); 95 } 96 else if(l.getType().equals(NullType.v())) 97 l.setName(prefix + "n" + nullCount++); 98 else 99 l.setName(prefix + "r" + objectCount++); 100 } 101 } 102 } 103 } 104 105 106 107 | Popular Tags |