KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > soot > baf > internal > AbstractInvokeInst


1 /* Soot - a J*va Optimization Framework
2  * Copyright (C) 1999 Patrick Lam, Patrick Pominville and Raja Vallee-Rai
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */

19
20 /*
21  * Modified by the Sable Research Group and others 1997-1999.
22  * See the 'credits' file distributed with Soot for the complete list of
23  * contributors. (Soot is distributed at http://www.sable.mcgill.ca/soot)
24  */

25
26
27
28
29
30 package soot.baf.internal;
31
32 import soot.*;
33 import soot.baf.*;
34 import java.util.*;
35
36 abstract class AbstractInvokeInst extends AbstractInst
37 {
38     SootMethodRef methodRef;
39
40     public SootMethodRef getMethodRef()
41     {
42         return methodRef;
43     }
44
45     public SootMethod getMethod()
46     {
47         return methodRef.resolve();
48     }
49
50     public Type getType()
51     {
52         return methodRef.returnType();
53     }
54
55     public String JavaDoc toString()
56     {
57         return getName() + getParameters();
58     }
59
60     abstract public String JavaDoc getName();
61     String JavaDoc getParameters()
62         { return " " + methodRef.getSignature(); }
63     protected void getParameters(UnitPrinter up) {
64         up.literal(" ");
65         up.methodRef(methodRef);
66     }
67
68     
69
70   
71   public int getInCount()
72   {
73     return getMethodRef().parameterTypes().size();
74   }
75   
76
77   public int getOutCount()
78   {
79     if(getMethodRef().returnType() instanceof VoidType)
80       return 0;
81     else
82       return 1;
83   }
84   
85
86
87   public int getInMachineCount()
88   {
89     int count = 0;
90     
91     Iterator it = getMethodRef().parameterTypes().iterator();
92     while(it.hasNext()) {
93       count += JasminClass.sizeOfType((Type) it.next());
94     }
95     return count;
96   }
97   
98
99   public int getOutMachineCount()
100   {
101     if(getMethodRef().returnType() instanceof VoidType)
102       return 0;
103     else
104       return JasminClass.sizeOfType(getMethodRef().returnType());
105   }
106
107   public boolean containsInvokeExpr() { return true; }
108
109 }
110
Popular Tags