Mercurial > hg > graal-jvmci-8
comparison graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/ElementUtils.java @ 19289:62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Tue, 03 Feb 2015 15:07:07 +0100 |
parents | b339d723a06b |
children | 35c3e3af8c39 |
comparison
equal
deleted
inserted
replaced
19288:3a37116ef37f | 19289:62c43fcf5be2 |
---|---|
1118 types.add(element.asType()); | 1118 types.add(element.asType()); |
1119 } | 1119 } |
1120 return types; | 1120 return types; |
1121 } | 1121 } |
1122 | 1122 |
1123 public static boolean variableEquals(VariableElement var1, VariableElement var2) { | |
1124 if (!var1.getSimpleName().equals(var2.getSimpleName())) { | |
1125 return false; | |
1126 } | |
1127 if (!ElementUtils.typeEquals(var1.asType(), var2.asType())) { | |
1128 return false; | |
1129 } | |
1130 if (!ElementUtils.elementEquals(var1.getEnclosingElement(), var2.getEnclosingElement())) { | |
1131 return false; | |
1132 } | |
1133 return true; | |
1134 } | |
1135 | |
1136 public static boolean executableEquals(ExecutableElement var1, ExecutableElement var2) { | |
1137 if (!var1.getSimpleName().equals(var2.getSimpleName())) { | |
1138 return false; | |
1139 } | |
1140 if (var1.getParameters().size() != var2.getParameters().size()) { | |
1141 return false; | |
1142 } | |
1143 if (!ElementUtils.typeEquals(var1.asType(), var2.asType())) { | |
1144 return false; | |
1145 } | |
1146 if (!ElementUtils.elementEquals(var1.getEnclosingElement(), var2.getEnclosingElement())) { | |
1147 return false; | |
1148 } | |
1149 for (int i = 0; i < var1.getParameters().size(); i++) { | |
1150 if (!typeEquals(var1.getParameters().get(i).asType(), var2.getParameters().get(i).asType())) { | |
1151 return false; | |
1152 } | |
1153 } | |
1154 return true; | |
1155 } | |
1156 | |
1157 public static boolean elementEquals(Element element1, Element element2) { | |
1158 if (element1.getKind() != element2.getKind()) { | |
1159 return false; | |
1160 } else if (element1 instanceof VariableElement) { | |
1161 return variableEquals((VariableElement) element1, (VariableElement) element2); | |
1162 } else if (element1 instanceof ExecutableElement) { | |
1163 return executableEquals((ExecutableElement) element1, (ExecutableElement) element2); | |
1164 } else if (element1 instanceof TypeElement) { | |
1165 return typeEquals(element1.asType(), element2.asType()); | |
1166 } else if (element1 instanceof PackageElement) { | |
1167 return element1.getSimpleName().equals(element2.getSimpleName()); | |
1168 } else { | |
1169 throw new AssertionError("unsupported element type"); | |
1170 } | |
1171 } | |
1123 } | 1172 } |