001: /*
002: * ProGuard -- shrinking, optimization, obfuscation, and preverification
003: * of Java bytecode.
004: *
005: * Copyright (c) 2002-2007 Eric Lafortune (eric@graphics.cornell.edu)
006: *
007: * This library is free software; you can redistribute it and/or modify it
008: * under the terms of the GNU General Public License as published by the Free
009: * Software Foundation; either version 2 of the License, or (at your option)
010: * any later version.
011: *
012: * This library is distributed in the hope that it will be useful, but WITHOUT
013: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
014: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
015: * for more details.
016: *
017: * You should have received a copy of the GNU Lesser General Public License
018: * along with this library; if not, write to the Free Software Foundation,
019: * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
020: */
021: package proguard.classfile.attribute.preverification;
022:
023: import proguard.classfile.*;
024: import proguard.classfile.attribute.CodeAttribute;
025: import proguard.classfile.attribute.preverification.visitor.StackMapFrameVisitor;
026:
027: /**
028: * This abstract class represents a stack map frame. Specific types
029: * of entries are subclassed from it.
030: *
031: * @author Eric Lafortune
032: */
033: public abstract class StackMapFrame implements VisitorAccepter {
034: public static final int SAME_ZERO_FRAME = 0;
035: public static final int SAME_ONE_FRAME = 64;
036: public static final int SAME_ONE_FRAME_EXTENDED = 247;
037: public static final int LESS_ZERO_FRAME = 248;
038: public static final int SAME_ZERO_FRAME_EXTENDED = 251;
039: public static final int MORE_ZERO_FRAME = 252;
040: public static final int FULL_FRAME = 255;
041:
042: public int u2offsetDelta;
043:
044: /**
045: * An extra field in which visitors can store information.
046: */
047: public Object visitorInfo;
048:
049: /**
050: * Returns the bytecode offset delta relative to the previous stack map
051: * frame.
052: */
053: public int getOffsetDelta() {
054: return u2offsetDelta;
055: }
056:
057: // Abstract methods to be implemented by extensions.
058:
059: /**
060: * Returns the stack map frame tag that specifies the entry type.
061: */
062: public abstract int getTag();
063:
064: /**
065: * Accepts the given visitor.
066: */
067: public abstract void accept(Clazz clazz, Method method,
068: CodeAttribute codeAttribute, int offset,
069: StackMapFrameVisitor stackMapFrameVisitor);
070:
071: // Implementations for VisitorAccepter.
072:
073: public Object getVisitorInfo() {
074: return visitorInfo;
075: }
076:
077: public void setVisitorInfo(Object visitorInfo) {
078: this .visitorInfo = visitorInfo;
079: }
080:
081: // Implementations for Object.
082:
083: public boolean equals(Object object) {
084: if (object == null || this .getClass() != object.getClass()) {
085: return false;
086: }
087:
088: StackMapFrame other = (StackMapFrame) object;
089:
090: return this .u2offsetDelta == other.u2offsetDelta;
091: }
092:
093: public int hashCode() {
094: return getClass().hashCode() ^ u2offsetDelta;
095: }
096:
097: public String toString() {
098: return "[" + u2offsetDelta + "] ";
099: }
100: }
|