1 11 package org.eclipse.jdt.internal.compiler.impl; 12 13 import org.eclipse.jdt.internal.compiler.ast.OperatorIds; 14 import org.eclipse.jdt.internal.compiler.lookup.TypeIds; 15 import org.eclipse.jdt.internal.compiler.problem.ShouldNotImplement; 16 import org.eclipse.jdt.internal.compiler.util.Messages; 17 18 public abstract class Constant implements TypeIds, OperatorIds { 19 20 public static final Constant NotAConstant = DoubleConstant.fromValue(Double.NaN); 21 22 public boolean booleanValue() { 23 24 throw new ShouldNotImplement(Messages.bind(Messages.constant_cannotCastedInto, new String [] { typeName(), "boolean" })); } 26 27 public byte byteValue() { 28 29 throw new ShouldNotImplement(Messages.bind(Messages.constant_cannotCastedInto, new String [] { typeName(), "byte" })); } 31 32 public final Constant castTo(int conversionToTargetType){ 33 37 if (this == NotAConstant) return NotAConstant; 38 switch(conversionToTargetType){ 39 case T_undefined : return this; 40 54 case (T_byte<<4)+T_byte : return this; 56 case (T_byte<<4)+T_long : return ByteConstant.fromValue((byte)this.longValue()); 57 case (T_byte<<4)+T_short : return ByteConstant.fromValue((byte)this.shortValue()); 58 case (T_byte<<4)+T_double : return ByteConstant.fromValue((byte)this.doubleValue()); 62 case (T_byte<<4)+T_float : return ByteConstant.fromValue((byte)this.floatValue()); 63 case (T_byte<<4)+T_char : return ByteConstant.fromValue((byte)this.charValue()); 65 case (T_byte<<4)+T_int : return ByteConstant.fromValue((byte)this.intValue()); 66 67 case (T_long<<4)+T_byte : return LongConstant.fromValue(this.byteValue()); 69 case (T_long<<4)+T_long : return this; 70 case (T_long<<4)+T_short : return LongConstant.fromValue(this.shortValue()); 71 case (T_long<<4)+T_double : return LongConstant.fromValue((long)this.doubleValue()); 75 case (T_long<<4)+T_float : return LongConstant.fromValue((long)this.floatValue()); 76 case (T_long<<4)+T_char : return LongConstant.fromValue(this.charValue()); 78 case (T_long<<4)+T_int : return LongConstant.fromValue(this.intValue()); 79 80 case (T_short<<4)+T_byte : return ShortConstant.fromValue(this.byteValue()); 82 case (T_short<<4)+T_long : return ShortConstant.fromValue((short)this.longValue()); 83 case (T_short<<4)+T_short : return this; 84 case (T_short<<4)+T_double : return ShortConstant.fromValue((short)this.doubleValue()); 88 case (T_short<<4)+T_float : return ShortConstant.fromValue((short)this.floatValue()); 89 case (T_short<<4)+T_char : return ShortConstant.fromValue((short)this.charValue()); 91 case (T_short<<4)+T_int : return ShortConstant.fromValue((short)this.intValue()); 92 93 106 case (T_JavaLangString<<4)+T_JavaLangString : return this; 112 119 132 case (T_double<<4)+T_byte : return DoubleConstant.fromValue(this.byteValue()); 134 case (T_double<<4)+T_long : return DoubleConstant.fromValue(this.longValue()); 135 case (T_double<<4)+T_short : return DoubleConstant.fromValue(this.shortValue()); 136 case (T_double<<4)+T_double : return this; 140 case (T_double<<4)+T_float : return DoubleConstant.fromValue(this.floatValue()); 141 case (T_double<<4)+T_char : return DoubleConstant.fromValue(this.charValue()); 143 case (T_double<<4)+T_int : return DoubleConstant.fromValue(this.intValue()); 144 145 case (T_float<<4)+T_byte : return FloatConstant.fromValue(this.byteValue()); 147 case (T_float<<4)+T_long : return FloatConstant.fromValue(this.longValue()); 148 case (T_float<<4)+T_short : return FloatConstant.fromValue(this.shortValue()); 149 case (T_float<<4)+T_double : return FloatConstant.fromValue((float)this.doubleValue()); 153 case (T_float<<4)+T_float : return this; 154 case (T_float<<4)+T_char : return FloatConstant.fromValue(this.charValue()); 156 case (T_float<<4)+T_int : return FloatConstant.fromValue(this.intValue()); 157 158 case (T_boolean<<4)+T_boolean : return this; 168 171 case (T_char<<4)+T_byte : return CharConstant.fromValue((char)this.byteValue()); 173 case (T_char<<4)+T_long : return CharConstant.fromValue((char)this.longValue()); 174 case (T_char<<4)+T_short : return CharConstant.fromValue((char)this.shortValue()); 175 case (T_char<<4)+T_double : return CharConstant.fromValue((char)this.doubleValue()); 179 case (T_char<<4)+T_float : return CharConstant.fromValue((char)this.floatValue()); 180 case (T_char<<4)+T_char : return this; 182 case (T_char<<4)+T_int : return CharConstant.fromValue((char)this.intValue()); 183 184 case (T_int<<4)+T_byte : return IntConstant.fromValue(this.byteValue()); 186 case (T_int<<4)+T_long : return IntConstant.fromValue((int) this.longValue()); 187 case (T_int<<4)+T_short : return IntConstant.fromValue(this.shortValue()); 188 case (T_int<<4)+T_double : return IntConstant.fromValue((int) this.doubleValue()); 192 case (T_int<<4)+T_float : return IntConstant.fromValue((int) this.floatValue()); 193 case (T_int<<4)+T_char : return IntConstant.fromValue(this.charValue()); 195 case (T_int<<4)+T_int : return this; 196 197 } 198 199 return NotAConstant; 200 } 201 202 public char charValue() { 203 204 throw new ShouldNotImplement(Messages.bind(Messages.constant_cannotCastedInto, new String [] { typeName(), "char" })); } 206 207 public static final Constant computeConstantOperation(Constant cst, int id, int operator) { 208 209 switch (operator) { 210 case NOT : 211 return BooleanConstant.fromValue(!cst.booleanValue()); 212 case PLUS : 213 return computeConstantOperationPLUS(IntConstant.fromValue(0),T_int,cst,id); 214 case MINUS : switch (id){ 216 case T_float : float f; 217 if ( (f= cst.floatValue()) == 0.0f) 218 { if (Float.floatToIntBits(f) == 0) 220 return FloatConstant.fromValue(-0.0f); 221 else 222 return FloatConstant.fromValue(0.0f);} 223 break; case T_double : double d; 225 if ( (d= cst.doubleValue()) == 0.0d) 226 { if (Double.doubleToLongBits(d) == 0) 228 return DoubleConstant.fromValue(-0.0d); 229 else 230 return DoubleConstant.fromValue(0.0d);} 231 break; } 233 return computeConstantOperationMINUS(IntConstant.fromValue(0),T_int,cst,id); 234 case TWIDDLE: 235 switch (id){ 236 case T_char : return IntConstant.fromValue(~ cst.charValue()); 237 case T_byte: return IntConstant.fromValue(~ cst.byteValue()); 238 case T_short: return IntConstant.fromValue(~ cst.shortValue()); 239 case T_int: return IntConstant.fromValue(~ cst.intValue()); 240 case T_long: return LongConstant.fromValue(~ cst.longValue()); 241 default : return NotAConstant; 242 } 243 default : return NotAConstant; 244 } 245 } 246 247 public static final Constant computeConstantOperation(Constant left, int leftId, int operator, Constant right, int rightId) { 248 249 switch (operator) { 250 case AND : return computeConstantOperationAND (left,leftId,right,rightId); 251 case AND_AND : return computeConstantOperationAND_AND (left,leftId,right,rightId); 252 case DIVIDE : return computeConstantOperationDIVIDE (left,leftId,right,rightId); 253 case GREATER : return computeConstantOperationGREATER (left,leftId,right,rightId); 254 case GREATER_EQUAL : return computeConstantOperationGREATER_EQUAL(left,leftId,right,rightId); 255 case LEFT_SHIFT : return computeConstantOperationLEFT_SHIFT (left,leftId,right,rightId); 256 case LESS : return computeConstantOperationLESS (left,leftId,right,rightId); 257 case LESS_EQUAL : return computeConstantOperationLESS_EQUAL (left,leftId,right,rightId); 258 case MINUS : return computeConstantOperationMINUS (left,leftId,right,rightId); 259 case MULTIPLY : return computeConstantOperationMULTIPLY (left,leftId,right,rightId); 260 case OR : return computeConstantOperationOR (left,leftId,right,rightId); 261 case OR_OR : return computeConstantOperationOR_OR (left,leftId,right,rightId); 262 case PLUS : return computeConstantOperationPLUS (left,leftId,right,rightId); 263 case REMAINDER : return computeConstantOperationREMAINDER (left,leftId,right,rightId); 264 case RIGHT_SHIFT: return computeConstantOperationRIGHT_SHIFT(left,leftId,right,rightId); 265 case UNSIGNED_RIGHT_SHIFT: return computeConstantOperationUNSIGNED_RIGHT_SHIFT(left,leftId,right,rightId); 266 case XOR : return computeConstantOperationXOR (left,leftId,right,rightId); 267 268 default : return NotAConstant; 269 } 270 } 271 272 public static final Constant computeConstantOperationAND(Constant left, int leftId, Constant right, int rightId) { 273 274 switch (leftId){ 275 case T_boolean : return BooleanConstant.fromValue(left.booleanValue() & right.booleanValue()); 276 case T_char : 277 switch (rightId){ 278 case T_char : return IntConstant.fromValue(left.charValue() & right.charValue()); 279 case T_byte: return IntConstant.fromValue(left.charValue() & right.byteValue()); 280 case T_short: return IntConstant.fromValue(left.charValue() & right.shortValue()); 281 case T_int: return IntConstant.fromValue(left.charValue() & right.intValue()); 282 case T_long: return LongConstant.fromValue(left.charValue() & right.longValue()); 283 } 284 break; 285 case T_byte : 286 switch (rightId){ 287 case T_char : return IntConstant.fromValue(left.byteValue() & right.charValue()); 288 case T_byte: return IntConstant.fromValue(left.byteValue() & right.byteValue()); 289 case T_short: return IntConstant.fromValue(left.byteValue() & right.shortValue()); 290 case T_int: return IntConstant.fromValue(left.byteValue() & right.intValue()); 291 case T_long: return LongConstant.fromValue(left.byteValue() & right.longValue()); 292 } 293 break; 294 case T_short : 295 switch (rightId){ 296 case T_char : return IntConstant.fromValue(left.shortValue() & right.charValue()); 297 case T_byte: return IntConstant.fromValue(left.shortValue() & right.byteValue()); 298 case T_short: return IntConstant.fromValue(left.shortValue() & right.shortValue()); 299 case T_int: return IntConstant.fromValue(left.shortValue() & right.intValue()); 300 case T_long: return LongConstant.fromValue(left.shortValue() & right.longValue()); 301 } 302 break; 303 case T_int : 304 switch (rightId){ 305 case T_char : return IntConstant.fromValue(left.intValue() & right.charValue()); 306 case T_byte: return IntConstant.fromValue(left.intValue() & right.byteValue()); 307 case T_short: return IntConstant.fromValue(left.intValue() & right.shortValue()); 308 case T_int: return IntConstant.fromValue(left.intValue() & right.intValue()); 309 case T_long: return LongConstant.fromValue(left.intValue() & right.longValue()); 310 } 311 break; 312 case T_long : 313 switch (rightId){ 314 case T_char : return LongConstant.fromValue(left.longValue() & right.charValue()); 315 case T_byte: return LongConstant.fromValue(left.longValue() & right.byteValue()); 316 case T_short: return LongConstant.fromValue(left.longValue() & right.shortValue()); 317 case T_int: return LongConstant.fromValue(left.longValue() & right.intValue()); 318 case T_long: return LongConstant.fromValue(left.longValue() & right.longValue()); 319 } 320 } 321 322 return NotAConstant; 323 } 324 325 public static final Constant computeConstantOperationAND_AND(Constant left, int leftId, Constant right, int rightId) { 326 327 return BooleanConstant.fromValue(left.booleanValue() && right.booleanValue()); 328 } 329 330 public static final Constant computeConstantOperationDIVIDE(Constant left, int leftId, Constant right, int rightId) { 331 333 switch (leftId){ 334 case T_char : 335 switch (rightId){ 336 case T_char : return IntConstant.fromValue(left.charValue() / right.charValue()); 337 case T_float: return FloatConstant.fromValue(left.charValue() / right.floatValue()); 338 case T_double: return DoubleConstant.fromValue(left.charValue() / right.doubleValue()); 339 case T_byte: return IntConstant.fromValue(left.charValue() / right.byteValue()); 340 case T_short: return IntConstant.fromValue(left.charValue() / right.shortValue()); 341 case T_int: return IntConstant.fromValue(left.charValue() / right.intValue()); 342 case T_long: return LongConstant.fromValue(left.charValue() / right.longValue()); 343 } 344 break; 345 case T_float : 346 switch (rightId){ 347 case T_char : return FloatConstant.fromValue(left.floatValue() / right.charValue()); 348 case T_float: return FloatConstant.fromValue(left.floatValue() / right.floatValue()); 349 case T_double: return DoubleConstant.fromValue(left.floatValue() / right.doubleValue()); 350 case T_byte: return FloatConstant.fromValue(left.floatValue() / right.byteValue()); 351 case T_short: return FloatConstant.fromValue(left.floatValue() / right.shortValue()); 352 case T_int: return FloatConstant.fromValue(left.floatValue() / right.intValue()); 353 case T_long: return FloatConstant.fromValue(left.floatValue() / right.longValue()); 354 } 355 break; 356 case T_double : 357 switch (rightId){ 358 case T_char : return DoubleConstant.fromValue(left.doubleValue() / right.charValue()); 359 case T_float: return DoubleConstant.fromValue(left.doubleValue() / right.floatValue()); 360 case T_double: return DoubleConstant.fromValue(left.doubleValue() / right.doubleValue()); 361 case T_byte: return DoubleConstant.fromValue(left.doubleValue() / right.byteValue()); 362 case T_short: return DoubleConstant.fromValue(left.doubleValue() / right.shortValue()); 363 case T_int: return DoubleConstant.fromValue(left.doubleValue() / right.intValue()); 364 case T_long: return DoubleConstant.fromValue(left.doubleValue() / right.longValue()); 365 } 366 break; 367 case T_byte : 368 switch (rightId){ 369 case T_char : return IntConstant.fromValue(left.byteValue() / right.charValue()); 370 case T_float: return FloatConstant.fromValue(left.byteValue() / right.floatValue()); 371 case T_double: return DoubleConstant.fromValue(left.byteValue() / right.doubleValue()); 372 case T_byte: return IntConstant.fromValue(left.byteValue() / right.byteValue()); 373 case T_short: return IntConstant.fromValue(left.byteValue() / right.shortValue()); 374 case T_int: return IntConstant.fromValue(left.byteValue() / right.intValue()); 375 case T_long: return LongConstant.fromValue(left.byteValue() / right.longValue()); 376 } 377 break; 378 case T_short : 379 switch (rightId){ 380 case T_char : return IntConstant.fromValue(left.shortValue() / right.charValue()); 381 case T_float: return FloatConstant.fromValue(left.shortValue() / right.floatValue()); 382 case T_double: return DoubleConstant.fromValue(left.shortValue() / right.doubleValue()); 383 case T_byte: return IntConstant.fromValue(left.shortValue() / right.byteValue()); 384 case T_short: return IntConstant.fromValue(left.shortValue() / right.shortValue()); 385 case T_int: return IntConstant.fromValue(left.shortValue() / right.intValue()); 386 case T_long: return LongConstant.fromValue(left.shortValue() / right.longValue()); 387 } 388 break; 389 case T_int : 390 switch (rightId){ 391 case T_char : return IntConstant.fromValue(left.intValue() / right.charValue()); 392 case T_float: return FloatConstant.fromValue(left.intValue() / right.floatValue()); 393 case T_double: return DoubleConstant.fromValue(left.intValue() / right.doubleValue()); 394 case T_byte: return IntConstant.fromValue(left.intValue() / right.byteValue()); 395 case T_short: return IntConstant.fromValue(left.intValue() / right.shortValue()); 396 case T_int: return IntConstant.fromValue(left.intValue() / right.intValue()); 397 case T_long: return LongConstant.fromValue(left.intValue() / right.longValue()); 398 } 399 break; 400 case T_long : 401 switch (rightId){ 402 case T_char : return LongConstant.fromValue(left.longValue() / right.charValue()); 403 case T_float: return FloatConstant.fromValue(left.longValue() / right.floatValue()); 404 case T_double: return DoubleConstant.fromValue(left.longValue() / right.doubleValue()); 405 case T_byte: return LongConstant.fromValue(left.longValue() / right.byteValue()); 406 case T_short: return LongConstant.fromValue(left.longValue() / right.shortValue()); 407 case T_int: return LongConstant.fromValue(left.longValue() / right.intValue()); 408 case T_long: return LongConstant.fromValue(left.longValue() / right.longValue()); 409 } 410 411 } 412 413 return NotAConstant; 414 } 415 416 public static final Constant computeConstantOperationEQUAL_EQUAL(Constant left, int leftId, Constant right, int rightId) { 417 418 switch (leftId){ 419 case T_boolean : 420 if (rightId == T_boolean) { 421 return BooleanConstant.fromValue(left.booleanValue() == right.booleanValue()); 422 } 423 break; 424 case T_char : 425 switch (rightId){ 426 case T_char : return BooleanConstant.fromValue(left.charValue() == right.charValue()); 427 case T_float: return BooleanConstant.fromValue(left.charValue() == right.floatValue()); 428 case T_double: return BooleanConstant.fromValue(left.charValue() == right.doubleValue()); 429 case T_byte: return BooleanConstant.fromValue(left.charValue() == right.byteValue()); 430 case T_short: return BooleanConstant.fromValue(left.charValue() == right.shortValue()); 431 case T_int: return BooleanConstant.fromValue(left.charValue() == right.intValue()); 432 case T_long: return BooleanConstant.fromValue(left.charValue() == right.longValue());} 433 break; 434 case T_float : 435 switch (rightId){ 436 case T_char : return BooleanConstant.fromValue(left.floatValue() == right.charValue()); 437 case T_float: return BooleanConstant.fromValue(left.floatValue() == right.floatValue()); 438 case T_double: return BooleanConstant.fromValue(left.floatValue() == right.doubleValue()); 439 case T_byte: return BooleanConstant.fromValue(left.floatValue() == right.byteValue()); 440 case T_short: return BooleanConstant.fromValue(left.floatValue() == right.shortValue()); 441 case T_int: return BooleanConstant.fromValue(left.floatValue() == right.intValue()); 442 case T_long: return BooleanConstant.fromValue(left.floatValue() == right.longValue()); 443 } 444 break; 445 case T_double : 446 switch (rightId){ 447 case T_char : return BooleanConstant.fromValue(left.doubleValue() == right.charValue()); 448 case T_float: return BooleanConstant.fromValue(left.doubleValue() == right.floatValue()); 449 case T_double: return BooleanConstant.fromValue(left.doubleValue() == right.doubleValue()); 450 case T_byte: return BooleanConstant.fromValue(left.doubleValue() == right.byteValue()); 451 case T_short: return BooleanConstant.fromValue(left.doubleValue() == right.shortValue()); 452 case T_int: return BooleanConstant.fromValue(left.doubleValue() == right.intValue()); 453 case T_long: return BooleanConstant.fromValue(left.doubleValue() == right.longValue()); 454 } 455 break; 456 case T_byte : 457 switch (rightId){ 458 case T_char : return BooleanConstant.fromValue(left.byteValue() == right.charValue()); 459 case T_float: return BooleanConstant.fromValue(left.byteValue() == right.floatValue()); 460 case T_double: return BooleanConstant.fromValue(left.byteValue() == right.doubleValue()); 461 case T_byte: return BooleanConstant.fromValue(left.byteValue() == right.byteValue()); 462 case T_short: return BooleanConstant.fromValue(left.byteValue() == right.shortValue()); 463 case T_int: return BooleanConstant.fromValue(left.byteValue() == right.intValue()); 464 case T_long: return BooleanConstant.fromValue(left.byteValue() == right.longValue()); 465 } 466 break; 467 case T_short : 468 switch (rightId){ 469 case T_char : return BooleanConstant.fromValue(left.shortValue() == right.charValue()); 470 case T_float: return BooleanConstant.fromValue(left.shortValue() == right.floatValue()); 471 case T_double: return BooleanConstant.fromValue(left.shortValue() == right.doubleValue()); 472 case T_byte: return BooleanConstant.fromValue(left.shortValue() == right.byteValue()); 473 case T_short: return BooleanConstant.fromValue(left.shortValue() == right.shortValue()); 474 case T_int: return BooleanConstant.fromValue(left.shortValue() == right.intValue()); 475 case T_long: return BooleanConstant.fromValue(left.shortValue() == right.longValue()); 476 } 477 break; 478 case T_int : 479 switch (rightId){ 480 case T_char : return BooleanConstant.fromValue(left.intValue() == right.charValue()); 481 case T_float: return BooleanConstant.fromValue(left.intValue() == right.floatValue()); 482 case T_double: return BooleanConstant.fromValue(left.intValue() == right.doubleValue()); 483 case T_byte: return BooleanConstant.fromValue(left.intValue() == right.byteValue()); 484 case T_short: return BooleanConstant.fromValue(left.intValue() == right.shortValue()); 485 case T_int: return BooleanConstant.fromValue(left.intValue() == right.intValue()); 486 case T_long: return BooleanConstant.fromValue(left.intValue() == right.longValue()); 487 } 488 break; 489 case T_long : 490 switch (rightId){ 491 case T_char : return BooleanConstant.fromValue(left.longValue() == right.charValue()); 492 case T_float: return BooleanConstant.fromValue(left.longValue() == right.floatValue()); 493 case T_double: return BooleanConstant.fromValue(left.longValue() == right.doubleValue()); 494 case T_byte: return BooleanConstant.fromValue(left.longValue() == right.byteValue()); 495 case T_short: return BooleanConstant.fromValue(left.longValue() == right.shortValue()); 496 case T_int: return BooleanConstant.fromValue(left.longValue() == right.intValue()); 497 case T_long: return BooleanConstant.fromValue(left.longValue() == right.longValue()); 498 } 499 break; 500 case T_JavaLangString : 501 if (rightId == T_JavaLangString) { 502 return BooleanConstant.fromValue(((StringConstant)left).hasSameValue(right)); 505 } 506 break; 507 case T_null : 508 if (rightId == T_JavaLangString) { 509 return BooleanConstant.fromValue(false); 510 } else { 511 if (rightId == T_null) { 512 return BooleanConstant.fromValue(true); 513 } 514 } 515 } 516 517 return BooleanConstant.fromValue(false); 518 } 519 520 public static final Constant computeConstantOperationGREATER(Constant left, int leftId, Constant right, int rightId) { 521 522 switch (leftId){ 523 case T_char : 524 switch (rightId){ 525 case T_char : return BooleanConstant.fromValue(left.charValue() > right.charValue()); 526 case T_float: return BooleanConstant.fromValue(left.charValue() > right.floatValue()); 527 case T_double: return BooleanConstant.fromValue(left.charValue() > right.doubleValue()); 528 case T_byte: return BooleanConstant.fromValue(left.charValue() > right.byteValue()); 529 case T_short: return BooleanConstant.fromValue(left.charValue() > right.shortValue()); 530 case T_int: return BooleanConstant.fromValue(left.charValue() > right.intValue()); 531 case T_long: return BooleanConstant.fromValue(left.charValue() > right.longValue()); 532 } 533 break; 534 case T_float : 535 switch (rightId){ 536 case T_char : return BooleanConstant.fromValue(left.floatValue() > right.charValue()); 537 case T_float: return BooleanConstant.fromValue(left.floatValue() > right.floatValue()); 538 case T_double: return BooleanConstant.fromValue(left.floatValue() > right.doubleValue()); 539 case T_byte: return BooleanConstant.fromValue(left.floatValue() > right.byteValue()); 540 case T_short: return BooleanConstant.fromValue(left.floatValue() > right.shortValue()); 541 case T_int: return BooleanConstant.fromValue(left.floatValue() > right.intValue()); 542 case T_long: return BooleanConstant.fromValue(left.floatValue() > right.longValue()); 543 } 544 break; 545 case T_double : 546 switch (rightId){ 547 case T_char : return BooleanConstant.fromValue(left.doubleValue() > right.charValue()); 548 case T_float: return BooleanConstant.fromValue(left.doubleValue() > right.floatValue()); 549 case T_double: return BooleanConstant.fromValue(left.doubleValue() > right.doubleValue()); 550 case T_byte: return BooleanConstant.fromValue(left.doubleValue() > right.byteValue()); 551 case T_short: return BooleanConstant.fromValue(left.doubleValue() > right.shortValue()); 552 case T_int: return BooleanConstant.fromValue(left.doubleValue() > right.intValue()); 553 case T_long: return BooleanConstant.fromValue(left.doubleValue() > right.longValue()); 554 } 555 break; 556 case T_byte : 557 switch (rightId){ 558 case T_char : return BooleanConstant.fromValue(left.byteValue() > right.charValue()); 559 case T_float: return BooleanConstant.fromValue(left.byteValue() > right.floatValue()); 560 case T_double: return BooleanConstant.fromValue(left.byteValue() > right.doubleValue()); 561 case T_byte: return BooleanConstant.fromValue(left.byteValue() > right.byteValue()); 562 case T_short: return BooleanConstant.fromValue(left.byteValue() > right.shortValue()); 563 case T_int: return BooleanConstant.fromValue(left.byteValue() > right.intValue()); 564 case T_long: return BooleanConstant.fromValue(left.byteValue() > right.longValue()); 565 } 566 break; 567 case T_short : 568 switch (rightId){ 569 case T_char : return BooleanConstant.fromValue(left.shortValue() > right.charValue()); 570 case T_float: return BooleanConstant.fromValue(left.shortValue() > right.floatValue()); 571 case T_double: return BooleanConstant.fromValue(left.shortValue() > right.doubleValue()); 572 case T_byte: return BooleanConstant.fromValue(left.shortValue() > right.byteValue()); 573 case T_short: return BooleanConstant.fromValue(left.shortValue() > right.shortValue()); 574 case T_int: return BooleanConstant.fromValue(left.shortValue() > right.intValue()); 575 case T_long: return BooleanConstant.fromValue(left.shortValue() > right.longValue()); 576 } 577 break; 578 case T_int : 579 switch (rightId){ 580 case T_char : return BooleanConstant.fromValue(left.intValue() > right.charValue()); 581 case T_float: return BooleanConstant.fromValue(left.intValue() > right.floatValue()); 582 case T_double: return BooleanConstant.fromValue(left.intValue() > right.doubleValue()); 583 case T_byte: return BooleanConstant.fromValue(left.intValue() > right.byteValue()); 584 case T_short: return BooleanConstant.fromValue(left.intValue() > right.shortValue()); 585 case T_int: return BooleanConstant.fromValue(left.intValue() > right.intValue()); 586 case T_long: return BooleanConstant.fromValue(left.intValue() > right.longValue()); 587 } 588 break; 589 case T_long : 590 switch (rightId){ 591 case T_char : return BooleanConstant.fromValue(left.longValue() > right.charValue()); 592 case T_float: return BooleanConstant.fromValue(left.longValue() > right.floatValue()); 593 case T_double: return BooleanConstant.fromValue(left.longValue() > right.doubleValue()); 594 case T_byte: return BooleanConstant.fromValue(left.longValue() > right.byteValue()); 595 case T_short: return BooleanConstant.fromValue(left.longValue() > right.shortValue()); 596 case T_int: return BooleanConstant.fromValue(left.longValue() > right.intValue()); 597 case T_long: return BooleanConstant.fromValue(left.longValue() > right.longValue()); 598 } 599 600 } 601 602 return NotAConstant; 603 } 604 605 public static final Constant computeConstantOperationGREATER_EQUAL(Constant left, int leftId, Constant right, int rightId) { 606 607 switch (leftId){ 608 case T_char : 609 switch (rightId){ 610 case T_char : return BooleanConstant.fromValue(left.charValue() >= right.charValue()); 611 case T_float: return BooleanConstant.fromValue(left.charValue() >= right.floatValue()); 612 case T_double: return BooleanConstant.fromValue(left.charValue() >= right.doubleValue()); 613 case T_byte: return BooleanConstant.fromValue(left.charValue() >= right.byteValue()); 614 case T_short: return BooleanConstant.fromValue(left.charValue() >= right.shortValue()); 615 case T_int: return BooleanConstant.fromValue(left.charValue() >= right.intValue()); 616 case T_long: return BooleanConstant.fromValue(left.charValue() >= right.longValue()); 617 } 618 break; 619 case T_float : 620 switch (rightId){ 621 case T_char : return BooleanConstant.fromValue(left.floatValue() >= right.charValue()); 622 case T_float: return BooleanConstant.fromValue(left.floatValue() >= right.floatValue()); 623 case T_double: return BooleanConstant.fromValue(left.floatValue() >= right.doubleValue()); 624 case T_byte: return BooleanConstant.fromValue(left.floatValue() >= right.byteValue()); 625 case T_short: return BooleanConstant.fromValue(left.floatValue() >= right.shortValue()); 626 case T_int: return BooleanConstant.fromValue(left.floatValue() >= right.intValue()); 627 case T_long: return BooleanConstant.fromValue(left.floatValue() >= right.longValue()); 628 } 629 break; 630 case T_double : 631 switch (rightId){ 632 case T_char : return BooleanConstant.fromValue(left.doubleValue() >= right.charValue()); 633 case T_float: return BooleanConstant.fromValue(left.doubleValue() >= right.floatValue()); 634 case T_double: return BooleanConstant.fromValue(left.doubleValue() >= right.doubleValue()); 635 case T_byte: return BooleanConstant.fromValue(left.doubleValue() >= right.byteValue()); 636 case T_short: return BooleanConstant.fromValue(left.doubleValue() >= right.shortValue()); 637 case T_int: return BooleanConstant.fromValue(left.doubleValue() >= right.intValue()); 638 case T_long: return BooleanConstant.fromValue(left.doubleValue() >= right.longValue()); 639 } 640 break; 641 case T_byte : 642 switch (rightId){ 643 case T_char : return BooleanConstant.fromValue(left.byteValue() >= right.charValue()); 644 case T_float: return BooleanConstant.fromValue(left.byteValue() >= right.floatValue()); 645 case T_double: return BooleanConstant.fromValue(left.byteValue() >= right.doubleValue()); 646 case T_byte: return BooleanConstant.fromValue(left.byteValue() >= right.byteValue()); 647 case T_short: return BooleanConstant.fromValue(left.byteValue() >= right.shortValue()); 648 case T_int: return BooleanConstant.fromValue(left.byteValue() >= right.intValue()); 649 case T_long: return BooleanConstant.fromValue(left.byteValue() >= right.longValue()); 650 } 651 break; 652 case T_short : 653 switch (rightId){ 654 case T_char : return BooleanConstant.fromValue(left.shortValue() >= right.charValue()); 655 case T_float: return BooleanConstant.fromValue(left.shortValue() >= right.floatValue()); 656 case T_double: return BooleanConstant.fromValue(left.shortValue() >= right.doubleValue()); 657 case T_byte: return BooleanConstant.fromValue(left.shortValue() >= right.byteValue()); 658 case T_short: return BooleanConstant.fromValue(left.shortValue() >= right.shortValue()); 659 case T_int: return BooleanConstant.fromValue(left.shortValue() >= right.intValue()); 660 case T_long: return BooleanConstant.fromValue(left.shortValue() >= right.longValue()); 661 } 662 break; 663 case T_int : 664 switch (rightId){ 665 case T_char : return BooleanConstant.fromValue(left.intValue() >= right.charValue()); 666 case T_float: return BooleanConstant.fromValue(left.intValue() >= right.floatValue()); 667 case T_double: return BooleanConstant.fromValue(left.intValue() >= right.doubleValue()); 668 case T_byte: return BooleanConstant.fromValue(left.intValue() >= right.byteValue()); 669 case T_short: return BooleanConstant.fromValue(left.intValue() >= right.shortValue()); 670 case T_int: return BooleanConstant.fromValue(left.intValue() >= right.intValue()); 671 case T_long: return BooleanConstant.fromValue(left.intValue() >= right.longValue()); 672 } 673 break; 674 case T_long : 675 switch (rightId){ 676 case T_char : return BooleanConstant.fromValue(left.longValue() >= right.charValue()); 677 case T_float: return BooleanConstant.fromValue(left.longValue() >= right.floatValue()); 678 case T_double: return BooleanConstant.fromValue(left.longValue() >= right.doubleValue()); 679 case T_byte: return BooleanConstant.fromValue(left.longValue() >= right.byteValue()); 680 case T_short: return BooleanConstant.fromValue(left.longValue() >= right.shortValue()); 681 case T_int: return BooleanConstant.fromValue(left.longValue() >= right.intValue()); 682 case T_long: return BooleanConstant.fromValue(left.longValue() >= right.longValue()); 683 } 684 685 } 686 687 return NotAConstant; 688 } 689 690 public static final Constant computeConstantOperationLEFT_SHIFT(Constant left, int leftId, Constant right, int rightId) { 691 692 switch (leftId){ 693 case T_char : 694 switch (rightId){ 695 case T_char : return IntConstant.fromValue(left.charValue() << right.charValue()); 696 case T_byte: return IntConstant.fromValue(left.charValue() << right.byteValue()); 697 case T_short: return IntConstant.fromValue(left.charValue() << right.shortValue()); 698 case T_int: return IntConstant.fromValue(left.charValue() << right.intValue()); 699 case T_long: return IntConstant.fromValue(left.charValue() << right.longValue()); 700 } 701 break; 702 case T_byte : 703 switch (rightId){ 704 case T_char : return IntConstant.fromValue(left.byteValue() << right.charValue()); 705 case T_byte: return IntConstant.fromValue(left.byteValue() << right.byteValue()); 706 case T_short: return IntConstant.fromValue(left.byteValue() << right.shortValue()); 707 case T_int: return IntConstant.fromValue(left.byteValue() << right.intValue()); 708 case T_long: return IntConstant.fromValue(left.byteValue() << right.longValue()); 709 } 710 break; 711 case T_short : 712 switch (rightId){ 713 case T_char : return IntConstant.fromValue(left.shortValue() << right.charValue()); 714 case T_byte: return IntConstant.fromValue(left.shortValue() << right.byteValue()); 715 case T_short: return IntConstant.fromValue(left.shortValue() << right.shortValue()); 716 case T_int: return IntConstant.fromValue(left.shortValue() << right.intValue()); 717 case T_long: return IntConstant.fromValue(left.shortValue() << right.longValue()); 718 } 719 break; 720 case T_int : 721 switch (rightId){ 722 case T_char : return IntConstant.fromValue(left.intValue() << right.charValue()); 723 case T_byte: return IntConstant.fromValue(left.intValue() << right.byteValue()); 724 case T_short: return IntConstant.fromValue(left.intValue() << right.shortValue()); 725 case T_int: return IntConstant.fromValue(left.intValue() << right.intValue()); 726 case T_long: return IntConstant.fromValue(left.intValue() << right.longValue()); 727 } 728 break; 729 case T_long : 730 switch (rightId){ 731 case T_char : return LongConstant.fromValue(left.longValue() << right.charValue()); 732 case T_byte: return LongConstant.fromValue(left.longValue() << right.byteValue()); 733 case T_short: return LongConstant.fromValue(left.longValue() << right.shortValue()); 734 case T_int: return LongConstant.fromValue(left.longValue() << right.intValue()); 735 case T_long: return LongConstant.fromValue(left.longValue() << right.longValue()); 736 } 737 738 } 739 740 return NotAConstant; 741 } 742 743 public static final Constant computeConstantOperationLESS(Constant left, int leftId, Constant right, int rightId) { 744 745 switch (leftId){ 746 case T_char : 747 switch (rightId){ 748 case T_char : return BooleanConstant.fromValue(left.charValue() < right.charValue()); 749 case T_float: return BooleanConstant.fromValue(left.charValue() < right.floatValue()); 750 case T_double: return BooleanConstant.fromValue(left.charValue() < right.doubleValue()); 751 case T_byte: return BooleanConstant.fromValue(left.charValue() < right.byteValue()); 752 case T_short: return BooleanConstant.fromValue(left.charValue() < right.shortValue()); 753 case T_int: return BooleanConstant.fromValue(left.charValue() < right.intValue()); 754 case T_long: return BooleanConstant.fromValue(left.charValue() < right.longValue()); 755 } 756 break; 757 case T_float : 758 switch (rightId){ 759 case T_char : return BooleanConstant.fromValue(left.floatValue() < right.charValue()); 760 case T_float: return BooleanConstant.fromValue(left.floatValue() < right.floatValue()); 761 case T_double: return BooleanConstant.fromValue(left.floatValue() < right.doubleValue()); 762 case T_byte: return BooleanConstant.fromValue(left.floatValue() < right.byteValue()); 763 case T_short: return BooleanConstant.fromValue(left.floatValue() < right.shortValue()); 764 case T_int: return BooleanConstant.fromValue(left.floatValue() < right.intValue()); 765 case T_long: return BooleanConstant.fromValue(left.floatValue() < right.longValue()); 766 } 767 break; 768 case T_double : 769 switch (rightId){ 770 case T_char : return BooleanConstant.fromValue(left.doubleValue() < right.charValue()); 771 case T_float: return BooleanConstant.fromValue(left.doubleValue() < right.floatValue()); 772 case T_double: return BooleanConstant.fromValue(left.doubleValue() < right.doubleValue()); 773 case T_byte: return BooleanConstant.fromValue(left.doubleValue() < right.byteValue()); 774 case T_short: return BooleanConstant.fromValue(left.doubleValue() < right.shortValue()); 775 case T_int: return BooleanConstant.fromValue(left.doubleValue() < right.intValue()); 776 case T_long: return BooleanConstant.fromValue(left.doubleValue() < right.longValue()); 777 } 778 break; 779 case T_byte : 780 switch (rightId){ 781 case T_char : return BooleanConstant.fromValue(left.byteValue() < right.charValue()); 782 case T_float: return BooleanConstant.fromValue(left.byteValue() < right.floatValue()); 783 case T_double: return BooleanConstant.fromValue(left.byteValue() < right.doubleValue()); 784 case T_byte: return BooleanConstant.fromValue(left.byteValue() < right.byteValue()); 785 case T_short: return BooleanConstant.fromValue(left.byteValue() < right.shortValue()); 786 case T_int: return BooleanConstant.fromValue(left.byteValue() < right.intValue()); 787 case T_long: return BooleanConstant.fromValue(left.byteValue() < right.longValue()); 788 } 789 break; 790 case T_short : 791 switch (rightId){ 792 case T_char : return BooleanConstant.fromValue(left.shortValue() < right.charValue()); 793 case T_float: return BooleanConstant.fromValue(left.shortValue() < right.floatValue()); 794 case T_double: return BooleanConstant.fromValue(left.shortValue() < right.doubleValue()); 795 case T_byte: return BooleanConstant.fromValue(left.shortValue() < right.byteValue()); 796 case T_short: return BooleanConstant.fromValue(left.shortValue() < right.shortValue()); 797 case T_int: return BooleanConstant.fromValue(left.shortValue() < right.intValue()); 798 case T_long: return BooleanConstant.fromValue(left.shortValue() < right.longValue()); 799 } 800 break; 801 case T_int : 802 switch (rightId){ 803 case T_char : return BooleanConstant.fromValue(left.intValue() < right.charValue()); 804 case T_float: return BooleanConstant.fromValue(left.intValue() < right.floatValue()); 805 case T_double: return BooleanConstant.fromValue(left.intValue() < right.doubleValue()); 806 case T_byte: return BooleanConstant.fromValue(left.intValue() < right.byteValue()); 807 case T_short: return BooleanConstant.fromValue(left.intValue() < right.shortValue()); 808 case T_int: return BooleanConstant.fromValue(left.intValue() < right.intValue()); 809 case T_long: return BooleanConstant.fromValue(left.intValue() < right.longValue()); 810 } 811 break; 812 case T_long : 813 switch (rightId){ 814 case T_char : return BooleanConstant.fromValue(left.longValue() < right.charValue()); 815 case T_float: return BooleanConstant.fromValue(left.longValue() < right.floatValue()); 816 case T_double: return BooleanConstant.fromValue(left.longValue() < right.doubleValue()); 817 case T_byte: return BooleanConstant.fromValue(left.longValue() < right.byteValue()); 818 case T_short: return BooleanConstant.fromValue(left.longValue() < right.shortValue()); 819 case T_int: return BooleanConstant.fromValue(left.longValue() < right.intValue()); 820 case T_long: return BooleanConstant.fromValue(left.longValue() < right.longValue()); 821 } 822 823 } 824 825 return NotAConstant; 826 } 827 828 public static final Constant computeConstantOperationLESS_EQUAL(Constant left, int leftId, Constant right, int rightId) { 829 830 switch (leftId){ 831 case T_char : 832 switch (rightId){ 833 case T_char : return BooleanConstant.fromValue(left.charValue() <= right.charValue()); 834 case T_float: return BooleanConstant.fromValue(left.charValue() <= right.floatValue()); 835 case T_double: return BooleanConstant.fromValue(left.charValue() <= right.doubleValue()); 836 case T_byte: return BooleanConstant.fromValue(left.charValue() <= right.byteValue()); 837 case T_short: return BooleanConstant.fromValue(left.charValue() <= right.shortValue()); 838 case T_int: return BooleanConstant.fromValue(left.charValue() <= right.intValue()); 839 case T_long: return BooleanConstant.fromValue(left.charValue() <= right.longValue()); 840 } 841 break; 842 case T_float : 843 switch (rightId){ 844 case T_char : return BooleanConstant.fromValue(left.floatValue() <= right.charValue()); 845 case T_float: return BooleanConstant.fromValue(left.floatValue() <= right.floatValue()); 846 case T_double: return BooleanConstant.fromValue(left.floatValue() <= right.doubleValue()); 847 case T_byte: return BooleanConstant.fromValue(left.floatValue() <= right.byteValue()); 848 case T_short: return BooleanConstant.fromValue(left.floatValue() <= right.shortValue()); 849 case T_int: return BooleanConstant.fromValue(left.floatValue() <= right.intValue()); 850 case T_long: return BooleanConstant.fromValue(left.floatValue() <= right.longValue()); 851 } 852 break; 853 case T_double : 854 switch (rightId){ 855 case T_char : return BooleanConstant.fromValue(left.doubleValue() <= right.charValue()); 856 case T_float: return BooleanConstant.fromValue(left.doubleValue() <= right.floatValue()); 857 case T_double: return BooleanConstant.fromValue(left.doubleValue() <= right.doubleValue()); 858 case T_byte: return BooleanConstant.fromValue(left.doubleValue() <= right.byteValue()); 859 case T_short: return BooleanConstant.fromValue(left.doubleValue() <= right.shortValue()); 860 case T_int: return BooleanConstant.fromValue(left.doubleValue() <= right.intValue()); 861 case T_long: return BooleanConstant.fromValue(left.doubleValue() <= right.longValue()); 862 } 863 break; 864 case T_byte : 865 switch (rightId){ 866 case T_char : return BooleanConstant.fromValue(left.byteValue() <= right.charValue()); 867 case T_float: return BooleanConstant.fromValue(left.byteValue() <= right.floatValue()); 868 case T_double: return BooleanConstant.fromValue(left.byteValue() <= right.doubleValue()); 869 case T_byte: return BooleanConstant.fromValue(left.byteValue() <= right.byteValue()); 870 case T_short: return BooleanConstant.fromValue(left.byteValue() <= right.shortValue()); 871 case T_int: return BooleanConstant.fromValue(left.byteValue() <= right.intValue()); 872 case T_long: return BooleanConstant.fromValue(left.byteValue() <= right.longValue()); 873 } 874 break; 875 case T_short : 876 switch (rightId){ 877 case T_char : return BooleanConstant.fromValue(left.shortValue() <= right.charValue()); 878 case T_float: return BooleanConstant.fromValue(left.shortValue() <= right.floatValue()); 879 case T_double: return BooleanConstant.fromValue(left.shortValue() <= right.doubleValue()); 880 case T_byte: return BooleanConstant.fromValue(left.shortValue() <= right.byteValue()); 881 case T_short: return BooleanConstant.fromValue(left.shortValue() <= right.shortValue()); 882 case T_int: return BooleanConstant.fromValue(left.shortValue() <= right.intValue()); 883 case T_long: return BooleanConstant.fromValue(left.shortValue() <= right.longValue()); 884 } 885 break; 886 case T_int : 887 switch (rightId){ 888 case T_char : return BooleanConstant.fromValue(left.intValue() <= right.charValue()); 889 case T_float: return BooleanConstant.fromValue(left.intValue() <= right.floatValue()); 890 case T_double: return BooleanConstant.fromValue(left.intValue() <= right.doubleValue()); 891 case T_byte: return BooleanConstant.fromValue(left.intValue() <= right.byteValue()); 892 case T_short: return BooleanConstant.fromValue(left.intValue() <= right.shortValue()); 893 case T_int: return BooleanConstant.fromValue(left.intValue() <= right.intValue()); 894 case T_long: return BooleanConstant.fromValue(left.intValue() <= right.longValue()); 895 } 896 break; 897 case T_long : 898 switch (rightId){ 899 case T_char : return BooleanConstant.fromValue(left.longValue() <= right.charValue()); 900 case T_float: return BooleanConstant.fromValue(left.longValue() <= right.floatValue()); 901 case T_double: return BooleanConstant.fromValue(left.longValue() <= right.doubleValue()); 902 case T_byte: return BooleanConstant.fromValue(left.longValue() <= right.byteValue()); 903 case T_short: return BooleanConstant.fromValue(left.longValue() <= right.shortValue()); 904 case T_int: return BooleanConstant.fromValue(left.longValue() <= right.intValue()); 905 case T_long: return BooleanConstant.fromValue(left.longValue() <= right.longValue()); 906 } 907 } 908 909 return NotAConstant; 910 } 911 912 public static final Constant computeConstantOperationMINUS(Constant left, int leftId, Constant right, int rightId) { 913 914 switch (leftId){ 915 case T_char : 916 switch (rightId){ 917 case T_char : return IntConstant.fromValue(left.charValue() - right.charValue()); 918 case T_float: return FloatConstant.fromValue(left.charValue() - right.floatValue()); 919 case T_double: return DoubleConstant.fromValue(left.charValue() - right.doubleValue()); 920 case T_byte: return IntConstant.fromValue(left.charValue() - right.byteValue()); 921 case T_short: return IntConstant.fromValue(left.charValue() - right.shortValue()); 922 case T_int: return IntConstant.fromValue(left.charValue() - right.intValue()); 923 case T_long: return LongConstant.fromValue(left.charValue() - right.longValue()); 924 } 925 break; 926 case T_float : 927 switch (rightId){ 928 case T_char : return FloatConstant.fromValue(left.floatValue() - right.charValue()); 929 case T_float: return FloatConstant.fromValue(left.floatValue() - right.floatValue()); 930 case T_double: return DoubleConstant.fromValue(left.floatValue() - right.doubleValue()); 931 case T_byte: return FloatConstant.fromValue(left.floatValue() - right.byteValue()); 932 case T_short: return FloatConstant.fromValue(left.floatValue() - right.shortValue()); 933 case T_int: return FloatConstant.fromValue(left.floatValue() - right.intValue()); 934 case T_long: return FloatConstant.fromValue(left.floatValue() - right.longValue()); 935 } 936 break; 937 case T_double : 938 switch (rightId){ 939 case T_char : return DoubleConstant.fromValue(left.doubleValue() - right.charValue()); 940 case T_float: return DoubleConstant.fromValue(left.doubleValue() - right.floatValue()); 941 case T_double: return DoubleConstant.fromValue(left.doubleValue() - right.doubleValue()); 942 case T_byte: return DoubleConstant.fromValue(left.doubleValue() - right.byteValue()); 943 case T_short: return DoubleConstant.fromValue(left.doubleValue() - right.shortValue()); 944 case T_int: return DoubleConstant.fromValue(left.doubleValue() - right.intValue()); 945 case T_long: return DoubleConstant.fromValue(left.doubleValue() - right.longValue()); 946 } 947 break; 948 case T_byte : 949 switch (rightId){ 950 case T_char : return IntConstant.fromValue(left.byteValue() - right.charValue()); 951 case T_float: return FloatConstant.fromValue(left.byteValue() - right.floatValue()); 952 case T_double: return DoubleConstant.fromValue(left.byteValue() - right.doubleValue()); 953 case T_byte: return IntConstant.fromValue(left.byteValue() - right.byteValue()); 954 case T_short: return IntConstant.fromValue(left.byteValue() - right.shortValue()); 955 case T_int: return IntConstant.fromValue(left.byteValue() - right.intValue()); 956 case T_long: return LongConstant.fromValue(left.byteValue() - right.longValue()); 957 } 958 break; 959 case T_short : 960 switch (rightId){ 961 case T_char : return IntConstant.fromValue(left.shortValue() - right.charValue()); 962 case T_float: return FloatConstant.fromValue(left.shortValue() - right.floatValue()); 963 case T_double: return DoubleConstant.fromValue(left.shortValue() - right.doubleValue()); 964 case T_byte: return IntConstant.fromValue(left.shortValue() - right.byteValue()); 965 case T_short: return IntConstant.fromValue(left.shortValue() - right.shortValue()); 966 case T_int: return IntConstant.fromValue(left.shortValue() - right.intValue()); 967 case T_long: return LongConstant.fromValue(left.shortValue() - right.longValue()); 968 } 969 break; 970 case T_int : 971 switch (rightId){ 972 case T_char : return IntConstant.fromValue(left.intValue() - right.charValue()); 973 case T_float: return FloatConstant.fromValue(left.intValue() - right.floatValue()); 974 case T_double: return DoubleConstant.fromValue(left.intValue() - right.doubleValue()); 975 case T_byte: return IntConstant.fromValue(left.intValue() - right.byteValue()); 976 case T_short: return IntConstant.fromValue(left.intValue() - right.shortValue()); 977 case T_int: return IntConstant.fromValue(left.intValue() - right.intValue()); 978 case T_long: return LongConstant.fromValue(left.intValue() - right.longValue()); 979 } 980 break; 981 case T_long : 982 switch (rightId){ 983 case T_char : return LongConstant.fromValue(left.longValue() - right.charValue()); 984 case T_float: return FloatConstant.fromValue(left.longValue() - right.floatValue()); 985 case T_double: return DoubleConstant.fromValue(left.longValue() - right.doubleValue()); 986 case T_byte: return LongConstant.fromValue(left.longValue() - right.byteValue()); 987 case T_short: return LongConstant.fromValue(left.longValue() - right.shortValue()); 988 case T_int: return LongConstant.fromValue(left.longValue() - right.intValue()); 989 case T_long: return LongConstant.fromValue(left.longValue() - right.longValue()); 990 } 991 992 } 993 994 return NotAConstant; 995 } 996 997 public static final Constant computeConstantOperationMULTIPLY(Constant left, int leftId, Constant right, int rightId) { 998 999 switch (leftId){ 1000 case T_char : 1001 switch (rightId){ 1002 case T_char : return IntConstant.fromValue(left.charValue() * right.charValue()); 1003 case T_float: return FloatConstant.fromValue(left.charValue() * right.floatValue()); 1004 case T_double: return DoubleConstant.fromValue(left.charValue() * right.doubleValue()); 1005 case T_byte: return IntConstant.fromValue(left.charValue() * right.byteValue()); 1006 case T_short: return IntConstant.fromValue(left.charValue() * right.shortValue()); 1007 case T_int: return IntConstant.fromValue(left.charValue() * right.intValue()); 1008 case T_long: return LongConstant.fromValue(left.charValue() * right.longValue()); 1009 } 1010 break; 1011 case T_float : 1012 switch (rightId){ 1013 case T_char : return FloatConstant.fromValue(left.floatValue() * right.charValue()); 1014 case T_float: return FloatConstant.fromValue(left.floatValue() * right.floatValue()); 1015 case T_double: return DoubleConstant.fromValue(left.floatValue() * right.doubleValue()); 1016 case T_byte: return FloatConstant.fromValue(left.floatValue() * right.byteValue()); 1017 case T_short: return FloatConstant.fromValue(left.floatValue() * right.shortValue()); 1018 case T_int: return FloatConstant.fromValue(left.floatValue() * right.intValue()); 1019 case T_long: return FloatConstant.fromValue(left.floatValue() * right.longValue()); 1020 } 1021 break; 1022 case T_double : 1023 switch (rightId){ 1024 case T_char : return DoubleConstant.fromValue(left.doubleValue() * right.charValue()); 1025 case T_float: return DoubleConstant.fromValue(left.doubleValue() * right.floatValue()); 1026 case T_double: return DoubleConstant.fromValue(left.doubleValue() * right.doubleValue()); 1027 case T_byte: return DoubleConstant.fromValue(left.doubleValue() * right.byteValue()); 1028 case T_short: return DoubleConstant.fromValue(left.doubleValue() * right.shortValue()); 1029 case T_int: return DoubleConstant.fromValue(left.doubleValue() * right.intValue()); 1030 case T_long: return DoubleConstant.fromValue(left.doubleValue() * right.longValue()); 1031 } 1032 break; 1033 case T_byte : 1034 switch (rightId){ 1035 case T_char : return IntConstant.fromValue(left.byteValue() * right.charValue()); 1036 case T_float: return FloatConstant.fromValue(left.byteValue() * right.floatValue()); 1037 case T_double: return DoubleConstant.fromValue(left.byteValue() * right.doubleValue()); 1038 case T_byte: return IntConstant.fromValue(left.byteValue() * right.byteValue()); 1039 case T_short: return IntConstant.fromValue(left.byteValue() * right.shortValue()); 1040 case T_int: return IntConstant.fromValue(left.byteValue() * right.intValue()); 1041 case T_long: return LongConstant.fromValue(left.byteValue() * right.longValue()); 1042 } 1043 break; 1044 case T_short : 1045 switch (rightId){ 1046 case T_char : return IntConstant.fromValue(left.shortValue() * right.charValue()); 1047 case T_float: return FloatConstant.fromValue(left.shortValue() * right.floatValue()); 1048 case T_double: return DoubleConstant.fromValue(left.shortValue() * right.doubleValue()); 1049 case T_byte: return IntConstant.fromValue(left.shortValue() * right.byteValue()); 1050 case T_short: return IntConstant.fromValue(left.shortValue() * right.shortValue()); 1051 case T_int: return IntConstant.fromValue(left.shortValue() * right.intValue()); 1052 case T_long: return LongConstant.fromValue(left.shortValue() * right.longValue()); 1053 } 1054 break; 1055 case T_int : 1056 switch (rightId){ 1057 case T_char : return IntConstant.fromValue(left.intValue() * right.charValue()); 1058 case T_float: return FloatConstant.fromValue(left.intValue() * right.floatValue()); 1059 case T_double: return DoubleConstant.fromValue(left.intValue() * right.doubleValue()); 1060 case T_byte: return IntConstant.fromValue(left.intValue() * right.byteValue()); 1061 case T_short: return IntConstant.fromValue(left.intValue() * right.shortValue()); 1062 case T_int: return IntConstant.fromValue(left.intValue() * right.intValue()); 1063 case T_long: return LongConstant.fromValue(left.intValue() * right.longValue()); 1064 } 1065 break; 1066 case T_long : 1067 switch (rightId){ 1068 case T_char : return LongConstant.fromValue(left.longValue() * right.charValue()); 1069 case T_float: return FloatConstant.fromValue(left.longValue() * right.floatValue()); 1070 case T_double: return DoubleConstant.fromValue(left.longValue() * right.doubleValue()); 1071 case T_byte: return LongConstant.fromValue(left.longValue() * right.byteValue()); 1072 case T_short: return LongConstant.fromValue(left.longValue() * right.shortValue()); 1073 case T_int: return LongConstant.fromValue(left.longValue() * right.intValue()); 1074 case T_long: return LongConstant.fromValue(left.longValue() * right.longValue()); 1075 } 1076 } 1077 1078 return NotAConstant; 1079 } 1080 1081 public static final Constant computeConstantOperationOR(Constant left, int leftId, Constant right, int rightId) { 1082 1083 switch (leftId){ 1084 case T_boolean : return BooleanConstant.fromValue(left.booleanValue() | right.booleanValue()); 1085 case T_char : 1086 switch (rightId){ 1087 case T_char : return IntConstant.fromValue(left.charValue() | right.charValue()); 1088 case T_byte: return IntConstant.fromValue(left.charValue() | right.byteValue()); 1089 case T_short: return IntConstant.fromValue(left.charValue() | right.shortValue()); 1090 case T_int: return IntConstant.fromValue(left.charValue() | right.intValue()); 1091 case T_long: return LongConstant.fromValue(left.charValue() | right.longValue()); 1092 } 1093 break; 1094 case T_byte : 1095 switch (rightId){ 1096 case T_char : return IntConstant.fromValue(left.byteValue() | right.charValue()); 1097 case T_byte: return IntConstant.fromValue(left.byteValue() | right.byteValue()); 1098 case T_short: return IntConstant.fromValue(left.byteValue() | right.shortValue()); 1099 case T_int: return IntConstant.fromValue(left.byteValue() | right.intValue()); 1100 case T_long: return LongConstant.fromValue(left.byteValue() | right.longValue()); 1101 } 1102 break; 1103 case T_short : 1104 switch (rightId){ 1105 case T_char : return IntConstant.fromValue(left.shortValue() | right.charValue()); 1106 case T_byte: return IntConstant.fromValue(left.shortValue() | right.byteValue()); 1107 case T_short: return IntConstant.fromValue(left.shortValue() | right.shortValue()); 1108 case T_int: return IntConstant.fromValue(left.shortValue() | right.intValue()); 1109 case T_long: return LongConstant.fromValue(left.shortValue() | right.longValue()); 1110 } 1111 break; 1112 case T_int : 1113 switch (rightId){ 1114 case T_char : return IntConstant.fromValue(left.intValue() | right.charValue()); 1115 case T_byte: return IntConstant.fromValue(left.intValue() | right.byteValue()); 1116 case T_short: return IntConstant.fromValue(left.intValue() | right.shortValue()); 1117 case T_int: return IntConstant.fromValue(left.intValue() | right.intValue()); 1118 case T_long: return LongConstant.fromValue(left.intValue() | right.longValue()); 1119 } 1120 break; 1121 case T_long : 1122 switch (rightId){ 1123 case T_char : return LongConstant.fromValue(left.longValue() | right.charValue()); 1124 case T_byte: return LongConstant.fromValue(left.longValue() | right.byteValue()); 1125 case T_short: return LongConstant.fromValue(left.longValue() | right.shortValue()); 1126 case T_int: return LongConstant.fromValue(left.longValue() | right.intValue()); 1127 case T_long: return LongConstant.fromValue(left.longValue() | right.longValue()); 1128 } 1129 1130 } 1131 1132 return NotAConstant; 1133 } 1134 1135 public static final Constant computeConstantOperationOR_OR(Constant left, int leftId, Constant right, int rightId) { 1136 1137 return BooleanConstant.fromValue(left.booleanValue() || right.booleanValue()); 1138 } 1139 1140 public static final Constant computeConstantOperationPLUS(Constant left, int leftId, Constant right, int rightId) { 1141 1142 switch (leftId){ 1143 case T_JavaLangObject : 1144 if (rightId == T_JavaLangString) { 1145 return StringConstant.fromValue(left.stringValue() + right.stringValue()); 1146 } 1147 case T_boolean : 1148 if (rightId == T_JavaLangString) { 1149 return StringConstant.fromValue(left.stringValue() + right.stringValue()); 1150 } 1151 break; 1152 case T_char : 1153 switch (rightId){ 1154 case T_char : return IntConstant.fromValue(left.charValue() + right.charValue()); 1155 case T_float: return FloatConstant.fromValue(left.charValue() + right.floatValue()); 1156 case T_double: return DoubleConstant.fromValue(left.charValue() + right.doubleValue()); 1157 case T_byte: return IntConstant.fromValue(left.charValue() + right.byteValue()); 1158 case T_short: return IntConstant.fromValue(left.charValue() + right.shortValue()); 1159 case T_int: return IntConstant.fromValue(left.charValue() + right.intValue()); 1160 case T_long: return LongConstant.fromValue(left.charValue() + right.longValue()); 1161 case T_JavaLangString: return StringConstant.fromValue(left.stringValue() + right.stringValue()); 1162 } 1163 break; 1164 case T_float : 1165 switch (rightId){ 1166 case T_char : return FloatConstant.fromValue(left.floatValue() + right.charValue()); 1167 case T_float: return FloatConstant.fromValue(left.floatValue() + right.floatValue()); 1168 case T_double: return DoubleConstant.fromValue(left.floatValue() + right.doubleValue()); 1169 case T_byte: return FloatConstant.fromValue(left.floatValue() + right.byteValue()); 1170 case T_short: return FloatConstant.fromValue(left.floatValue() + right.shortValue()); 1171 case T_int: return FloatConstant.fromValue(left.floatValue() + right.intValue()); 1172 case T_long: return FloatConstant.fromValue(left.floatValue() + right.longValue()); 1173 case T_JavaLangString: return StringConstant.fromValue(left.stringValue() + right.stringValue()); 1174 } 1175 break; 1176 case T_double : 1177 switch (rightId){ 1178 case T_char : return DoubleConstant.fromValue(left.doubleValue() + right.charValue()); 1179 case T_float: return DoubleConstant.fromValue(left.doubleValue() + right.floatValue()); 1180 case T_double: return DoubleConstant.fromValue(left.doubleValue() + right.doubleValue()); 1181 case T_byte: return DoubleConstant.fromValue(left.doubleValue() + right.byteValue()); 1182 case T_short: return DoubleConstant.fromValue(left.doubleValue() + right.shortValue()); 1183 case T_int: return DoubleConstant.fromValue(left.doubleValue() + right.intValue()); 1184 case T_long: return DoubleConstant.fromValue(left.doubleValue() + right.longValue()); 1185 case T_JavaLangString: return StringConstant.fromValue(left.stringValue() + right.stringValue()); 1186 } 1187 break; 1188 case T_byte : 1189 switch (rightId){ 1190 case T_char : return IntConstant.fromValue(left.byteValue() + right.charValue()); 1191 case T_float: return FloatConstant.fromValue(left.byteValue() + right.floatValue()); 1192 case T_double: return DoubleConstant.fromValue(left.byteValue() + right.doubleValue()); 1193 case T_byte: return IntConstant.fromValue(left.byteValue() + right.byteValue()); 1194 case T_short: return IntConstant.fromValue(left.byteValue() + right.shortValue()); 1195 case T_int: return IntConstant.fromValue(left.byteValue() + right.intValue()); 1196 case T_long: return LongConstant.fromValue(left.byteValue() + right.longValue()); 1197 case T_JavaLangString: return StringConstant.fromValue(left.stringValue() + right.stringValue()); 1198 } 1199 1200 break; 1201 case T_short : 1202 switch (rightId){ 1203 case T_char : return IntConstant.fromValue(left.shortValue() + right.charValue()); 1204 case T_float: return FloatConstant.fromValue(left.shortValue() + right.floatValue()); 1205 case T_double: return DoubleConstant.fromValue(left.shortValue() + right.doubleValue()); 1206 case T_byte: return IntConstant.fromValue(left.shortValue() + right.byteValue()); 1207 case T_short: return IntConstant.fromValue(left.shortValue() + right.shortValue()); 1208 case T_int: return IntConstant.fromValue(left.shortValue() + right.intValue()); 1209 case T_long: return LongConstant.fromValue(left.shortValue() + right.longValue()); 1210 case T_JavaLangString: return StringConstant.fromValue(left.stringValue() + right.stringValue()); 1211 } 1212 break; 1213 case T_int : 1214 switch (rightId){ 1215 case T_char : return IntConstant.fromValue(left.intValue() + right.charValue()); 1216 case T_float: return FloatConstant.fromValue(left.intValue() + right.floatValue()); 1217 case T_double: return DoubleConstant.fromValue(left.intValue() + right.doubleValue()); 1218 case T_byte: return IntConstant.fromValue(left.intValue() + right.byteValue()); 1219 case T_short: return IntConstant.fromValue(left.intValue() + right.shortValue()); 1220 case T_int: return IntConstant.fromValue(left.intValue() + right.intValue()); 1221 case T_long: return LongConstant.fromValue(left.intValue() + right.longValue()); 1222 case T_JavaLangString: return StringConstant.fromValue(left.stringValue() + right.stringValue()); 1223 } 1224 break; 1225 case T_long : 1226 switch (rightId){ 1227 case T_char : return LongConstant.fromValue(left.longValue() + right.charValue()); 1228 case T_float: return FloatConstant.fromValue(left.longValue() + right.floatValue()); 1229 case T_double: return DoubleConstant.fromValue(left.longValue() + right.doubleValue()); 1230 case T_byte: return LongConstant.fromValue(left.longValue() + right.byteValue()); 1231 case T_short: return LongConstant.fromValue(left.longValue() + right.shortValue()); 1232 case T_int: return LongConstant.fromValue(left.longValue() + right.intValue()); 1233 case T_long: return LongConstant.fromValue(left.longValue() + right.longValue()); 1234 case T_JavaLangString: return StringConstant.fromValue(left.stringValue() + right.stringValue()); 1235 } 1236 break; 1237 case T_JavaLangString : 1238 switch (rightId){ 1239 case T_char : return StringConstant.fromValue(left.stringValue() + String.valueOf(right.charValue())); 1240 case T_float: return StringConstant.fromValue(left.stringValue() + String.valueOf(right.floatValue())); 1241 case T_double: return StringConstant.fromValue(left.stringValue() + String.valueOf(right.doubleValue())); 1242 case T_byte: return StringConstant.fromValue(left.stringValue() + String.valueOf(right.byteValue())); 1243 case T_short: return StringConstant.fromValue(left.stringValue() + String.valueOf(right.shortValue())); 1244 case T_int: return StringConstant.fromValue(left.stringValue() + String.valueOf(right.intValue())); 1245 case T_long: return StringConstant.fromValue(left.stringValue() + String.valueOf(right.longValue())); 1246 case T_JavaLangString: return StringConstant.fromValue(left.stringValue() + right.stringValue()); 1247 case T_boolean: return StringConstant.fromValue(left.stringValue() + right.booleanValue()); 1248 } 1249 break; 1250 } 1263 1264 return NotAConstant; 1265 } 1266 1267 public static final Constant computeConstantOperationREMAINDER(Constant left, int leftId, Constant right, int rightId) { 1268 1269 switch (leftId){ 1270 case T_char : 1271 switch (rightId){ 1272 case T_char : return IntConstant.fromValue(left.charValue() % right.charValue()); 1273 case T_float: return FloatConstant.fromValue(left.charValue() % right.floatValue()); 1274 case T_double: return DoubleConstant.fromValue(left.charValue() % right.doubleValue()); 1275 case T_byte: return IntConstant.fromValue(left.charValue() % right.byteValue()); 1276 case T_short: return IntConstant.fromValue(left.charValue() % right.shortValue()); 1277 case T_int: return IntConstant.fromValue(left.charValue() % right.intValue()); 1278 case T_long: return LongConstant.fromValue(left.charValue() % right.longValue()); 1279 } 1280 break; 1281 case T_float : 1282 switch (rightId){ 1283 case T_char : return FloatConstant.fromValue(left.floatValue() % right.charValue()); 1284 case T_float: return FloatConstant.fromValue(left.floatValue() % right.floatValue()); 1285 case T_double: return DoubleConstant.fromValue(left.floatValue() % right.doubleValue()); 1286 case T_byte: return FloatConstant.fromValue(left.floatValue() % right.byteValue()); 1287 case T_short: return FloatConstant.fromValue(left.floatValue() % right.shortValue()); 1288 case T_int: return FloatConstant.fromValue(left.floatValue() % right.intValue()); 1289 case T_long: return FloatConstant.fromValue(left.floatValue() % right.longValue()); 1290 } 1291 break; 1292 case T_double : 1293 switch (rightId){ 1294 case T_char : return DoubleConstant.fromValue(left.doubleValue() % right.charValue()); 1295 case T_float: return DoubleConstant.fromValue(left.doubleValue() % right.floatValue()); 1296 case T_double: return DoubleConstant.fromValue(left.doubleValue() % right.doubleValue()); 1297 case T_byte: return DoubleConstant.fromValue(left.doubleValue() % right.byteValue()); 1298 case T_short: return DoubleConstant.fromValue(left.doubleValue() % right.shortValue()); 1299 case T_int: return DoubleConstant.fromValue(left.doubleValue() % right.intValue()); 1300 case T_long: return DoubleConstant.fromValue(left.doubleValue() % right.longValue()); 1301 } 1302 break; 1303 case T_byte : 1304 switch (rightId){ 1305 case T_char : return IntConstant.fromValue(left.byteValue() % right.charValue()); 1306 case T_float: return FloatConstant.fromValue(left.byteValue() % right.floatValue()); 1307 case T_double: return DoubleConstant.fromValue(left.byteValue() % right.doubleValue()); 1308 case T_byte: return IntConstant.fromValue(left.byteValue() % right.byteValue()); 1309 case T_short: return IntConstant.fromValue(left.byteValue() % right.shortValue()); 1310 case T_int: return IntConstant.fromValue(left.byteValue() % right.intValue()); 1311 case T_long: return LongConstant.fromValue(left.byteValue() % right.longValue()); 1312 } 1313 break; 1314 case T_short : 1315 switch (rightId){ 1316 case T_char : return IntConstant.fromValue(left.shortValue() % right.charValue()); 1317 case T_float: return FloatConstant.fromValue(left.shortValue() % right.floatValue()); 1318 case T_double: return DoubleConstant.fromValue(left.shortValue() % right.doubleValue()); 1319 case T_byte: return IntConstant.fromValue(left.shortValue() % right.byteValue()); 1320 case T_short: return IntConstant.fromValue(left.shortValue() % right.shortValue()); 1321 case T_int: return IntConstant.fromValue(left.shortValue() % right.intValue()); 1322 case T_long: return LongConstant.fromValue(left.shortValue() % right.longValue()); 1323 } 1324 break; 1325 case T_int : 1326 switch (rightId){ 1327 case T_char : return IntConstant.fromValue(left.intValue() % right.charValue()); 1328 case T_float: return FloatConstant.fromValue(left.intValue() % right.floatValue()); 1329 case T_double: return DoubleConstant.fromValue(left.intValue() % right.doubleValue()); 1330 case T_byte: return IntConstant.fromValue(left.intValue() % right.byteValue()); 1331 case T_short: return IntConstant.fromValue(left.intValue() % right.shortValue()); 1332 case T_int: return IntConstant.fromValue(left.intValue() % right.intValue()); 1333 case T_long: return LongConstant.fromValue(left.intValue() % right.longValue()); 1334 } 1335 break; 1336 case T_long : 1337 switch (rightId){ 1338 case T_char : return LongConstant.fromValue(left.longValue() % right.charValue()); 1339 case T_float: return FloatConstant.fromValue(left.longValue() % right.floatValue()); 1340 case T_double: return DoubleConstant.fromValue(left.longValue() % right.doubleValue()); 1341 case T_byte: return LongConstant.fromValue(left.longValue() % right.byteValue()); 1342 case T_short: return LongConstant.fromValue(left.longValue() % right.shortValue()); 1343 case T_int: return LongConstant.fromValue(left.longValue() % right.intValue()); 1344 case T_long: return LongConstant.fromValue(left.longValue() % right.longValue()); 1345 } 1346 1347 } 1348 1349 return NotAConstant; 1350 } 1351 1352 public static final Constant computeConstantOperationRIGHT_SHIFT(Constant left, int leftId, Constant right, int rightId) { 1353 1354 switch (leftId){ 1355 case T_char : 1356 switch (rightId){ 1357 case T_char : return IntConstant.fromValue(left.charValue() >> right.charValue()); 1358 case T_byte: return IntConstant.fromValue(left.charValue() >> right.byteValue()); 1359 case T_short: return IntConstant.fromValue(left.charValue() >> right.shortValue()); 1360 case T_int: return IntConstant.fromValue(left.charValue() >> right.intValue()); 1361 case T_long: return IntConstant.fromValue(left.charValue() >> right.longValue()); 1362 } 1363 break; 1364 case T_byte : 1365 switch (rightId){ 1366 case T_char : return IntConstant.fromValue(left.byteValue() >> right.charValue()); 1367 case T_byte: return IntConstant.fromValue(left.byteValue() >> right.byteValue()); 1368 case T_short: return IntConstant.fromValue(left.byteValue() >> right.shortValue()); 1369 case T_int: return IntConstant.fromValue(left.byteValue() >> right.intValue()); 1370 case T_long: return IntConstant.fromValue(left.byteValue() >> right.longValue()); 1371 } 1372 break; 1373 case T_short : 1374 switch (rightId){ 1375 case T_char : return IntConstant.fromValue(left.shortValue() >> right.charValue()); 1376 case T_byte: return IntConstant.fromValue(left.shortValue() >> right.byteValue()); 1377 case T_short: return IntConstant.fromValue(left.shortValue() >> right.shortValue()); 1378 case T_int: return IntConstant.fromValue(left.shortValue() >> right.intValue()); 1379 case T_long: return IntConstant.fromValue(left.shortValue() >> right.longValue()); 1380 } 1381 break; 1382 case T_int : 1383 switch (rightId){ 1384 case T_char : return IntConstant.fromValue(left.intValue() >> right.charValue()); 1385 case T_byte: return IntConstant.fromValue(left.intValue() >> right.byteValue()); 1386 case T_short: return IntConstant.fromValue(left.intValue() >> right.shortValue()); 1387 case T_int: return IntConstant.fromValue(left.intValue() >> right.intValue()); 1388 case T_long: return IntConstant.fromValue(left.intValue() >> right.longValue()); 1389 } 1390 break; 1391 case T_long : 1392 switch (rightId){ 1393 case T_char : return LongConstant.fromValue(left.longValue() >> right.charValue()); 1394 case T_byte: return LongConstant.fromValue(left.longValue() >> right.byteValue()); 1395 case T_short: return LongConstant.fromValue(left.longValue() >> right.shortValue()); 1396 case T_int: return LongConstant.fromValue(left.longValue() >> right.intValue()); 1397 case T_long: return LongConstant.fromValue(left.longValue() >> right.longValue()); 1398 } 1399 1400 } 1401 1402 return NotAConstant; 1403 } 1404 1405 public static final Constant computeConstantOperationUNSIGNED_RIGHT_SHIFT(Constant left, int leftId, Constant right, int rightId) { 1406 1407 switch (leftId){ 1408 case T_char : 1409 switch (rightId){ 1410 case T_char : return IntConstant.fromValue(left.charValue() >>> right.charValue()); 1411 case T_byte: return IntConstant.fromValue(left.charValue() >>> right.byteValue()); 1412 case T_short: return IntConstant.fromValue(left.charValue() >>> right.shortValue()); 1413 case T_int: return IntConstant.fromValue(left.charValue() >>> right.intValue()); 1414 case T_long: return IntConstant.fromValue(left.charValue() >>> right.longValue()); 1415 } 1416 break; 1417 case T_byte : 1418 switch (rightId){ 1419 case T_char : return IntConstant.fromValue(left.byteValue() >>> right.charValue()); 1420 case T_byte: return IntConstant.fromValue(left.byteValue() >>> right.byteValue()); 1421 case T_short: return IntConstant.fromValue(left.byteValue() >>> right.shortValue()); 1422 case T_int: return IntConstant.fromValue(left.byteValue() >>> right.intValue()); 1423 case T_long: return IntConstant.fromValue(left.byteValue() >>> right.longValue()); 1424 } 1425 break; 1426 case T_short : 1427 switch (rightId){ 1428 case T_char : return IntConstant.fromValue(left.shortValue() >>> right.charValue()); 1429 case T_byte: return IntConstant.fromValue(left.shortValue() >>> right.byteValue()); 1430 case T_short: return IntConstant.fromValue(left.shortValue() >>> right.shortValue()); 1431 case T_int: return IntConstant.fromValue(left.shortValue() >>> right.intValue()); 1432 case T_long: return IntConstant.fromValue(left.shortValue() >>> right.longValue()); 1433 } 1434 break; 1435 case T_int : 1436 switch (rightId){ 1437 case T_char : return IntConstant.fromValue(left.intValue() >>> right.charValue()); 1438 case T_byte: return IntConstant.fromValue(left.intValue() >>> right.byteValue()); 1439 case T_short: return IntConstant.fromValue(left.intValue() >>> right.shortValue()); 1440 case T_int: return IntConstant.fromValue(left.intValue() >>> right.intValue()); 1441 case T_long: return IntConstant.fromValue(left.intValue() >>> right.longValue()); 1442 } 1443 break; 1444 case T_long : 1445 switch (rightId){ 1446 case T_char : return LongConstant.fromValue(left.longValue() >>> right.charValue()); 1447 case T_byte: return LongConstant.fromValue(left.longValue() >>> right.byteValue()); 1448 case T_short: return LongConstant.fromValue(left.longValue() >>> right.shortValue()); 1449 case T_int: return LongConstant.fromValue(left.longValue() >>> right.intValue()); 1450 case T_long: return LongConstant.fromValue(left.longValue() >>> right.longValue()); 1451 } 1452 1453 } 1454 1455 return NotAConstant; 1456 } 1457 1458 public static final Constant computeConstantOperationXOR(Constant left, int leftId, Constant right, int rightId) { 1459 1460 switch (leftId){ 1461 case T_boolean : return BooleanConstant.fromValue(left.booleanValue() ^ right.booleanValue()); 1462 case T_char : 1463 switch (rightId){ 1464 case T_char : return IntConstant.fromValue(left.charValue() ^ right.charValue()); 1465 case T_byte: return IntConstant.fromValue(left.charValue() ^ right.byteValue()); 1466 case T_short: return IntConstant.fromValue(left.charValue() ^ right.shortValue()); 1467 case T_int: return IntConstant.fromValue(left.charValue() ^ right.intValue()); 1468 case T_long: return LongConstant.fromValue(left.charValue() ^ right.longValue()); 1469 } 1470 break; 1471 case T_byte : 1472 switch (rightId){ 1473 case T_char : return IntConstant.fromValue(left.byteValue() ^ right.charValue()); 1474 case T_byte: return IntConstant.fromValue(left.byteValue() ^ right.byteValue()); 1475 case T_short: return IntConstant.fromValue(left.byteValue() ^ right.shortValue()); 1476 case T_int: return IntConstant.fromValue(left.byteValue() ^ right.intValue()); 1477 case T_long: return LongConstant.fromValue(left.byteValue() ^ right.longValue()); 1478 } 1479 break; 1480 case T_short : 1481 switch (rightId){ 1482 case T_char : return IntConstant.fromValue(left.shortValue() ^ right.charValue()); 1483 case T_byte: return IntConstant.fromValue(left.shortValue() ^ right.byteValue()); 1484 case T_short: return IntConstant.fromValue(left.shortValue() ^ right.shortValue()); 1485 case T_int: return IntConstant.fromValue(left.shortValue() ^ right.intValue()); 1486 case T_long: return LongConstant.fromValue(left.shortValue() ^ right.longValue()); 1487 } 1488 break; 1489 case T_int : 1490 switch (rightId){ 1491 case T_char : return IntConstant.fromValue(left.intValue() ^ right.charValue()); 1492 case T_byte: return IntConstant.fromValue(left.intValue() ^ right.byteValue()); 1493 case T_short: return IntConstant.fromValue(left.intValue() ^ right.shortValue()); 1494 case T_int: return IntConstant.fromValue(left.intValue() ^ right.intValue()); 1495 case T_long: return LongConstant.fromValue(left.intValue() ^ right.longValue()); 1496 } 1497 break; 1498 case T_long : 1499 switch (rightId){ 1500 case T_char : return LongConstant.fromValue(left.longValue() ^ right.charValue()); 1501 case T_byte: return LongConstant.fromValue(left.longValue() ^ right.byteValue()); 1502 case T_short: return LongConstant.fromValue(left.longValue() ^ right.shortValue()); 1503 case T_int: return LongConstant.fromValue(left.longValue() ^ right.intValue()); 1504 case T_long: return LongConstant.fromValue(left.longValue() ^ right.longValue()); 1505 } 1506 } 1507 1508 return NotAConstant; 1509 } 1510 1511 public double doubleValue() { 1512 1513 throw new ShouldNotImplement(Messages.bind(Messages.constant_cannotCastedInto, new String [] { typeName(), "double" })); } 1515 1516 public float floatValue() { 1517 1518 throw new ShouldNotImplement(Messages.bind(Messages.constant_cannotCastedInto, new String [] { typeName(), "float" })); } 1520 1524 public boolean hasSameValue(Constant otherConstant) { 1525 if (this == otherConstant) 1526 return true; 1527 int typeID; 1528 if ((typeID = typeID()) != otherConstant.typeID()) 1529 return false; 1530 switch (typeID) { 1531 case TypeIds.T_boolean: 1532 return booleanValue() == otherConstant.booleanValue(); 1533 case TypeIds.T_byte: 1534 return byteValue() == otherConstant.byteValue(); 1535 case TypeIds.T_char: 1536 return charValue() == otherConstant.charValue(); 1537 case TypeIds.T_double: 1538 return doubleValue() == otherConstant.doubleValue(); 1539 case TypeIds.T_float: 1540 return floatValue() == otherConstant.floatValue(); 1541 case TypeIds.T_int: 1542 return intValue() == otherConstant.intValue(); 1543 case TypeIds.T_short: 1544 return shortValue() == otherConstant.shortValue(); 1545 case TypeIds.T_long: 1546 return longValue() == otherConstant.longValue(); 1547 case TypeIds.T_JavaLangString: 1548 String value = stringValue(); 1549 return value == null 1550 ? otherConstant.stringValue() == null 1551 : value.equals(otherConstant.stringValue()); 1552 } 1553 return false; 1554 } 1555 1556 public int intValue() { 1557 1558 throw new ShouldNotImplement(Messages.bind(Messages.constant_cannotCastedInto, new String [] { typeName(), "int" })); } 1560 1561 public long longValue() { 1562 1563 throw new ShouldNotImplement(Messages.bind(Messages.constant_cannotCastedInto, new String [] { typeName(), "long" })); } 1565 1566 public short shortValue() { 1567 1568 throw new ShouldNotImplement(Messages.bind(Messages.constant_cannotConvertedTo, new String [] { typeName(), "short" })); } 1570 1571 public String stringValue() { 1572 1573 throw new ShouldNotImplement(Messages.bind(Messages.constant_cannotConvertedTo, new String [] { typeName(), "String" })); } 1575 1576 public String toString(){ 1577 1578 if (this == NotAConstant) return "(Constant) NotAConstant"; return super.toString(); } 1580 1581 public abstract int typeID(); 1582 1583 public String typeName() { 1584 switch (typeID()) { 1585 case T_int : return "int"; case T_byte : return "byte"; case T_short : return "short"; case T_char : return "char"; case T_float : return "float"; case T_double : return "double"; case T_boolean : return "boolean"; case T_long : return "long"; case T_JavaLangString : return "java.lang.String"; case T_null : return "null"; default: return "unknown"; } 1597 } 1598} 1599 | Popular Tags |