Usages of

com.ibm.wala.types.TypeName.getArrayTypeForElementType()
/** * Parse method descriptor to obtain descriptions of method's parameters. * * @return parameter descriptions, or null if there are no parameters * @throws IllegalArgumentException if b is null */ public static final TypeName[] parseForParameterNames(Language l, ImmutableByteArray b) throws IllegalArgumentException { if (b == null) { throw new IllegalArgumentException("b is null"); } if (b.length() <= 2) { throw new IllegalArgumentException("invalid descriptor: " + b); } if (b.get(0) != '(') { throw new IllegalArgumentException("invalid descriptor: " + b); } ArrayList<TypeName> sigs = new ArrayList<TypeName>(10); int i = 1; while (true) { switch (b.get(i++)) { case TypeReference.VoidTypeCode: sigs.add(TypeReference.VoidName); continue; case TypeReference.BooleanTypeCode: sigs.add(TypeReference.BooleanName); continue; case TypeReference.ByteTypeCode: sigs.add(TypeReference.ByteName); continue; case TypeReference.ShortTypeCode: sigs.add(TypeReference.ShortName); continue; case TypeReference.IntTypeCode: sigs.add(TypeReference.IntName); continue; case TypeReference.LongTypeCode: sigs.add(TypeReference.LongName); continue; case TypeReference.FloatTypeCode: sigs.add(TypeReference.FloatName); continue; case TypeReference.DoubleTypeCode: sigs.add(TypeReference.DoubleName); continue; case TypeReference.CharTypeCode: sigs.add(TypeReference.CharName); continue; case TypeReference.OtherPrimitiveTypeCode: { int off = i - 1; while (b.get(i++) != ';') ; sigs.add(l.lookupPrimitiveType(new String(b.substring(off + 1, i - off - 2)))); continue; } case TypeReference.ClassTypeCode: { int off = i - 1; while (b.get(i++) != ';') ; sigs.add(TypeName.findOrCreate(b, off, i - off - 1)); continue; } case TypeReference.ArrayTypeCode: { int off = i - 1; while (b.get(i) == TypeReference.ArrayTypeCode) { ++i; } TypeName T = null; byte c = b.get(i++); if (c == TypeReference.ClassTypeCode) { while (b.get(i++) != ';') ; T = TypeName.findOrCreate(b, off, i - off - 1); } else if (c == TypeReference.OtherPrimitiveTypeCode) { int typeOff = i; while (b.get(i++) != ';') ; T = l.lookupPrimitiveType(new String(b.substring(typeOff, i - typeOff - 1))); while (--typeOff > off) { T = T.getArrayTypeForElementType(); } } else { T = TypeName.findOrCreate(b, off, i - off); } sigs.add(T); continue; } case (byte) ')': // end of parameter list int size = sigs.size(); if (size == 0) { return null; } Iterator<TypeName> it = sigs.iterator(); TypeName[] result = new TypeName[size]; for (int j = 0; j < size; j++) { result[j] = it.next(); } return result; default: assert false : "bad descriptor " + b; } } }
Usage snippet has been bookmarked! Review your bookmarks
Thank you! Review your likes