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.*;
026:
027: /**
028: * This StackMapFrame represents a "same locals 1 stack item frame" or a
029: * "same locals 1 stack item frame extended".
030: *
031: * @author Eric Lafortune
032: */
033: public class SameOneFrame extends StackMapFrame {
034: public VerificationType stackItem;
035:
036: /**
037: * Creates an uninitialized SameOneFrame.
038: */
039: public SameOneFrame() {
040: }
041:
042: /**
043: * Creates a SameOneFrame with the given tag.
044: */
045: public SameOneFrame(int tag) {
046: u2offsetDelta = tag - SAME_ONE_FRAME;
047: }
048:
049: /**
050: * Creates a SameOneFrame with the given stack verification type.
051: */
052: public SameOneFrame(VerificationType stackItem) {
053: this .stackItem = stackItem;
054: }
055:
056: /**
057: * Applies the given verification type visitor to the stack item.
058: */
059: public void stackItemAccept(Clazz clazz, Method method,
060: CodeAttribute codeAttribute, int offset,
061: VerificationTypeVisitor verificationTypeVisitor) {
062: stackItem.accept(clazz, method, codeAttribute, offset,
063: verificationTypeVisitor);
064: }
065:
066: // Implementations for StackMapFrame.
067:
068: public int getTag() {
069: return u2offsetDelta < 64 ? SAME_ONE_FRAME + u2offsetDelta
070: : SAME_ONE_FRAME_EXTENDED;
071: }
072:
073: public void accept(Clazz clazz, Method method,
074: CodeAttribute codeAttribute, int offset,
075: StackMapFrameVisitor stackMapFrameVisitor) {
076: stackMapFrameVisitor.visitSameOneFrame(clazz, method,
077: codeAttribute, offset, this );
078: }
079:
080: // Implementations for Object.
081:
082: public boolean equals(Object object) {
083: if (!super .equals(object)) {
084: return false;
085: }
086:
087: SameOneFrame other = (SameOneFrame) object;
088:
089: return this .u2offsetDelta == other.u2offsetDelta
090: && this .stackItem.equals(other.stackItem);
091: }
092:
093: public int hashCode() {
094: return super .hashCode() ^ stackItem.hashCode();
095: }
096:
097: public String toString() {
098: return super .toString() + "Var: ..., Stack: ["
099: + stackItem.toString() + "]";
100: }
101: }
|