1 24 25 package org.aspectj.compiler.base.bcg.pool; 26 27 import org.aspectj.compiler.base.bcg.*; 28 29 import java.io.*; 30 import java.util.*; 31 32 import org.aspectj.compiler.base.ast.ArrayType; 33 import org.aspectj.compiler.base.ast.NameType; 34 import org.aspectj.compiler.base.ast.RefType; 35 36 public abstract class Constant implements Comparable { 37 38 static final byte UTF_TAG = 1; 39 static final byte INT_TAG = 3; 40 static final byte FLOAT_TAG = 4; 41 static final byte LONG_TAG = 5; 42 static final byte DOUBLE_TAG = 6; 43 static final byte CLASS_TAG = 7; 44 static final byte STRING_TAG = 8; 45 static final byte FIELD_REF_TAG = 9; 46 static final byte METHOD_REF_TAG = 10; 47 static final byte INTERFACE_METHOD_REF_TAG = 11; 48 static final byte NAME_AND_TYPE_TAG = 12; 49 50 private int index = 0; 51 private int popularity = 0; 52 public void makePopular() { popularity++; } 53 54 void setIndex(int index) { this.index = index; } 55 public short getIndex() { return (short)index; } 56 public void writeIndex(DataOutputStream stream) throws IOException { 57 stream.writeShort((short)index); 58 } 59 public void writeBriefIndex(DataOutputStream stream) throws IOException { 60 stream.writeByte((byte)index); 61 } 62 abstract void writeTo(DataOutputStream stream) throws IOException; 63 abstract void readFrom(DataInputStream stream, ConstantPool pool) throws IOException; 64 public int compareTo(Object o) { 65 int other = ((Constant)o).popularity; 67 68 return (popularity > other) ? +1 : (popularity == other) ? 0 : -1; 69 } 70 boolean isBig() { return false; } public void display(int indent, boolean inline) { 72 System.err.print(this); 73 } 74 75 static String rep(int index, String x) { 76 return x + ":" + Integer.toHexString(index); 77 } 78 } 79 | Popular Tags |