1 /* 2 * ProGuard -- shrinking, optimization, obfuscation, and preverification 3 * of Java bytecode. 4 * 5 * Copyright (c) 2002-2014 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 */ 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 { 35 public static final int TOP_TYPE = 0; 36 public static final int INTEGER_TYPE = 1; 37 public static final int FLOAT_TYPE = 2; 38 public static final int DOUBLE_TYPE = 3; 39 public static final int LONG_TYPE = 4; 40 public static final int NULL_TYPE = 5; 41 public static final int UNINITIALIZED_THIS_TYPE = 6; 42 public static final int OBJECT_TYPE = 7; 43 public static final int UNINITIALIZED_TYPE = 8; 44 45 46 /** 47 * An extra field in which visitors can store information. 48 */ 49 public Object visitorInfo; 50 51 52 /** 53 * Returns the tag of the verification type. 54 */ getTag()55 public abstract int getTag(); 56 57 58 /** 59 * Accepts the given visitor in the context of a method's code, either on 60 * a stack or as a variable. 61 */ accept(Clazz clazz, Method method, CodeAttribute codeAttribute, int instructionOffset, VerificationTypeVisitor verificationTypeVisitor)62 public abstract void accept(Clazz clazz, Method method, CodeAttribute codeAttribute, int instructionOffset, VerificationTypeVisitor verificationTypeVisitor); 63 64 65 /** 66 * Accepts the given visitor in the context of a stack in a method's code . 67 */ stackAccept(Clazz clazz, Method method, CodeAttribute codeAttribute, int instructionOffset, int stackIndex, VerificationTypeVisitor verificationTypeVisitor)68 public abstract void stackAccept(Clazz clazz, Method method, CodeAttribute codeAttribute, int instructionOffset, int stackIndex, VerificationTypeVisitor verificationTypeVisitor); 69 70 71 /** 72 * Accepts the given visitor in the context of a variable in a method's code. 73 */ variablesAccept(Clazz clazz, Method method, CodeAttribute codeAttribute, int instructionOffset, int variableIndex, VerificationTypeVisitor verificationTypeVisitor)74 public abstract void variablesAccept(Clazz clazz, Method method, CodeAttribute codeAttribute, int instructionOffset, int variableIndex, VerificationTypeVisitor verificationTypeVisitor); 75 76 77 // Implementations for VisitorAccepter. 78 getVisitorInfo()79 public Object getVisitorInfo() 80 { 81 return visitorInfo; 82 } 83 setVisitorInfo(Object visitorInfo)84 public void setVisitorInfo(Object visitorInfo) 85 { 86 this.visitorInfo = visitorInfo; 87 } 88 89 90 // Implementations for Object. 91 equals(Object object)92 public boolean equals(Object object) 93 { 94 return object != null && 95 this.getClass() == object.getClass(); 96 } 97 98 hashCode()99 public int hashCode() 100 { 101 return this.getClass().hashCode(); 102 } 103 } 104