~ubuntu-branches/ubuntu/feisty/proguard/feisty

« back to all changes in this revision

Viewing changes to src/proguard/shrink/InnerUsageMarker.java

  • Committer: Bazaar Package Importer
  • Author(s): Sam Clegg
  • Date: 2005-11-13 09:42:59 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20051113094259-432zf4yyw4890mmn
Tags: 3.4-1
* New upstream release (Closes: #338355)
* debian/control: bump standards version
* debian/copyright: update FSF address
* increase java stack size for proguard and proguardgui

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* $Id: InnerUsageMarker.java,v 1.15 2004/12/11 16:35:23 eric Exp $
 
1
/* $Id: InnerUsageMarker.java,v 1.18 2005/06/11 13:21:35 eric Exp $
2
2
 *
3
3
 * ProGuard -- shrinking, optimization, and obfuscation of Java class files.
4
4
 *
5
 
 * Copyright (c) 2002-2004 Eric Lafortune (eric@graphics.cornell.edu)
 
5
 * Copyright (c) 2002-2005 Eric Lafortune (eric@graphics.cornell.edu)
6
6
 *
7
7
 * This program is free software; you can redistribute it and/or modify it
8
8
 * under the terms of the GNU General Public License as published by the Free
40
40
             AttrInfoVisitor,
41
41
             InnerClassesInfoVisitor
42
42
{
 
43
    private UsageMarker usageMarker;
 
44
 
 
45
    // A field acting as a parameter for the class file visitor.
43
46
    private boolean markingAttributes = true;
 
47
 
 
48
    // A field acting as a return parameter for several methods.
44
49
    private boolean used;
45
50
 
46
51
 
 
52
    /**
 
53
     * Creates a new InnerUsageMarker.
 
54
     * @param usageMarker the usage marker that is used to mark the classes
 
55
     *                    and class members.
 
56
     */
 
57
    public InnerUsageMarker(UsageMarker usageMarker)
 
58
    {
 
59
        this.usageMarker = usageMarker;
 
60
    }
 
61
 
 
62
 
47
63
    // Implementations for ClassFileVisitor.
48
64
 
49
65
    public void visitProgramClassFile(ProgramClassFile programClassFile)
50
66
    {
51
 
        boolean classUsed = UsageMarker.isUsed(programClassFile);
 
67
        boolean classUsed = usageMarker.isUsed(programClassFile);
52
68
 
53
69
        if (markingAttributes && classUsed)
54
70
        {
87
103
 
88
104
    public void visitClassCpInfo(ClassFile classFile, ClassCpInfo classCpInfo)
89
105
    {
90
 
        boolean classUsed = UsageMarker.isUsed(classCpInfo);
 
106
        boolean classUsed = usageMarker.isUsed(classCpInfo);
91
107
 
92
108
        if (!classUsed)
93
109
        {
100
116
            {
101
117
                // The class is being used. Mark the ClassCpInfo as being used
102
118
                // as well.
103
 
                UsageMarker.markAsUsed(classCpInfo);
 
119
                usageMarker.markAsUsed(classCpInfo);
104
120
 
105
121
                markCpEntry(classFile, classCpInfo.u2nameIndex);
106
122
            }
113
129
 
114
130
    public void visitUtf8CpInfo(ClassFile classFile, Utf8CpInfo utf8CpInfo)
115
131
    {
116
 
        if (!UsageMarker.isUsed(utf8CpInfo))
 
132
        if (!usageMarker.isUsed(utf8CpInfo))
117
133
        {
118
 
            UsageMarker.markAsUsed(utf8CpInfo);
 
134
            usageMarker.markAsUsed(utf8CpInfo);
119
135
        }
120
136
    }
121
137
 
158
174
        {
159
175
            // We got a positive used flag, so some inner class is being used.
160
176
            // Mark this attribute as being used as well.
161
 
            UsageMarker.markAsUsed(innerClassesAttrInfo);
 
177
            usageMarker.markAsUsed(innerClassesAttrInfo);
162
178
 
163
179
            markCpEntry(classFile, innerClassesAttrInfo.u2attrNameIndex);
164
180
        }
169
185
 
170
186
    public void visitInnerClassesInfo(ClassFile classFile, InnerClassesInfo innerClassesInfo)
171
187
    {
172
 
        boolean innerClassesInfoUsed = UsageMarker.isUsed(innerClassesInfo);
 
188
        boolean innerClassesInfoUsed = usageMarker.isUsed(innerClassesInfo);
173
189
 
174
190
        if (!innerClassesInfoUsed)
175
191
        {
197
213
            // used, then mark this InnerClassesInfo as well.
198
214
            if (innerClassesInfoUsed)
199
215
            {
200
 
                UsageMarker.markAsUsed(innerClassesInfo);
 
216
                usageMarker.markAsUsed(innerClassesInfo);
201
217
 
202
218
                if (u2innerNameIndex != 0)
203
219
                {