ObjectType.java revision 9f606f95f03a75961498803e24bee6799a7c0885
1/*
2 * ProGuard -- shrinking, optimization, obfuscation, and preverification
3 *             of Java bytecode.
4 *
5 * Copyright (c) 2002-2009 Eric Lafortune (eric@graphics.cornell.edu)
6 *
7 * This program 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 program 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 General Public License for
15 * more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */
21package proguard.classfile.attribute.preverification;
22
23import proguard.classfile.*;
24import proguard.classfile.attribute.CodeAttribute;
25import proguard.classfile.attribute.preverification.visitor.VerificationTypeVisitor;
26
27/**
28 * This VerificationType represents an Object type.
29 *
30 * @author Eric Lafortune
31 */
32public class ObjectType extends VerificationType
33{
34    public int u2classIndex;
35
36
37
38    /**
39     * Creates an uninitialized ObjectType.
40     */
41    public ObjectType()
42    {
43    }
44
45
46    /**
47     * Creates an ObjectType that points to the given class constant.
48     */
49    public ObjectType(int u2classIndex)
50    {
51        this.u2classIndex = u2classIndex;
52    }
53
54
55    // Implementations for VerificationType.
56
57    public int getTag()
58    {
59        return OBJECT_TYPE;
60    }
61
62
63    public void accept(Clazz clazz, Method method, CodeAttribute codeAttribute, int instructionOffset, VerificationTypeVisitor verificationTypeVisitor)
64    {
65        verificationTypeVisitor.visitObjectType(clazz, method, codeAttribute, instructionOffset, this);
66    }
67
68
69    public void stackAccept(Clazz clazz, Method method, CodeAttribute codeAttribute, int instructionOffset, int stackIndex, VerificationTypeVisitor verificationTypeVisitor)
70    {
71        verificationTypeVisitor.visitStackObjectType(clazz, method, codeAttribute, instructionOffset, stackIndex, this);
72    }
73
74
75    public void variablesAccept(Clazz clazz, Method method, CodeAttribute codeAttribute, int instructionOffset, int variableIndex, VerificationTypeVisitor verificationTypeVisitor)
76    {
77        verificationTypeVisitor.visitVariablesObjectType(clazz, method, codeAttribute, instructionOffset, variableIndex, this);
78    }
79
80
81    // Implementations for Object.
82
83    public boolean equals(Object object)
84    {
85        if (!super.equals(object))
86        {
87            return false;
88        }
89
90        ObjectType other = (ObjectType)object;
91
92        return this.u2classIndex == other.u2classIndex;
93    }
94
95
96    public int hashCode()
97    {
98        return super.hashCode() ^
99               u2classIndex;
100    }
101
102
103    public String toString()
104    {
105        return "a:" + u2classIndex;
106    }
107}
108