01: /*
02: * ProGuard -- shrinking, optimization, obfuscation, and preverification
03: * of Java bytecode.
04: *
05: * Copyright (c) 2002-2007 Eric Lafortune (eric@graphics.cornell.edu)
06: *
07: * This library is free software; you can redistribute it and/or modify it
08: * under the terms of the GNU General Public License as published by the Free
09: * 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.classfile.attribute.preverification;
22:
23: import proguard.classfile.*;
24: import proguard.classfile.attribute.CodeAttribute;
25: import proguard.classfile.attribute.preverification.visitor.StackMapFrameVisitor;
26:
27: /**
28: * This StackMapFrame represents an "chop frame".
29: *
30: * @author Eric Lafortune
31: */
32: public class LessZeroFrame extends StackMapFrame {
33: public int choppedVariablesCount;
34:
35: /**
36: * Creates an uninitialized LessZeroFrame.
37: */
38: public LessZeroFrame() {
39: }
40:
41: /**
42: * Creates a LessZeroFrame with the given tag.
43: */
44: public LessZeroFrame(int tag) {
45: choppedVariablesCount = LESS_ZERO_FRAME + 3 - tag;
46: }
47:
48: /**
49: * Creates a LessZeroFrame with the given number of chopped variables.
50: */
51: public LessZeroFrame(byte choppedVariablesCount) {
52: this .choppedVariablesCount = (int) choppedVariablesCount;
53: }
54:
55: // Implementations for StackMapFrame.
56:
57: public int getTag() {
58: return LESS_ZERO_FRAME + 3 - choppedVariablesCount;
59: }
60:
61: public void accept(Clazz clazz, Method method,
62: CodeAttribute codeAttribute, int offset,
63: StackMapFrameVisitor stackMapFrameVisitor) {
64: stackMapFrameVisitor.visitLessZeroFrame(clazz, method,
65: codeAttribute, offset, this );
66: }
67:
68: // Implementations for Object.
69:
70: public boolean equals(Object object) {
71: if (!super .equals(object)) {
72: return false;
73: }
74:
75: LessZeroFrame other = (LessZeroFrame) object;
76:
77: return this .u2offsetDelta == other.u2offsetDelta
78: && this .choppedVariablesCount != other.choppedVariablesCount;
79: }
80:
81: public int hashCode() {
82: return super .hashCode() ^ choppedVariablesCount;
83: }
84:
85: public String toString() {
86: return super .toString() + "Var: (chopped "
87: + choppedVariablesCount + "), Stack: (empty)";
88: }
89: }
|