1 20 21 26 27 28 package soot.jimple.internal; 29 30 import soot.*; 31 import soot.jimple.*; 32 import soot.baf.*; 33 import soot.util.*; 34 import java.util.*; 35 36 import soot.tagkit.*; 37 38 public abstract class AbstractVirtualInvokeExpr extends AbstractInstanceInvokeExpr 39 implements VirtualInvokeExpr, ConvertToBaf 40 { 41 protected AbstractVirtualInvokeExpr(ValueBox baseBox, SootMethodRef methodRef, 42 ValueBox[] argBoxes) 43 { 44 if( methodRef.isStatic() ) throw new RuntimeException ("wrong static-ness"); 45 this.baseBox = baseBox; this.methodRef = methodRef; 46 this.argBoxes = argBoxes; 47 } 48 49 public boolean equivTo(Object o) 50 { 51 if (o instanceof AbstractVirtualInvokeExpr) 52 { 53 AbstractVirtualInvokeExpr ie = (AbstractVirtualInvokeExpr)o; 54 if (!(baseBox.getValue().equivTo(ie.baseBox.getValue()) && 55 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 baseBox.getValue().equivHashCode() * 101 + getMethod().equivHashCode() * 17; 70 } 71 72 public abstract Object clone(); 73 74 public void apply(Switch sw) 75 { 76 ((ExprSwitch) sw).caseVirtualInvokeExpr(this); 77 } 78 79 public String toString() 80 { 81 StringBuffer buffer = new StringBuffer (); 82 83 buffer.append(Jimple.VIRTUALINVOKE + " " + baseBox.getValue().toString() + 84 "." + 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.VIRTUALINVOKE); 102 up.literal(" "); 103 baseBox.toString(up); 104 up.literal("."); 105 up.methodRef(methodRef); 106 up.literal("("); 107 108 for(int i = 0; i < argBoxes.length; i++) 109 { 110 if(i != 0) 111 up.literal(", "); 112 113 argBoxes[i].toString(up); 114 } 115 116 up.literal(")"); 117 } 118 119 public void convertToBaf(JimpleToBafContext context, List out) 120 { 121 ((ConvertToBaf)(getBase())).convertToBaf(context, out); 122 123 for(int i = 0; i < argBoxes.length; i++) 124 { 125 ((ConvertToBaf)(argBoxes[i].getValue())).convertToBaf(context, out); 126 } 127 128 Unit u; 129 out.add(u = Baf.v().newVirtualInvokeInst(methodRef)); 130 131 Unit currentUnit = context.getCurrentUnit(); 132 133 Iterator it = currentUnit.getTags().iterator(); 134 while(it.hasNext()) { 135 u.addTag((Tag) it.next()); 136 } 137 138 } 139 } 140 | Popular Tags |