1 30 package com.sleepycat.asm; 31 32 38 final class Item { 39 40 43 int index; 44 45 55 int type; 56 57 60 int intVal; 61 62 65 long longVal; 66 67 70 float floatVal; 71 72 75 double doubleVal; 76 77 81 String strVal1; 82 83 87 String strVal2; 88 89 93 String strVal3; 94 95 98 int hashCode; 99 100 104 Item next; 105 106 109 Item() { 110 } 111 112 Item(int index) { 113 this.index = index; 114 } 115 116 122 Item(final int index, final Item i) { 123 this.index = index; 124 type = i.type; 125 intVal = i.intVal; 126 longVal = i.longVal; 127 floatVal = i.floatVal; 128 doubleVal = i.doubleVal; 129 strVal1 = i.strVal1; 130 strVal2 = i.strVal2; 131 strVal3 = i.strVal3; 132 hashCode = i.hashCode; 133 } 134 135 140 void set(final int intVal) { 141 this.type = ClassWriter.INT; 142 this.intVal = intVal; 143 this.hashCode = 0x7FFFFFFF & (type + intVal); 144 } 145 146 151 void set(final long longVal) { 152 this.type = ClassWriter.LONG; 153 this.longVal = longVal; 154 this.hashCode = 0x7FFFFFFF & (type + (int) longVal); 155 } 156 157 162 void set(final float floatVal) { 163 this.type = ClassWriter.FLOAT; 164 this.floatVal = floatVal; 165 this.hashCode = 0x7FFFFFFF & (type + (int) floatVal); 166 } 167 168 173 void set(final double doubleVal) { 174 this.type = ClassWriter.DOUBLE; 175 this.doubleVal = doubleVal; 176 this.hashCode = 0x7FFFFFFF & (type + (int) doubleVal); 177 } 178 179 187 void set( 188 final int type, 189 final String strVal1, 190 final String strVal2, 191 final String strVal3) 192 { 193 this.type = type; 194 this.strVal1 = strVal1; 195 this.strVal2 = strVal2; 196 this.strVal3 = strVal3; 197 switch (type) { 198 case ClassWriter.UTF8: 199 case ClassWriter.STR: 200 case ClassWriter.CLASS: 201 hashCode = 0x7FFFFFFF & (type + strVal1.hashCode()); 202 return; 203 case ClassWriter.NAME_TYPE: 204 hashCode = 0x7FFFFFFF & (type + strVal1.hashCode() 205 * strVal2.hashCode()); 206 return; 207 default: 211 hashCode = 0x7FFFFFFF & (type + strVal1.hashCode() 212 * strVal2.hashCode() * strVal3.hashCode()); 213 } 214 } 215 216 223 boolean isEqualTo(final Item i) { 224 if (i.type == type) { 225 switch (type) { 226 case ClassWriter.INT: 227 return i.intVal == intVal; 228 case ClassWriter.LONG: 229 return i.longVal == longVal; 230 case ClassWriter.FLOAT: 231 return i.floatVal == floatVal; 232 case ClassWriter.DOUBLE: 233 return i.doubleVal == doubleVal; 234 case ClassWriter.UTF8: 235 case ClassWriter.STR: 236 case ClassWriter.CLASS: 237 return i.strVal1.equals(strVal1); 238 case ClassWriter.NAME_TYPE: 239 return i.strVal1.equals(strVal1) 240 && i.strVal2.equals(strVal2); 241 default: 245 return i.strVal1.equals(strVal1) 246 && i.strVal2.equals(strVal2) 247 && i.strVal3.equals(strVal3); 248 } 249 } 250 return false; 251 } 252 } 253 | Popular Tags |