KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > proguard > optimize > evaluation > LoadingInvocationUnit


1 /*
2  * ProGuard -- shrinking, optimization, obfuscation, and preverification
3  * of Java bytecode.
4  *
5  * Copyright (c) 2002-2007 Eric Lafortune (eric@graphics.cornell.edu)
6  *
7  * This library is free software; you can redistribute it and/or modify it
8  * under the terms of the GNU General Public License as published by the Free
9  * Software Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * This library is distributed in the hope that it will be useful, but WITHOUT
13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
15  * for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public License
18  * along with this library; if not, write to the Free Software Foundation,
19  * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20  */

21 package proguard.optimize.evaluation;
22
23 import proguard.classfile.constant.*;
24 import proguard.classfile.*;
25 import proguard.evaluation.value.*;
26 import proguard.evaluation.*;
27
28 /**
29  * This InvocationUbit loads parameter values and return values that were
30  * previously stored with the methods that are invoked.
31  *
32  * @see StoringInvocationUnit
33  * @author Eric Lafortune
34  */

35 public class LoadingInvocationUnit
36 extends BasicInvocationUnit
37 {
38     // Implementations for BasicInvocationUnit.
39

40     protected Value getFieldClassValue(Clazz clazz,
41                                        RefConstant refConstant,
42                                        String JavaDoc type)
43     {
44         Member referencedMember = refConstant.referencedMember;
45         if (referencedMember != null)
46         {
47             ReferenceValue value = StoringInvocationUnit.getFieldClassValue((Field)referencedMember);
48             if (value != null)
49             {
50                 return value;
51             }
52         }
53
54         return super.getFieldClassValue(clazz, refConstant, type);
55     }
56
57
58     protected Value getFieldValue(Clazz clazz,
59                                   RefConstant refConstant,
60                                   String JavaDoc type)
61     {
62         Member referencedMember = refConstant.referencedMember;
63         if (referencedMember != null)
64         {
65             Value value = StoringInvocationUnit.getFieldValue((Field)referencedMember);
66             if (value != null)
67             {
68                 return value;
69             }
70         }
71
72         return super.getFieldValue(clazz, refConstant, type);
73     }
74
75
76     protected Value getMethodParameterValue(Clazz clazz,
77                                             Method method,
78                                             int parameterIndex,
79                                             String JavaDoc type,
80                                             Clazz referencedClass)
81     {
82         Value value = StoringInvocationUnit.getMethodParameterValue(method, parameterIndex);
83         if (value != null)
84         {
85             return value;
86         }
87
88         return super.getMethodParameterValue(clazz,
89                                              method,
90                                              parameterIndex,
91                                              type,
92                                              referencedClass);
93     }
94
95
96     protected Value getMethodReturnValue(Clazz clazz,
97                                          RefConstant refConstant,
98                                          String JavaDoc type)
99     {
100         Member referencedMember = refConstant.referencedMember;
101         if (referencedMember != null)
102         {
103             Value value = StoringInvocationUnit.getMethodReturnValue((Method)referencedMember);
104             if (value != null)
105             {
106                 return value;
107             }
108         }
109
110         return super.getMethodReturnValue(clazz,
111                                           refConstant,
112                                           type);
113     }
114 }
115
Popular Tags