Mercurial > hg > graal-jvmci-8
comparison graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/ElementUtils.java @ 16909:62cfffca9be2
Truffle-DSL: some more performance optimizations.
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Sat, 23 Aug 2014 19:31:18 +0200 |
parents | 433ece7d941d |
children | 93e061157811 |
comparison
equal
deleted
inserted
replaced
16908:d3f282a9e287 | 16909:62cfffca9be2 |
---|---|
396 case INT: | 396 case INT: |
397 return "int"; | 397 return "int"; |
398 case LONG: | 398 case LONG: |
399 return "long"; | 399 return "long"; |
400 case DECLARED: | 400 case DECLARED: |
401 return getDeclaredName((DeclaredType) mirror); | 401 return getDeclaredName((DeclaredType) mirror, true); |
402 case ARRAY: | 402 case ARRAY: |
403 return getSimpleName(((ArrayType) mirror).getComponentType()) + "[]"; | 403 return getSimpleName(((ArrayType) mirror).getComponentType()) + "[]"; |
404 case VOID: | 404 case VOID: |
405 return "void"; | 405 return "void"; |
406 case WILDCARD: | 406 case WILDCARD: |
422 b.append("? super ").append(getSimpleName(type.getExtendsBound())); | 422 b.append("? super ").append(getSimpleName(type.getExtendsBound())); |
423 } | 423 } |
424 return b.toString(); | 424 return b.toString(); |
425 } | 425 } |
426 | 426 |
427 private static String getDeclaredName(DeclaredType element) { | 427 public static String getDeclaredName(DeclaredType element, boolean includeTypeVariables) { |
428 String simpleName = fixECJBinaryNameIssue(element.asElement().getSimpleName().toString()); | 428 String simpleName = fixECJBinaryNameIssue(element.asElement().getSimpleName().toString()); |
429 | 429 |
430 if (element.getTypeArguments().size() == 0) { | 430 if (!includeTypeVariables || element.getTypeArguments().size() == 0) { |
431 return simpleName; | 431 return simpleName; |
432 } | 432 } |
433 | 433 |
434 StringBuilder b = new StringBuilder(simpleName); | 434 StringBuilder b = new StringBuilder(simpleName); |
435 b.append("<"); | 435 b.append("<"); |
653 | 653 |
654 public static String getPackageName(TypeElement element) { | 654 public static String getPackageName(TypeElement element) { |
655 return findPackageElement(element).getQualifiedName().toString(); | 655 return findPackageElement(element).getQualifiedName().toString(); |
656 } | 656 } |
657 | 657 |
658 public static String getEnclosedQualifiedName(DeclaredType mirror) { | |
659 Element e = ((TypeElement) mirror.asElement()).getEnclosingElement(); | |
660 if (e.getKind() == ElementKind.PACKAGE) { | |
661 return ((PackageElement) e).getQualifiedName().toString(); | |
662 } else if (e.getKind().isInterface() || e.getKind().isClass()) { | |
663 return getQualifiedName((TypeElement) e); | |
664 } else { | |
665 return null; | |
666 } | |
667 } | |
668 | |
658 public static String getPackageName(TypeMirror mirror) { | 669 public static String getPackageName(TypeMirror mirror) { |
659 switch (mirror.getKind()) { | 670 switch (mirror.getKind()) { |
660 case BOOLEAN: | 671 case BOOLEAN: |
661 case BYTE: | 672 case BYTE: |
662 case CHAR: | 673 case CHAR: |