equal
deleted
inserted
replaced
380 } |
380 } |
381 |
381 |
382 /** Returns class name in "internal" form (i.e., '/' separators |
382 /** Returns class name in "internal" form (i.e., '/' separators |
383 instead of '.') */ |
383 instead of '.') */ |
384 protected static String getClassName |
384 protected static String getClassName |
385 (Class c, boolean addPrefixAndSuffixForNonPrimitiveTypes) |
385 (Class<?> c, boolean addPrefixAndSuffixForNonPrimitiveTypes) |
386 { |
386 { |
387 if (c.isPrimitive()) { |
387 if (c.isPrimitive()) { |
388 if (c == Boolean.TYPE) { |
388 if (c == Boolean.TYPE) { |
389 return "Z"; |
389 return "Z"; |
390 } else if (c == Byte.TYPE) { |
390 } else if (c == Byte.TYPE) { |
488 asm.emitShort(checkedExceptionIndices[i]); |
488 asm.emitShort(checkedExceptionIndices[i]); |
489 } |
489 } |
490 } |
490 } |
491 } |
491 } |
492 |
492 |
493 protected short indexForPrimitiveType(Class type) { |
493 protected short indexForPrimitiveType(Class<?> type) { |
494 if (type == Boolean.TYPE) { |
494 if (type == Boolean.TYPE) { |
495 return booleanIdx; |
495 return booleanIdx; |
496 } else if (type == Byte.TYPE) { |
496 } else if (type == Byte.TYPE) { |
497 return byteIdx; |
497 return byteIdx; |
498 } else if (type == Character.TYPE) { |
498 } else if (type == Character.TYPE) { |
509 return shortIdx; |
509 return shortIdx; |
510 } |
510 } |
511 throw new InternalError("Should have found primitive type"); |
511 throw new InternalError("Should have found primitive type"); |
512 } |
512 } |
513 |
513 |
514 protected short ctorIndexForPrimitiveType(Class type) { |
514 protected short ctorIndexForPrimitiveType(Class<?> type) { |
515 if (type == Boolean.TYPE) { |
515 if (type == Boolean.TYPE) { |
516 return booleanCtorIdx; |
516 return booleanCtorIdx; |
517 } else if (type == Byte.TYPE) { |
517 } else if (type == Byte.TYPE) { |
518 return byteCtorIdx; |
518 return byteCtorIdx; |
519 } else if (type == Character.TYPE) { |
519 } else if (type == Character.TYPE) { |
532 throw new InternalError("Should have found primitive type"); |
532 throw new InternalError("Should have found primitive type"); |
533 } |
533 } |
534 |
534 |
535 /** Returns true for widening or identity conversions for primitive |
535 /** Returns true for widening or identity conversions for primitive |
536 types only */ |
536 types only */ |
537 protected static boolean canWidenTo(Class type, Class otherType) { |
537 protected static boolean canWidenTo(Class<?> type, Class<?> otherType) { |
538 if (!type.isPrimitive()) { |
538 if (!type.isPrimitive()) { |
539 return false; |
539 return false; |
540 } |
540 } |
541 |
541 |
542 // Widening conversions (from JVM spec): |
542 // Widening conversions (from JVM spec): |
607 (or none if the identity conversion). Requires that a primitive |
607 (or none if the identity conversion). Requires that a primitive |
608 conversion exists; i.e., canWidenTo must have already been |
608 conversion exists; i.e., canWidenTo must have already been |
609 called and returned true. */ |
609 called and returned true. */ |
610 protected static void emitWideningBytecodeForPrimitiveConversion |
610 protected static void emitWideningBytecodeForPrimitiveConversion |
611 (ClassFileAssembler cb, |
611 (ClassFileAssembler cb, |
612 Class fromType, |
612 Class<?> fromType, |
613 Class toType) |
613 Class<?> toType) |
614 { |
614 { |
615 // Note that widening conversions for integral types (i.e., "b2s", |
615 // Note that widening conversions for integral types (i.e., "b2s", |
616 // "s2i") are no-ops since values on the Java stack are |
616 // "s2i") are no-ops since values on the Java stack are |
617 // sign-extended. |
617 // sign-extended. |
618 |
618 |
648 } |
648 } |
649 |
649 |
650 // Otherwise, was identity or no-op conversion. Fall through. |
650 // Otherwise, was identity or no-op conversion. Fall through. |
651 } |
651 } |
652 |
652 |
653 protected short unboxingMethodForPrimitiveType(Class primType) { |
653 protected short unboxingMethodForPrimitiveType(Class<?> primType) { |
654 if (primType == Boolean.TYPE) { |
654 if (primType == Boolean.TYPE) { |
655 return booleanUnboxIdx; |
655 return booleanUnboxIdx; |
656 } else if (primType == Byte.TYPE) { |
656 } else if (primType == Byte.TYPE) { |
657 return byteUnboxIdx; |
657 return byteUnboxIdx; |
658 } else if (primType == Character.TYPE) { |
658 } else if (primType == Character.TYPE) { |
669 return doubleUnboxIdx; |
669 return doubleUnboxIdx; |
670 } |
670 } |
671 throw new InternalError("Illegal primitive type " + primType.getName()); |
671 throw new InternalError("Illegal primitive type " + primType.getName()); |
672 } |
672 } |
673 |
673 |
674 protected static final Class[] primitiveTypes = new Class[] { |
674 protected static final Class<?>[] primitiveTypes = new Class<?>[] { |
675 Boolean.TYPE, |
675 Boolean.TYPE, |
676 Byte.TYPE, |
676 Byte.TYPE, |
677 Character.TYPE, |
677 Character.TYPE, |
678 Short.TYPE, |
678 Short.TYPE, |
679 Integer.TYPE, |
679 Integer.TYPE, |
681 Float.TYPE, |
681 Float.TYPE, |
682 Double.TYPE |
682 Double.TYPE |
683 }; |
683 }; |
684 |
684 |
685 /** We don't consider "Void" to be a primitive type */ |
685 /** We don't consider "Void" to be a primitive type */ |
686 protected static boolean isPrimitive(Class c) { |
686 protected static boolean isPrimitive(Class<?> c) { |
687 return (c.isPrimitive() && c != Void.TYPE); |
687 return (c.isPrimitive() && c != Void.TYPE); |
688 } |
688 } |
689 |
689 |
690 protected int typeSizeInStackSlots(Class c) { |
690 protected int typeSizeInStackSlots(Class<?> c) { |
691 if (c == Void.TYPE) { |
691 if (c == Void.TYPE) { |
692 return 0; |
692 return 0; |
693 } |
693 } |
694 if (c == Long.TYPE || c == Double.TYPE) { |
694 if (c == Long.TYPE || c == Double.TYPE) { |
695 return 2; |
695 return 2; |