1 4 package gnu.bytecode; 5 import java.io.*; 6 7 8 9 public class CpoolValue2 extends CpoolEntry 10 { 11 int tag; 12 long value; 13 14 CpoolValue2 (int tag) { this.tag = tag; } 15 16 CpoolValue2 (ConstantPool cpool, int tag, int hash, long value) 17 { 18 super (cpool, hash); 19 this.tag = tag; 20 this.value = value; 21 cpool.count++; 22 } 23 24 public int getTag() { return tag; } 25 26 public final long getValue() 27 { 28 return value; 29 } 30 31 static int hashCode (long val) { return (int) val; } 32 33 public int hashCode () 34 { 35 if (hash == 0) 36 hash = hashCode(value); 37 return hash; 38 } 39 40 void write (DataOutputStream dstr) throws java.io.IOException 41 { 42 dstr.writeByte (tag); 43 dstr.writeLong (value); 44 } 45 46 public void print (ClassTypeWriter dst, int verbosity) 47 { 48 if (tag == ConstantPool.LONG) 49 { 50 if (verbosity > 0) 51 dst.print("Long "); 52 dst.print(value); 53 if (verbosity > 1 && value != 0) 54 { 55 dst.print("=0x"); 56 dst.print(Long.toHexString(value)); 57 } 58 } 59 else { 61 if (verbosity > 0) 62 dst.print("Double "); 63 dst.print(Double.longBitsToDouble(value)); 64 if (verbosity > 1) 65 { 66 dst.print("=0x"); 67 dst.print(Long.toHexString(value)); 68 } 69 } 70 } 71 } 72 | Popular Tags |