~ubuntu-branches/ubuntu/maverick/proguard/maverick

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Sam Clegg, Onkar Shinde, Sam Clegg
  • Date: 2009-10-09 16:17:49 UTC
  • mfrom: (1.2.3 upstream) (3.1.6 karmic)
  • Revision ID: james.westby@ubuntu.com-20091009161749-qjk059y5r792co7c
Tags: 4.4-1
[ Onkar Shinde ]
* Merge from Ubuntu. (Closes: #534029, #548810)

[ Sam Clegg ]
* Thanks Onkar for the above fixes!
* New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 * ProGuard -- shrinking, optimization, obfuscation, and preverification
3
3
 *             of Java bytecode.
4
4
 *
5
 
 * Copyright (c) 2002-2008 Eric Lafortune (eric@graphics.cornell.edu)
 
5
 * Copyright (c) 2002-2009 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
21
21
package proguard.optimize.evaluation;
22
22
 
23
23
import proguard.classfile.*;
 
24
import proguard.classfile.visitor.MemberVisitor;
24
25
import proguard.classfile.attribute.*;
25
26
import proguard.classfile.attribute.visitor.AttributeVisitor;
26
27
import proguard.classfile.editor.VariableRemapper;
45
46
    private static final int MAX_VARIABLES_SIZE = 64;
46
47
 
47
48
 
48
 
    private final boolean reuseThis;
 
49
    private final boolean       reuseThis;
 
50
    private final MemberVisitor extraVariableMemberVisitor;
49
51
 
50
52
    private final LivenessAnalyzer livenessAnalyzer = new LivenessAnalyzer();
51
53
    private final VariableRemapper variableRemapper = new VariableRemapper();
56
58
    /**
57
59
     * Creates a new VariableOptimizer.
58
60
     * @param reuseThis specifies whether the 'this' variable can be reused.
 
61
     *                  Many JVMs for JME and IBM's JVMs for JSE can't handle
 
62
     *                  such reuse.
59
63
     */
60
64
    public VariableOptimizer(boolean reuseThis)
61
65
    {
62
 
        this.reuseThis = reuseThis;
 
66
        this(reuseThis, null);
 
67
    }
 
68
 
 
69
 
 
70
    /**
 
71
     * Creates a new VariableOptimizer with an extra visitor.
 
72
     * @param reuseThis                  specifies whether the 'this' variable
 
73
     *                                   can be reused. Many JVMs for JME and
 
74
     *                                   IBM's JVMs for JSE can't handle such
 
75
     *                                   reuse.
 
76
     * @param extraVariableMemberVisitor an optional extra visitor for all
 
77
     *                                   removed variables.
 
78
     */
 
79
    public VariableOptimizer(boolean       reuseThis,
 
80
                             MemberVisitor extraVariableMemberVisitor)
 
81
    {
 
82
        this.reuseThis                  = reuseThis;
 
83
        this.extraVariableMemberVisitor = extraVariableMemberVisitor;
63
84
    }
64
85
 
65
86
 
140
161
 
141
162
            variableRemapper.setVariableMap(variableMap);
142
163
            variableRemapper.visitCodeAttribute(clazz, method, codeAttribute);
 
164
 
 
165
            // Visit the method, if required.
 
166
            if (extraVariableMemberVisitor != null)
 
167
            {
 
168
                method.accept(clazz, extraVariableMemberVisitor);
 
169
            }
143
170
        }
144
171
    }
145
172