1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32 package org.kit.furia.fragment.soot.representation.internal;
33
34 import soot.*;
35 import org.kit.furia.fragment.soot.representation.*;
36 import soot.jimple.internal.*;
37 import java.util.*;
38
39 public class FVirtualInvokeExpr extends AbstractVirtualInvokeExpr
40 implements Precedence, Qable, SpecialConstructContainer
41 {
42
43
44
45 private static final long serialVersionUID = -6455352440041113825L;
46
47 public FVirtualInvokeExpr(Value base, SootMethodRef methodRef, List args)
48 {
49 super(Frimp.v().newObjExprBox(base), methodRef,
50 new ValueBox[args.size()]);
51
52 for(int i = 0; i < args.size(); i++)
53 this.argBoxes[i] = Frimp.v().newExprBox((Value) args.get(i));
54 }
55
56
57 public int getPrecedence() { return 950; }
58
59 private String toString(Value op, String opString, String rightString)
60 {
61 String leftOp = opString;
62
63 if (getBase() instanceof Precedence &&
64 ((Precedence)getBase()).getPrecedence() < getPrecedence())
65 leftOp = "(" + leftOp + ")";
66 return leftOp + rightString;
67 }
68
69 public String toString()
70 {
71 StringBuffer buffer = new StringBuffer();
72
73 buffer.append("." + methodRef.getSignature() + "(");
74
75 for(int i = 0; i < argBoxes.length; i++)
76 {
77 if(i != 0)
78 buffer.append(", ");
79
80 buffer.append(argBoxes[i].getValue().toString());
81 }
82
83 buffer.append(")");
84
85 return toString(getBase(), getBase().toString(),
86 buffer.toString());
87 }
88
89 public void toString(UnitPrinter up)
90 {
91 if( PrecedenceTest.needsBrackets( baseBox, this ) ) up.literal("(");
92 baseBox.toString(up);
93 if( PrecedenceTest.needsBrackets( baseBox, this ) ) up.literal(")");
94 up.literal(".");
95 up.methodRef(methodRef);
96 up.literal("(");
97
98 for(int i = 0; i < argBoxes.length; i++)
99 {
100 if(i != 0)
101 up.literal(", ");
102
103 argBoxes[i].toString(up);
104 }
105
106 up.literal(")");
107 }
108
109
110 public Object clone()
111 {
112 ArrayList clonedArgs = new ArrayList(getArgCount());
113
114 for(int i = 0; i < getArgCount(); i++) {
115 clonedArgs.add(i, Frimp.cloneIfNecessary(getArg(i)));
116 }
117
118 return new FVirtualInvokeExpr(Frimp.cloneIfNecessary(getBase()), methodRef,
119 clonedArgs);
120 }
121
122 public String toQ() throws Exception {
123
124 StringBuffer buffer = new StringBuffer();
125
126 buffer.append(FuriaConstructDefinitions.FURIA_fvirtualInvokeExpr + "(" + Frimp.toQ(methodRef ));
127
128 for(int i = 0; i < argBoxes.length; i++)
129 {
130
131 buffer.append(",");
132
133 buffer.append(Frimp.toQ(argBoxes[i].getValue()));
134 }
135
136 buffer.append(")");
137
138 return buffer.toString();
139
140 }
141
142 public List getContainedSpecialConstructs() {
143 List res = new LinkedList();
144 res.add(methodRef);
145 return res;
146 }
147
148 }
149