Mercurial > hg > graal-jvmci-8
comparison graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/ElementUtils.java @ 18805:121748e43a01
Truffle-DSL: fix execute methods with evaluated arguments were not handled correctly with varargs arguments.
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Fri, 09 Jan 2015 16:02:55 +0100 |
parents | c0fb70634640 |
children | ae81dd154fb6 |
comparison
equal
deleted
inserted
replaced
18804:07b61dff860f | 18805:121748e43a01 |
---|---|
1077 return type; | 1077 return type; |
1078 } | 1078 } |
1079 return new DeclaredCodeTypeMirror((TypeElement) declaredType.asElement()); | 1079 return new DeclaredCodeTypeMirror((TypeElement) declaredType.asElement()); |
1080 } | 1080 } |
1081 | 1081 |
1082 public static ExecutableElement findMethod(TypeElement type, Set<Modifier> includeModifiers, Set<Modifier> excludeModifiers, String methodName, List<TypeMirror> types) { | |
1083 outer: for (ExecutableElement executable : ElementFilter.methodsIn(type.getEnclosedElements())) { | |
1084 if (includeModifiers != null) { | |
1085 if (!executable.getModifiers().containsAll(includeModifiers)) { | |
1086 continue; | |
1087 } | |
1088 } | |
1089 if (excludeModifiers != null) { | |
1090 if (executable.getModifiers().containsAll(excludeModifiers)) { | |
1091 continue; | |
1092 } | |
1093 } | |
1094 if (!executable.getSimpleName().toString().equals(methodName)) { | |
1095 continue; | |
1096 } | |
1097 if (types.size() != executable.getParameters().size()) { | |
1098 continue; | |
1099 } | |
1100 for (int i = 0; i < types.size(); i++) { | |
1101 TypeMirror var1 = types.get(i); | |
1102 VariableElement var2 = executable.getParameters().get(i); | |
1103 if (ElementUtils.typeEquals(var1, var2.asType())) { | |
1104 continue outer; | |
1105 } | |
1106 } | |
1107 return executable; | |
1108 } | |
1109 return null; | |
1110 } | |
1111 | |
1112 public static List<TypeMirror> asTypes(List<? extends Element> elements) { | |
1113 List<TypeMirror> types = new ArrayList<>(elements.size()); | |
1114 for (Element element : elements) { | |
1115 types.add(element.asType()); | |
1116 } | |
1117 return types; | |
1118 } | |
1119 | |
1082 } | 1120 } |