| 92 | } |
| 93 | |
| 94 | public <T extends CallableDeclaration<T> & NodeWithParameters<T>> MethodInstance getMethod(T methodDecl) { |
| 95 | ClassInstance cls = getCls(methodDecl); |
| 96 | if (cls == null) return null; |
| 97 | |
| 98 | StringBuilder sb = new StringBuilder(); |
| 99 | sb.append('('); |
| 100 | |
| 101 | if (methodDecl instanceof ConstructorDeclaration && cls.isEnum()) { // implicit extra String name + int ordinal for enum constructors |
| 102 | sb.append("Ljava/lang/String;I"); |
| 103 | } |
| 104 | |
| 105 | for (Parameter p : methodDecl.getParameters()) { |
| 106 | sb.append(toDesc(p.getType(), rootCls)); |
| 107 | } |
| 108 | |
| 109 | sb.append(')'); |
| 110 | |
| 111 | if (methodDecl instanceof NodeWithType) { |
| 112 | sb.append(toDesc(((NodeWithType<?, ?>) methodDecl).getType(), rootCls)); |
| 113 | } else { |
| 114 | sb.append('V'); |
| 115 | } |
| 116 | |
| 117 | String desc = sb.toString(); |
| 118 | String name; |
| 119 | |
| 120 | if (methodDecl instanceof ConstructorDeclaration) { |
| 121 | name = "<init>"; |
| 122 | } else { |
| 123 | name = methodDecl.getName().getIdentifier(); |
| 124 | } |
| 125 | |
| 126 | return cls.getMethod(name, desc, nameType); |
| 127 | } |
| 128 | |
| 129 | public FieldInstance getField(VariableDeclarator var) { |
| 130 | ClassInstance cls = getCls(var); |