1 20 21 26 27 28 29 30 31 package soot.jimple; 32 33 import soot.tagkit.*; 34 import soot.*; 35 import soot.baf.*; 36 import soot.util.*; 37 import java.util.*; 38 import java.io.*; 39 40 public class StaticFieldRef implements FieldRef, ConvertToBaf 41 { 42 43 44 protected SootFieldRef fieldRef; 45 46 protected StaticFieldRef(SootFieldRef fieldRef) 47 { 48 if( !fieldRef.isStatic() ) throw new RuntimeException ("wrong static-ness"); 49 this.fieldRef = fieldRef; 50 } 51 52 public Object clone() 53 { 54 return new StaticFieldRef(fieldRef); 55 } 56 57 public String toString() 58 { 59 return fieldRef.getSignature(); 60 } 61 62 public void toString( UnitPrinter up ) { 63 up.fieldRef(fieldRef); 64 } 65 66 public SootFieldRef getFieldRef() 67 { 68 return fieldRef; 69 } 70 71 public void setFieldRef(SootFieldRef fieldRef) { 72 this.fieldRef = fieldRef; 73 } 74 public SootField getField() 75 { 76 return fieldRef.resolve(); 77 } 78 79 public List getUseBoxes() 80 { 81 return AbstractUnit.emptyList; 82 } 83 84 public Type getType() 85 { 86 return fieldRef.type(); 87 } 88 89 public void apply(Switch sw) 90 { 91 ((RefSwitch) sw).caseStaticFieldRef(this); 92 } 93 94 public boolean equivTo(Object o) 95 { 96 if (o instanceof StaticFieldRef) 97 return ((StaticFieldRef)o).getField().equals(getField()); 98 99 return false; 100 } 101 102 public int equivHashCode() 103 { 104 return getField().equivHashCode(); 105 } 106 107 public void convertToBaf(JimpleToBafContext context, List out) 108 { 109 Unit u = Baf.v().newStaticGetInst(fieldRef); 110 out.add(u); 111 112 Iterator it = context.getCurrentUnit().getTags().iterator(); 113 while(it.hasNext()) { 114 u.addTag((Tag) it.next()); 115 } 116 } 117 } 118 | Popular Tags |