comparison graal/com.oracle.graal.compiler.match.processor/src/com/oracle/graal/compiler/match/processor/MatchProcessor.java @ 21927:6a93800d10f1

Map from method name to rule should be per type not per annotation processor
author Tom Rodriguez <tom.rodriguez@oracle.com>
date Thu, 11 Jun 2015 12:15:19 -0700
parents 93c50cefb9e8
children
comparison
equal deleted inserted replaced
21926:607a5d806916 21927:6a93800d10f1
331 /** 331 /**
332 * The types which are know for purpose of parsing MatchRule expressions. 332 * The types which are know for purpose of parsing MatchRule expressions.
333 */ 333 */
334 Map<String, TypeDescriptor> knownTypes = new HashMap<>(); 334 Map<String, TypeDescriptor> knownTypes = new HashMap<>();
335 335
336 /**
337 * The mapping between elements with MatchRules and the wrapper class used invoke the code
338 * generation after the match.
339 */
340 private Map<String, MethodInvokerItem> invokers = new LinkedHashMap<>();
341
342 private TypeDescriptor valueType; 336 private TypeDescriptor valueType;
343 337
344 private TypeMirror matchRulesTypeMirror; 338 private TypeMirror matchRulesTypeMirror;
345 339
346 private TypeMirror matchRuleTypeMirror; 340 private TypeMirror matchRuleTypeMirror;
498 out.println("public class " + matchStatementClassName + " implements " + MatchStatementSet.class.getSimpleName() + " {"); 492 out.println("public class " + matchStatementClassName + " implements " + MatchStatementSet.class.getSimpleName() + " {");
499 493
500 out.println(); 494 out.println();
501 495
502 // Generate declarations for the wrapper class to invoke the code generation methods. 496 // Generate declarations for the wrapper class to invoke the code generation methods.
503 for (MethodInvokerItem invoker : invokers.values()) { 497 for (MethodInvokerItem invoker : info.invokers.values()) {
504 StringBuilder args = new StringBuilder(); 498 StringBuilder args = new StringBuilder();
505 StringBuilder types = new StringBuilder(); 499 StringBuilder types = new StringBuilder();
506 int count = invoker.fields.size(); 500 int count = invoker.fields.size();
507 int index = 0; 501 int index = 0;
508 for (VariableElement arg : invoker.fields) { 502 for (VariableElement arg : invoker.fields) {
642 636
643 final TypeElement topDeclaringType; 637 final TypeElement topDeclaringType;
644 final List<MatchRuleItem> matchRules = new ArrayList<>(); 638 final List<MatchRuleItem> matchRules = new ArrayList<>();
645 private final Set<Element> originatingElements = new HashSet<>(); 639 private final Set<Element> originatingElements = new HashSet<>();
646 public Set<String> positionDeclarations = new LinkedHashSet<>(); 640 public Set<String> positionDeclarations = new LinkedHashSet<>();
641
642 /**
643 * The mapping between elements with MatchRules and the wrapper class used invoke the code
644 * generation after the match.
645 */
646 Map<String, MethodInvokerItem> invokers = new LinkedHashMap<>();
647 647
648 /** 648 /**
649 * The set of packages which must be imported to refer the classes mention in matchRules. 649 * The set of packages which must be imported to refer the classes mention in matchRules.
650 */ 650 */
651 Set<String> requiredPackages = new HashSet<>(); 651 Set<String> requiredPackages = new HashSet<>();
917 return; 917 return;
918 } 918 }
919 } 919 }
920 920
921 String methodName = method.getSimpleName().toString(); 921 String methodName = method.getSimpleName().toString();
922 MethodInvokerItem invoker = invokers.get(methodName); 922 MethodInvokerItem invoker = info.invokers.get(methodName);
923 if (invoker == null) { 923 if (invoker == null) {
924 invoker = new MethodInvokerItem(methodName, topDeclaringType(method).getSimpleName().toString(), method, actualParameters); 924 invoker = new MethodInvokerItem(methodName, topDeclaringType(method).getSimpleName().toString(), method, actualParameters);
925 invokers.put(methodName, invoker); 925 info.invokers.put(methodName, invoker);
926 } else if (invoker.method != method) { 926 } else if (invoker.method != method) {
927 // This could be supported but it's easier if they are unique since the names 927 // This could be supported but it's easier if they are unique since the names
928 // are used in log output and snippet counters. 928 // are used in log output and snippet counters.
929 errorMessage(method, "Use unique method names for match methods."); 929 errorMessage(method, "Use unique method names for match methods: %s.%s != %s.%s", method.getReceiverType(), method.getSimpleName(), invoker.method.getReceiverType(),
930 invoker.method.getSimpleName());
930 return; 931 return;
931 } 932 }
932 933
933 Element enclosing = method.getEnclosingElement(); 934 Element enclosing = method.getEnclosingElement();
934 String declaringClass = ""; 935 String declaringClass = "";