Search in sources :

Example 1 with AnnotationVisitor

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

the class AnnotationExpr method writeAnnotationValue.

@Override
public void writeAnnotationValue(AnnotationVisitor visitor, String key) {
    final AnnotationVisitor av = visitor.visitAnnotation(key, this.annotation.getType().getExtendedName());
    this.annotation.write(av);
    av.visitEnd();
}
Also used : AnnotationVisitor(dyvilx.tools.asm.AnnotationVisitor)

Example 2 with AnnotationVisitor

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

the class ArrayExpr method writeAnnotationValue.

@Override
public void writeAnnotationValue(AnnotationVisitor visitor, String key) {
    final AnnotationVisitor arrayVisitor = visitor.visitArray(key);
    for (IValue value : this.values) {
        value.writeAnnotationValue(arrayVisitor, null);
    }
    arrayVisitor.visitEnd();
}
Also used : AnnotationVisitor(dyvilx.tools.asm.AnnotationVisitor)

Example 3 with AnnotationVisitor

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

the class ModifierUtil method writeModifiers.

public static void writeModifiers(AnnotatableVisitor visitor, long flags) {
    final int dyvilModifiers = (int) (flags >> 32);
    if (dyvilModifiers != 0) {
        final AnnotationVisitor annotationVisitor = visitor.visitAnnotation(DYVIL_MODIFIERS, true);
        annotationVisitor.visit("value", dyvilModifiers);
        annotationVisitor.visitEnd();
    }
}
Also used : AnnotationVisitor(dyvilx.tools.asm.AnnotationVisitor)

Example 4 with AnnotationVisitor

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

the class CodeClass method writeClassParameters.

private void writeClassParameters(ClassWriter writer) throws BytecodeException {
    final int parameterCount = this.parameters.size();
    if (parameterCount == 0) {
        return;
    }
    final AnnotationVisitor annotationVisitor = writer.visitAnnotation(AnnotationUtil.CLASS_PARAMETERS, false);
    final AnnotationVisitor arrayVisitor = annotationVisitor.visitArray("names");
    for (int i = 0; i < parameterCount; i++) {
        final IParameter parameter = this.parameters.get(i);
        parameter.write(writer);
        arrayVisitor.visit("", parameter.getInternalName());
    }
    arrayVisitor.visitEnd();
    annotationVisitor.visitEnd();
}
Also used : IParameter(dyvilx.tools.compiler.ast.parameter.IParameter) AnnotationVisitor(dyvilx.tools.asm.AnnotationVisitor)

Example 5 with AnnotationVisitor

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

the class AnnotationMetadata method write.

@Override
public void write(ClassWriter writer) throws BytecodeException {
    for (IParameter parameter : this.theClass.getParameters()) {
        final StringBuilder desc = new StringBuilder("()");
        parameter.getType().appendExtendedName(desc);
        final MethodVisitor methodVisitor = writer.visitMethod(Modifiers.PUBLIC | Modifiers.ABSTRACT, parameter.getInternalName(), desc.toString(), null, null);
        final IValue argument = parameter.getValue();
        if (argument != null && argument.isAnnotationConstant()) {
            final AnnotationVisitor av = methodVisitor.visitAnnotationDefault();
            argument.writeAnnotationValue(av, parameter.getInternalName());
            av.visitEnd();
        }
        methodVisitor.visitEnd();
    }
}
Also used : IParameter(dyvilx.tools.compiler.ast.parameter.IParameter) IValue(dyvilx.tools.compiler.ast.expression.IValue) AnnotationVisitor(dyvilx.tools.asm.AnnotationVisitor) MethodVisitor(dyvilx.tools.asm.MethodVisitor)

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