KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > proguard > classfile > attribute > preverification > StackMapFrame


1 /*
2  * ProGuard -- shrinking, optimization, obfuscation, and preverification
3  * of Java bytecode.
4  *
5  * Copyright (c) 2002-2007 Eric Lafortune (eric@graphics.cornell.edu)
6  *
7  * This library 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 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.*;
26
27 /**
28  * This abstract class represents a stack map frame. Specific types
29  * of entries are subclassed from it.
30  *
31  * @author Eric Lafortune
32  */

33 public abstract class StackMapFrame implements VisitorAccepter
34 {
35     public static final int SAME_ZERO_FRAME = 0;
36     public static final int SAME_ONE_FRAME = 64;
37     public static final int SAME_ONE_FRAME_EXTENDED = 247;
38     public static final int LESS_ZERO_FRAME = 248;
39     public static final int SAME_ZERO_FRAME_EXTENDED = 251;
40     public static final int MORE_ZERO_FRAME = 252;
41     public static final int FULL_FRAME = 255;
42
43
44     public int u2offsetDelta;
45
46     /**
47      * An extra field in which visitors can store information.
48      */

49     public Object JavaDoc visitorInfo;
50
51
52
53     /**
54      * Returns the bytecode offset delta relative to the previous stack map
55      * frame.
56      */

57     public int getOffsetDelta()
58     {
59         return u2offsetDelta;
60     }
61
62
63     // Abstract methods to be implemented by extensions.
64

65     /**
66      * Returns the stack map frame tag that specifies the entry type.
67      */

68     public abstract int getTag();
69
70
71     /**
72      * Accepts the given visitor.
73      */

74     public abstract void accept(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, StackMapFrameVisitor stackMapFrameVisitor);
75
76
77     // Implementations for VisitorAccepter.
78

79     public Object JavaDoc getVisitorInfo()
80     {
81         return visitorInfo;
82     }
83
84     public void setVisitorInfo(Object JavaDoc visitorInfo)
85     {
86         this.visitorInfo = visitorInfo;
87     }
88
89
90     // Implementations for Object.
91

92     public boolean equals(Object JavaDoc object)
93     {
94         if (object == null ||
95             this.getClass() != object.getClass())
96         {
97             return false;
98         }
99
100         StackMapFrame other = (StackMapFrame)object;
101
102         return this.u2offsetDelta == other.u2offsetDelta;
103     }
104
105
106     public int hashCode()
107     {
108         return getClass().hashCode() ^
109                u2offsetDelta;
110     }
111
112
113     public String JavaDoc toString()
114     {
115         return "[" + u2offsetDelta + "] ";
116     }
117 }
118
Popular Tags