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