private TypeSignature parseClassTypeSignature() { if (current != 'L') { throw new IllegalStateException(); } advance(); int pos = position; ClassTypeSignature outerType = null; for (;;) { switch (current) { case '.': case '<': if (outerType == null) { outerType = new ClassTypeSignature(TypeSignatureKind.ClassType, "L" + signature.substring(pos, position) + ";"); } else { var outerName = outerType.getName().substring(1, outerType.getName().length() - 1); outerType = new ClassTypeSignature(TypeSignatureKind.ClassType, "L" + outerName + "$" + signature.substring(pos, position) + ";"); } if (current == '.') { advance(); } else { parseTypeArguments(outerType); if (current == '.') { advance(); } } pos = position; break; default: advance(); break; case ';': if (outerType == null) { outerType = new ClassTypeSignature(TypeSignatureKind.ClassType, "L" + signature.substring(pos, position) + ";"); } advance(); return(outerType); case -1: throw new IllegalStateException(); } } }
private void parseTypeArguments(ClassTypeSignature genericTypeDeclaration) { if (current != '<') { throw new IllegalStateException(); } advance(); var typeArguments = genericTypeDeclaration.typeArguments; for (;;) { switch (current) { case '*': advance(); typeArguments.add(new WildcardTypeSignature(TypeSignatureKind.UnboundedWildcardType, null)); break; case '+': advance(); typeArguments.add(new WildcardTypeSignature(TypeSignatureKind.UpperBoundedWildcardType, parseFieldTypeSignature())); break; case '-': advance(); typeArguments.add(new WildcardTypeSignature(TypeSignatureKind.LowerBoundedWildcardType, parseFieldTypeSignature())); break; default: typeArguments.add(parseFieldTypeSignature()); break; case '>': if (typeArguments.isEmpty()) { throw new IllegalStateException(); } advance(); return; case -1: throw new IllegalStateException(); } } }
private TypeSignature parseClassTypeSignature() { if (current != 'L') { throw new IllegalStateException(); } advance(); int pos = position; ClassTypeSignature outerType = null; for (;;) { switch (current) { case '.': case '<': if (outerType == null) { outerType = new ClassTypeSignature(TypeSignatureKind.ClassType, "L" + signature.substring(pos, position) + ";"); } else { var outerName = outerType.getName().substring(1, outerType.getName().length() - 1); outerType = new ClassTypeSignature(TypeSignatureKind.ClassType, "L" + outerName + "$" + signature.substring(pos, position) + ";"); } if (current == '.') { advance(); } else { parseTypeArguments(outerType); if (current == '.') { advance(); } } pos = position; break; default: advance(); break; case ';': if (outerType == null) { outerType = new ClassTypeSignature(TypeSignatureKind.ClassType, "L" + signature.substring(pos, position) + ";"); } advance(); return outerType; case -1: throw new IllegalStateException(); } } }