comparison graal/com.oracle.truffle.codegen.processor/src/com/oracle/truffle/codegen/processor/Utils.java @ 8251:cb70ed101b5f

Added automatic generation of generic specialization which throws unsupported operation if reached.
author Christian Humer <christian.humer@gmail.com>
date Wed, 13 Mar 2013 11:32:43 +0100
parents c4c3f50fa9c2
children 5eeade940236
comparison
equal deleted inserted replaced
8250:edc414f52e2b 8251:cb70ed101b5f
746 746
747 if (isRuntimeException(exceptionType)) { 747 if (isRuntimeException(exceptionType)) {
748 return true; 748 return true;
749 } 749 }
750 750
751 // search for any supertypes 751 // search for any super types
752 TypeElement exceptionTypeElement = fromTypeMirror(exceptionType); 752 TypeElement exceptionTypeElement = fromTypeMirror(exceptionType);
753 List<TypeElement> superTypes = getSuperTypes(exceptionTypeElement); 753 List<TypeElement> superTypes = getSuperTypes(exceptionTypeElement);
754 for (TypeElement typeElement : superTypes) { 754 for (TypeElement typeElement : superTypes) {
755 if (Utils.containsType(thrownTypes, typeElement.asType())) { 755 if (Utils.containsType(thrownTypes, typeElement.asType())) {
756 return true; 756 return true;
775 775
776 private static boolean isRuntimeException(TypeMirror type) { 776 private static boolean isRuntimeException(TypeMirror type) {
777 Set<String> typeSuperSet = new HashSet<>(getQualifiedSuperTypeNames(fromTypeMirror(type))); 777 Set<String> typeSuperSet = new HashSet<>(getQualifiedSuperTypeNames(fromTypeMirror(type)));
778 String typeName = getQualifiedName(type); 778 String typeName = getQualifiedName(type);
779 if (!typeSuperSet.contains(Throwable.class.getCanonicalName()) && !typeName.equals(Throwable.class.getCanonicalName())) { 779 if (!typeSuperSet.contains(Throwable.class.getCanonicalName()) && !typeName.equals(Throwable.class.getCanonicalName())) {
780 throw new IllegalArgumentException("Given does not extend Throwable."); 780 throw new IllegalArgumentException("Given type does not extend Throwable.");
781 } 781 }
782 return typeSuperSet.contains(RuntimeException.class.getCanonicalName()) || typeName.equals(RuntimeException.class.getCanonicalName()); 782 return typeSuperSet.contains(RuntimeException.class.getCanonicalName()) || typeName.equals(RuntimeException.class.getCanonicalName());
783 } 783 }
784 784
785 private static boolean containsType(Collection<? extends TypeMirror> collection, TypeMirror type) { 785 private static boolean containsType(Collection<? extends TypeMirror> collection, TypeMirror type) {