Search in sources :

Example 31 with SignatureReader

use of org.objectweb.asm.signature.SignatureReader in project CodenameOne by codenameone.

the class NameTranslatorClassVisitor method translateSignature.

private String translateSignature(final String signature, boolean type) {
    if (signature == null) {
        return null;
    }
    SignatureReader r = new SignatureReader(signature);
    SignatureWriter w = new SignatureWriter() {

        public void visitClassType(final String name) {
            String n = translator.getClassMirrorTranslation(name);
            super.visitClassType(n);
        }
    };
    if (type) {
        r.acceptType(w);
    } else {
        r.accept(w);
    }
    return w.toString();
}
Also used : SignatureReader(org.objectweb.asm.signature.SignatureReader) SignatureWriter(org.objectweb.asm.signature.SignatureWriter)

Example 32 with SignatureReader

use of org.objectweb.asm.signature.SignatureReader in project evosuite by EvoSuite.

the class CastClassAnalyzer method handleClassSignature.

private void handleClassSignature(ClassNode cn) {
    CollectParameterTypesVisitor visitor = new CollectParameterTypesVisitor(cn.name);
    if (cn.signature != null) {
        new SignatureReader(cn.signature).accept(visitor);
        for (Type castType : visitor.getClasses()) {
            if (!castClassMap.containsKey(castType)) {
                logger.debug("Adding new cast class from signature visitor: " + castType);
                castClassMap.put(castType, 1);
            }
        }
    }
}
Also used : Type(org.objectweb.asm.Type) SignatureReader(org.objectweb.asm.signature.SignatureReader)

Example 33 with SignatureReader

use of org.objectweb.asm.signature.SignatureReader in project maple-ir by LLVM-but-worse.

the class Textifier method visitLocalVariable.

@Override
public void visitLocalVariable(final String name, final String desc, final String signature, final Label start, final Label end, final int index) {
    buf.setLength(0);
    buf.append(tab2).append("LOCALVARIABLE ").append(name).append(' ');
    appendDescriptor(FIELD_DESCRIPTOR, desc);
    buf.append(' ');
    appendLabel(start);
    buf.append(' ');
    appendLabel(end);
    buf.append(' ').append(index).append('\n');
    if (signature != null) {
        buf.append(tab2);
        appendDescriptor(FIELD_SIGNATURE, signature);
        TraceSignatureVisitor sv = new TraceSignatureVisitor(0);
        SignatureReader r = new SignatureReader(signature);
        r.acceptType(sv);
        buf.append(tab2).append("// declaration: ").append(sv.getDeclaration()).append('\n');
    }
    text.add(buf.toString());
}
Also used : SignatureReader(org.objectweb.asm.signature.SignatureReader)

Example 34 with SignatureReader

use of org.objectweb.asm.signature.SignatureReader in project maple-ir by LLVM-but-worse.

the class Textifier method visitField.

@Override
public Textifier visitField(final int access, final String name, final String desc, final String signature, final Object value) {
    buf.setLength(0);
    buf.append('\n');
    if ((access & Opcodes.ACC_DEPRECATED) != 0) {
        buf.append(tab).append("// DEPRECATED\n");
    }
    buf.append(tab).append("// access flags 0x").append(Integer.toHexString(access).toUpperCase()).append('\n');
    if (signature != null) {
        buf.append(tab);
        appendDescriptor(FIELD_SIGNATURE, signature);
        TraceSignatureVisitor sv = new TraceSignatureVisitor(0);
        SignatureReader r = new SignatureReader(signature);
        r.acceptType(sv);
        buf.append(tab).append("// declaration: ").append(sv.getDeclaration()).append('\n');
    }
    buf.append(tab);
    appendAccess(access);
    appendDescriptor(FIELD_DESCRIPTOR, desc);
    buf.append(' ').append(name);
    if (value != null) {
        buf.append(" = ");
        if (value instanceof String) {
            buf.append('\"').append(value).append('\"');
        } else {
            buf.append(value);
        }
    }
    buf.append('\n');
    text.add(buf.toString());
    Textifier t = createTextifier();
    text.add(t.getText());
    return t;
}
Also used : SignatureReader(org.objectweb.asm.signature.SignatureReader)

Example 35 with SignatureReader

use of org.objectweb.asm.signature.SignatureReader in project maple-ir by LLVM-but-worse.

the class Textifier method visitMethod.

@Override
public Textifier visitMethod(final int access, final String name, final String desc, final String signature, final String[] exceptions) {
    buf.setLength(0);
    buf.append('\n');
    if ((access & Opcodes.ACC_DEPRECATED) != 0) {
        buf.append(tab).append("// DEPRECATED\n");
    }
    buf.append(tab).append("// access flags 0x").append(Integer.toHexString(access).toUpperCase()).append('\n');
    if (signature != null) {
        buf.append(tab);
        appendDescriptor(METHOD_SIGNATURE, signature);
        TraceSignatureVisitor v = new TraceSignatureVisitor(0);
        SignatureReader r = new SignatureReader(signature);
        r.accept(v);
        String genericDecl = v.getDeclaration();
        String genericReturn = v.getReturnType();
        String genericExceptions = v.getExceptions();
        buf.append(tab).append("// declaration: ").append(genericReturn).append(' ').append(name).append(genericDecl);
        if (genericExceptions != null) {
            buf.append(" throws ").append(genericExceptions);
        }
        buf.append('\n');
    }
    buf.append(tab);
    appendAccess(access);
    if ((access & Opcodes.ACC_NATIVE) != 0) {
        buf.append("native ");
    }
    if ((access & Opcodes.ACC_VARARGS) != 0) {
        buf.append("varargs ");
    }
    if ((access & Opcodes.ACC_BRIDGE) != 0) {
        buf.append("bridge ");
    }
    if ((this.access & Opcodes.ACC_INTERFACE) != 0 && (access & Opcodes.ACC_ABSTRACT) == 0 && (access & Opcodes.ACC_STATIC) == 0) {
        buf.append("default ");
    }
    buf.append(name);
    appendDescriptor(METHOD_DESCRIPTOR, desc);
    if (exceptions != null && exceptions.length > 0) {
        buf.append(" throws ");
        for (int i = 0; i < exceptions.length; ++i) {
            appendDescriptor(INTERNAL_NAME, exceptions[i]);
            buf.append(' ');
        }
    }
    buf.append('\n');
    text.add(buf.toString());
    Textifier t = createTextifier();
    text.add(t.getText());
    return t;
}
Also used : SignatureReader(org.objectweb.asm.signature.SignatureReader)

Aggregations

SignatureReader (org.objectweb.asm.signature.SignatureReader)41 SignatureWriter (org.objectweb.asm.signature.SignatureWriter)12 ArrayList (java.util.ArrayList)5 ClassNode (org.codehaus.groovy.ast.ClassNode)4 GenericsType (org.codehaus.groovy.ast.GenericsType)3 Type (org.objectweb.asm.Type)3 SignatureVisitor (org.objectweb.asm.signature.SignatureVisitor)3 BoundDescriptor (com.buschmais.jqassistant.plugin.java.api.model.generics.BoundDescriptor)2 AbstractBoundVisitor (com.buschmais.jqassistant.plugin.java.impl.scanner.visitor.generics.AbstractBoundVisitor)2 List (java.util.List)2 Map (java.util.Map)2 TypeSignatureVisitor (net.sourceforge.pmd.dcd.asm.TypeSignatureVisitor)2 EntryMessage (org.apache.logging.log4j.message.EntryMessage)2 ConstantExpression (org.codehaus.groovy.ast.expr.ConstantExpression)2 ReturnStatement (org.codehaus.groovy.ast.stmt.ReturnStatement)2 DelegatingMethodVisitor (com.buschmais.jqassistant.plugin.java.impl.scanner.visitor.delegate.DelegatingMethodVisitor)1 ClassSignatureVisitor (com.buschmais.jqassistant.plugin.java.impl.scanner.visitor.generics.ClassSignatureVisitor)1 MethodSignatureVisitor (com.buschmais.jqassistant.plugin.java.impl.scanner.visitor.generics.MethodSignatureVisitor)1 IOException (java.io.IOException)1 Constructor (java.lang.reflect.Constructor)1