~ubuntu-branches/ubuntu/trusty/proguard/trusty

« back to all changes in this revision

Viewing changes to src/proguard/optimize/evaluation/LoadingInvocationUnit.java

  • Committer: Bazaar Package Importer
  • Author(s): Sam Clegg
  • Date: 2008-05-15 10:39:48 UTC
  • mfrom: (1.2.1 upstream) (3.1.3 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080515103948-nipob41uk77osuu2
* New upstream release
* Fix build of ant task (Closes: #459829)
  Thanks to Hans van Kranenburg <debian@knorrie.org>

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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.*;
 
24
import proguard.classfile.constant.RefConstant;
 
25
import proguard.evaluation.BasicInvocationUnit;
 
26
import proguard.evaluation.value.*;
 
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      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      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 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      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
}