use of org.objectweb.asm.signature.SignatureReader in project jqa-java-plugin by buschmais.
the class ClassVisitor method visitMethod.
@Override
public org.objectweb.asm.MethodVisitor visitMethod(final int access, final String name, final String desc, final String signature, final String[] exceptions) {
MethodDescriptor methodDescriptor = visitorHelper.getMethodDescriptor(cachedType, SignatureHelper.getMethodSignature(name, desc));
visitorHelper.getTypeVariableResolver().push();
methodDescriptor.setName(name);
setModifiers(access, methodDescriptor);
if (hasFlag(access, Opcodes.ACC_ABSTRACT)) {
methodDescriptor.setAbstract(Boolean.TRUE);
}
if (hasFlag(access, Opcodes.ACC_NATIVE)) {
methodDescriptor.setNative(Boolean.TRUE);
}
if (signature == null) {
String returnType = SignatureHelper.getType(org.objectweb.asm.Type.getReturnType(desc));
methodDescriptor.setReturns(visitorHelper.resolveType(returnType, cachedType).getTypeDescriptor());
org.objectweb.asm.Type[] types = org.objectweb.asm.Type.getArgumentTypes(desc);
for (int i = 0; i < types.length; i++) {
String parameterType = SignatureHelper.getType(types[i]);
TypeDescriptor typeDescriptor = visitorHelper.resolveType(parameterType, cachedType).getTypeDescriptor();
ParameterDescriptor parameterDescriptor = visitorHelper.addParameterDescriptor(methodDescriptor, i);
parameterDescriptor.setType(typeDescriptor);
}
} else {
new SignatureReader(signature).accept(new MethodSignatureVisitor(cachedType, methodDescriptor, visitorHelper));
}
for (int i = 0; exceptions != null && i < exceptions.length; i++) {
TypeDescriptor exceptionType = visitorHelper.resolveType(SignatureHelper.getObjectType(exceptions[i]), cachedType).getTypeDescriptor();
methodDescriptor.getThrows().add(exceptionType);
}
return new DelegatingMethodVisitor(asList(new MethodVisitor(cachedType, methodDescriptor, visitorHelper), new MethodLoCVisitor(methodDescriptor), new MethodComplexityVisitor(methodDescriptor)));
}
use of org.objectweb.asm.signature.SignatureReader in project jqa-java-plugin by buschmais.
the class ClassVisitor method visit.
@Override
public void visit(final int version, final int access, final String name, final String signature, final String superName, final String[] interfaces) {
Class<? extends ClassFileDescriptor> javaType = getJavaType(access);
String fullQualifiedName = SignatureHelper.getObjectType(name);
cachedType = visitorHelper.createType(fullQualifiedName, fileDescriptor, javaType);
visitorHelper.getTypeVariableResolver().push();
ClassFileDescriptor classFileDescriptor = cachedType.getTypeDescriptor();
classFileDescriptor.setByteCodeVersion(version);
if (hasFlag(access, Opcodes.ACC_ABSTRACT) && !hasFlag(access, Opcodes.ACC_INTERFACE)) {
classFileDescriptor.setAbstract(Boolean.TRUE);
}
setModifiers(access, classFileDescriptor);
if (signature == null) {
if (superName != null) {
TypeDescriptor superClassType = visitorHelper.resolveType(SignatureHelper.getObjectType(superName), cachedType).getTypeDescriptor();
classFileDescriptor.setSuperClass(superClassType);
}
for (int i = 0; interfaces != null && i < interfaces.length; i++) {
TypeDescriptor interfaceType = visitorHelper.resolveType(SignatureHelper.getObjectType(interfaces[i]), cachedType).getTypeDescriptor();
classFileDescriptor.getInterfaces().add(interfaceType);
}
} else {
new SignatureReader(signature).accept(new ClassSignatureVisitor(cachedType, visitorHelper));
}
}
use of org.objectweb.asm.signature.SignatureReader in project jqa-java-plugin by buschmais.
the class MethodVisitor method visitLocalVariable.
@Override
public void visitLocalVariable(final String name, final String desc, final String signature, final Label start, final Label end, final int index) {
if (visitorHelper.getClassModelConfiguration().isMethodDeclaresVariable() && !THIS.equals(name)) {
final VariableDescriptor variableDescriptor = visitorHelper.getVariableDescriptor(name, SignatureHelper.getFieldSignature(name, desc));
if (signature == null) {
TypeDescriptor type = visitorHelper.resolveType(SignatureHelper.getType((desc)), containingType).getTypeDescriptor();
variableDescriptor.setType(type);
} else {
new SignatureReader(signature).accept(new AbstractBoundVisitor(visitorHelper, containingType) {
@Override
protected void apply(TypeDescriptor rawTypeBound, BoundDescriptor bound) {
variableDescriptor.setType(rawTypeBound);
variableDescriptor.setGenericType(bound);
}
});
}
methodDescriptor.getVariables().add(variableDescriptor);
}
}
use of org.objectweb.asm.signature.SignatureReader in project maple-ir by LLVM-but-worse.
the class Remapper method mapSignature.
/**
* @param typeSignature
* true if signature is a FieldTypeSignature, such as the
* signature parameter of the ClassVisitor.visitField or
* MethodVisitor.visitLocalVariable methods
*/
public String mapSignature(String signature, boolean typeSignature) {
if (signature == null) {
return null;
}
SignatureReader r = new SignatureReader(signature);
SignatureWriter w = new SignatureWriter();
SignatureVisitor a = createRemappingSignatureAdapter(w);
if (typeSignature) {
r.acceptType(a);
} else {
r.accept(a);
}
return w.toString();
}
use of org.objectweb.asm.signature.SignatureReader in project maple-ir by LLVM-but-worse.
the class Textifier method visit.
// ------------------------------------------------------------------------
// Classes
// ------------------------------------------------------------------------
@Override
public void visit(final int version, final int access, final String name, final String signature, final String superName, final String[] interfaces) {
this.access = access;
int major = version & 0xFFFF;
int minor = version >>> 16;
buf.setLength(0);
buf.append("// class version ").append(major).append('.').append(minor).append(" (").append(version).append(")\n");
if ((access & Opcodes.ACC_DEPRECATED) != 0) {
buf.append("// DEPRECATED\n");
}
buf.append("// access flags 0x").append(Integer.toHexString(access).toUpperCase()).append('\n');
appendDescriptor(CLASS_SIGNATURE, signature);
if (signature != null) {
TraceSignatureVisitor sv = new TraceSignatureVisitor(access);
SignatureReader r = new SignatureReader(signature);
r.accept(sv);
buf.append("// declaration: ").append(name).append(sv.getDeclaration()).append('\n');
}
appendAccess(access & ~Opcodes.ACC_SUPER);
if ((access & Opcodes.ACC_ANNOTATION) != 0) {
buf.append("@interface ");
} else if ((access & Opcodes.ACC_INTERFACE) != 0) {
buf.append("interface ");
} else if ((access & Opcodes.ACC_ENUM) == 0) {
buf.append("class ");
}
appendDescriptor(INTERNAL_NAME, name);
if (superName != null && !"java/lang/Object".equals(superName)) {
buf.append(" extends ");
appendDescriptor(INTERNAL_NAME, superName);
buf.append(' ');
}
if (interfaces != null && interfaces.length > 0) {
buf.append(" implements ");
for (int i = 0; i < interfaces.length; ++i) {
appendDescriptor(INTERNAL_NAME, interfaces[i]);
buf.append(' ');
}
}
buf.append(" {\n\n");
text.add(buf.toString());
}
Aggregations