1 20 21 26 27 28 package soot.jimple.internal; 29 30 import soot.*; 31 import soot.tagkit.*; 32 import soot.jimple.*; 33 import soot.baf.*; 34 import soot.util.*; 35 import java.util.*; 36 37 import soot.tagkit.*; 38 39 40 public abstract class AbstractStaticInvokeExpr extends AbstractInvokeExpr implements StaticInvokeExpr, ConvertToBaf 41 { 42 AbstractStaticInvokeExpr(SootMethodRef methodRef, List args) 43 { 44 this(methodRef, new ValueBox[args.size()]); 45 46 for(int i = 0; i < args.size(); i++) 47 this.argBoxes[i] = Jimple.v().newImmediateBox((Value) args.get(i)); 48 } 49 50 public boolean equivTo(Object o) 51 { 52 if (o instanceof AbstractStaticInvokeExpr) 53 { 54 AbstractStaticInvokeExpr ie = (AbstractStaticInvokeExpr)o; 55 if (!(getMethod().equals(ie.getMethod()) && 56 argBoxes.length == ie.argBoxes.length)) 57 return false; 58 for (int i = 0; i < argBoxes.length; i++) 59 if (!(argBoxes[i].getValue().equivTo(ie.argBoxes[i].getValue()))) 60 return false; 61 return true; 62 } 63 return false; 64 } 65 66 67 public int equivHashCode() 68 { 69 return getMethod().equivHashCode(); 70 } 71 72 public abstract Object clone(); 73 74 protected AbstractStaticInvokeExpr(SootMethodRef methodRef, ValueBox[] argBoxes) 75 { 76 if( !methodRef.isStatic() ) throw new RuntimeException ("wrong static-ness"); 77 this.methodRef = methodRef; this.argBoxes = argBoxes; 78 } 79 80 public String toString() 81 { 82 StringBuffer buffer = new StringBuffer (); 83 84 buffer.append(Jimple.v().STATICINVOKE + " " + methodRef.getSignature() + "("); 85 86 for(int i = 0; i < argBoxes.length; i++) 87 { 88 if(i != 0) 89 buffer.append(", "); 90 91 buffer.append(argBoxes[i].getValue().toString()); 92 } 93 94 buffer.append(")"); 95 96 return buffer.toString(); 97 } 98 99 public void toString(UnitPrinter up) 100 { 101 up.literal(Jimple.v().STATICINVOKE); 102 up.literal(" "); 103 up.methodRef(methodRef); 104 up.literal("("); 105 106 for(int i = 0; i < argBoxes.length; i++) 107 { 108 if(i != 0) 109 up.literal(", "); 110 111 argBoxes[i].toString(up); 112 } 113 114 up.literal(")"); 115 } 116 117 public List getUseBoxes() 118 { 119 List list = new ArrayList(); 120 121 for(int i = 0; i < argBoxes.length; i++) 122 { 123 list.addAll(argBoxes[i].getValue().getUseBoxes()); 124 list.add(argBoxes[i]); 125 } 126 127 return list; 128 } 129 130 public void apply(Switch sw) 131 { 132 ((ExprSwitch) sw).caseStaticInvokeExpr(this); 133 } 134 135 public void convertToBaf(JimpleToBafContext context, List out) 136 { 137 for(int i = 0; i < argBoxes.length; i++) 138 { 139 ((ConvertToBaf)(argBoxes[i].getValue())).convertToBaf(context, out); 140 } 141 142 Unit u; 143 out.add(u = Baf.v().newStaticInvokeInst(methodRef)); 144 145 Unit currentUnit = context.getCurrentUnit(); 146 147 Iterator it = currentUnit.getTags().iterator(); 148 while(it.hasNext()) { 149 u.addTag((Tag) it.next()); 150 } 151 } 152 } 153 | Popular Tags |