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.VerificationTypeVisitor;
26:
27: /**
28: * This abstract class represents a verification type of a local variable or
29: * a stack element. Specific verification types are subclassed from it.
30: *
31: * @author Eric Lafortune
32: */
33: public abstract class VerificationType implements VisitorAccepter {
34: public static final int TOP_TYPE = 0;
35: public static final int INTEGER_TYPE = 1;
36: public static final int FLOAT_TYPE = 2;
37: public static final int DOUBLE_TYPE = 3;
38: public static final int LONG_TYPE = 4;
39: public static final int NULL_TYPE = 5;
40: public static final int UNINITIALIZED_THIS_TYPE = 6;
41: public static final int OBJECT_TYPE = 7;
42: public static final int UNINITIALIZED_TYPE = 8;
43:
44: /**
45: * An extra field in which visitors can store information.
46: */
47: public Object visitorInfo;
48:
49: /**
50: * Returns the tag of the verification type.
51: */
52: public abstract int getTag();
53:
54: /**
55: * Accepts the given visitor in the context of a method's code, either on
56: * a stack or as a variable.
57: */
58: public abstract void accept(Clazz clazz, Method method,
59: CodeAttribute codeAttribute, int instructionOffset,
60: VerificationTypeVisitor verificationTypeVisitor);
61:
62: /**
63: * Accepts the given visitor in the context of a stack in a method's code .
64: */
65: public abstract void stackAccept(Clazz clazz, Method method,
66: CodeAttribute codeAttribute, int instructionOffset,
67: int stackIndex,
68: VerificationTypeVisitor verificationTypeVisitor);
69:
70: /**
71: * Accepts the given visitor in the context of a variable in a method's code.
72: */
73: public abstract void variablesAccept(Clazz clazz, Method method,
74: CodeAttribute codeAttribute, int instructionOffset,
75: int variableIndex,
76: VerificationTypeVisitor verificationTypeVisitor);
77:
78: // Implementations for VisitorAccepter.
79:
80: public Object getVisitorInfo() {
81: return visitorInfo;
82: }
83:
84: public void setVisitorInfo(Object visitorInfo) {
85: this .visitorInfo = visitorInfo;
86: }
87:
88: // Implementations for Object.
89:
90: public boolean equals(Object object) {
91: return object != null && this .getClass() == object.getClass();
92: }
93:
94: public int hashCode() {
95: return this.getClass().hashCode();
96: }
97: }
|