Search in sources :

Example 6 with AnnotationVisitor

use of dyvilx.tools.asm.AnnotationVisitor in project Dyvil by Dyvil.

the class AnnotationUtil method visitDyvilName.

public static void visitDyvilName(IType type, TypeAnnotatableVisitor visitor, int typeRef, TypePath typePath) {
    final AnnotationVisitor annotation = visitor.visitTypeAnnotation(typeRef, typePath, AnnotationUtil.DYVIL_TYPE, true);
    annotation.visit("value", type.getDescriptor(IType.NAME_FULL));
    annotation.visitEnd();
}
Also used : AnnotationVisitor(dyvilx.tools.asm.AnnotationVisitor)

Example 7 with AnnotationVisitor

use of dyvilx.tools.asm.AnnotationVisitor in project Dyvil by Dyvil.

the class CodeMethod method writeAnnotations.

protected void writeAnnotations(MethodWriter writer, long flags) {
    this.attributes.write(writer);
    // Write DyvilName annotation if it differs from the mangled name
    final String qualifiedName = this.name.qualified;
    if (!this.getInternalName().equals(qualifiedName)) {
        final AnnotationVisitor annotationVisitor = writer.visitAnnotation(AnnotationUtil.DYVIL_NAME, false);
        annotationVisitor.visit("value", qualifiedName);
        annotationVisitor.visitEnd();
    }
    // Write receiver type signature
    final IType thisType = this.getThisType();
    if (thisType != null && thisType != this.enclosingClass.getThisType()) {
        final AnnotationVisitor annotationVisitor = writer.visitAnnotation(AnnotationUtil.RECEIVER_TYPE, false);
        annotationVisitor.visit("value", thisType.getDescriptor(IType.NAME_FULL));
        annotationVisitor.visitEnd();
    }
    ModifierUtil.writeModifiers(writer, flags);
    if (this.hasModifier(Modifiers.DEPRECATED) && this.getAnnotation(Deprecation.DEPRECATED_CLASS) == null) {
        writer.visitAnnotation(Deprecation.DYVIL_EXTENDED, true).visitEnd();
    }
    // Type Variable Annotations
    if (this.typeParameters != null) {
        this.typeParameters.write(writer);
    }
    IType.writeAnnotations(this.type, writer, TypeReference.newTypeReference(TypeReference.METHOD_RETURN), "");
    if (this.exceptions != null) {
        for (int i = 0; i < this.exceptions.size(); i++) {
            IType.writeAnnotations(this.exceptions.get(i), writer, TypeReference.newExceptionReference(i), "");
        }
    }
}
Also used : AnnotationVisitor(dyvilx.tools.asm.AnnotationVisitor) IType(dyvilx.tools.compiler.ast.type.IType)

Aggregations

AnnotationVisitor (dyvilx.tools.asm.AnnotationVisitor)7 IParameter (dyvilx.tools.compiler.ast.parameter.IParameter)2 MethodVisitor (dyvilx.tools.asm.MethodVisitor)1 IValue (dyvilx.tools.compiler.ast.expression.IValue)1 IType (dyvilx.tools.compiler.ast.type.IType)1