Mercurial > hg > graal-jvmci-8
comparison graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/ElementUtils.java @ 20170:953c813b8e7a
DSL: allow comparison of different integral types.
author | Chris Seaton <chris.seaton@oracle.com> |
---|---|
date | Sun, 05 Apr 2015 20:40:52 +0100 |
parents | 2bd8b3aa282f |
children | 3648df587223 |
comparison
equal
deleted
inserted
replaced
20169:65d29fa81397 | 20170:953c813b8e7a |
---|---|
932 return false; | 932 return false; |
933 } | 933 } |
934 } | 934 } |
935 } | 935 } |
936 | 936 |
937 public static boolean typeCompatible(TypeMirror type1, TypeMirror type2) { | |
938 if (typeEquals(type1, type2)) { | |
939 return true; | |
940 } else if (kindIsIntegral(type1.getKind())) { | |
941 return kindIsIntegral(type2.getKind()); | |
942 } else { | |
943 return false; | |
944 } | |
945 } | |
946 | |
947 private static boolean kindIsIntegral(TypeKind kind) { | |
948 return kind == TypeKind.BYTE || kind == TypeKind.SHORT || kind == TypeKind.INT || kind == TypeKind.LONG; | |
949 } | |
950 | |
937 public static List<String> getUniqueIdentifiers(List<TypeMirror> typeMirror) { | 951 public static List<String> getUniqueIdentifiers(List<TypeMirror> typeMirror) { |
938 List<String> ids = new ArrayList<>(); | 952 List<String> ids = new ArrayList<>(); |
939 for (TypeMirror type : typeMirror) { | 953 for (TypeMirror type : typeMirror) { |
940 ids.add(getUniqueIdentifier(type)); | 954 ids.add(getUniqueIdentifier(type)); |
941 } | 955 } |