1 4 package gnu.bytecode; 5 import java.io.*; 6 7 17 18 abstract public class CpoolEntry 19 { 20 21 int hash; 22 23 24 public int index; 25 26 public int getIndex() { return index; } 27 28 30 CpoolEntry next; 31 32 public abstract int getTag(); 33 34 public int hashCode () { return hash; } 35 36 abstract void write(DataOutputStream str) 37 throws java.io.IOException ; 38 39 42 void add_hashed (ConstantPool cpool) 43 { 44 CpoolEntry[] hashTab = cpool.hashTab; 45 int index = (hash & 0x7FFFFFFF) % hashTab.length; 46 next = hashTab[index]; 47 hashTab[index] = this; 48 } 49 50 protected CpoolEntry () { } 51 52 public CpoolEntry (ConstantPool cpool, int h) 53 { 54 hash = h; 55 if (cpool.locked) 56 throw new Error ("adding new entry to locked contant pool"); 57 index = ++cpool.count; 58 59 if (cpool.pool == null) 61 cpool.pool = new CpoolEntry[60]; 62 else if (index >= cpool.pool.length) 63 { 64 int old_size = cpool.pool.length; 65 int new_size = 2 * cpool.pool.length; 66 CpoolEntry[] new_pool = new CpoolEntry[new_size]; 67 for (int i = 0; i < old_size; i++) 68 new_pool[i] = cpool.pool[i]; 69 cpool.pool = new_pool; 70 } 71 72 if (cpool.hashTab == null || index >= 0.60 * cpool.hashTab.length) 74 cpool.rehash(); 75 76 cpool.pool[index] = this; 78 add_hashed (cpool); 80 } 81 82 86 87 public abstract void print (ClassTypeWriter dst, int verbosity); 88 }; 89 | Popular Tags |