コード例 #1
0
  private Type getMirrorType(final Type type) {
    int numDimensions = 0;
    final Type basicType;

    if (type.getSort() == Type.ARRAY) {
      numDimensions = type.getDimensions();
      basicType = type.getElementType();
    } else {
      basicType = type;
    }

    if (basicType.getSort() != Type.OBJECT) {
      return type;
    }

    final Mirror mirror = getMirror(basicType.getInternalName());

    if (mirror.isClassMirror()) {
      final StringBuilder name = new StringBuilder();

      for (int i = 0; i < numDimensions; ++i) {
        name.append('[');
      }
      name.append('L').append(mirror.getTranslatedName()).append(';');

      return Type.getType(name.toString());
    }

    return type;
  }
コード例 #2
0
 private ClassMetadata getClassMetadata(
     ClassMetadataResolver resolver, Type type, boolean ignoreArray) {
   if (type.getSort() == Type.ARRAY) {
     return resolver.resolve(
         type.getElementType().getClassName(), ignoreArray ? 0 : type.getDimensions());
   } else {
     return resolver.resolve(type.getClassName(), 0);
   }
 }
コード例 #3
0
ファイル: Compiler.java プロジェクト: rwaldron/es6draft
 private String getDescriptor(Type type) {
   if (type.getSort() == Type.OBJECT) {
     String name = type.getInternalName();
     int index = name.lastIndexOf('/');
     return name.substring(index + 1);
   }
   if (type.getSort() == Type.ARRAY) {
     StringBuilder sb = new StringBuilder(getDescriptor(type.getElementType()));
     for (int dim = type.getDimensions(); dim > 0; --dim) {
       sb.append("[]");
     }
     return sb.toString();
   }
   return type.getClassName();
 }