Search in sources :

Example 11 with Type

use of jdk.internal.org.objectweb.asm.Type in project Bytecoder by mirkosertic.

the class LocalVariablesSorter method visitLocalVariableAnnotation.

@Override
public AnnotationVisitor visitLocalVariableAnnotation(int typeRef, TypePath typePath, Label[] start, Label[] end, int[] index, String desc, boolean visible) {
    Type t = Type.getType(desc);
    int[] newIndex = new int[index.length];
    for (int i = 0; i < newIndex.length; ++i) {
        newIndex[i] = remap(index[i], t);
    }
    return mv.visitLocalVariableAnnotation(typeRef, typePath, start, end, newIndex, desc, visible);
}
Also used : Type(jdk.internal.org.objectweb.asm.Type)

Example 12 with Type

use of jdk.internal.org.objectweb.asm.Type in project Bytecoder by mirkosertic.

the class SimpleVerifier method merge.

@Override
public BasicValue merge(final BasicValue v, final BasicValue w) {
    if (!v.equals(w)) {
        Type t = v.getType();
        Type u = w.getType();
        if (t != null && (t.getSort() == Type.OBJECT || t.getSort() == Type.ARRAY)) {
            if (u != null && (u.getSort() == Type.OBJECT || u.getSort() == Type.ARRAY)) {
                if ("Lnull;".equals(t.getDescriptor())) {
                    return w;
                }
                if ("Lnull;".equals(u.getDescriptor())) {
                    return v;
                }
                if (isAssignableFrom(t, u)) {
                    return v;
                }
                if (isAssignableFrom(u, t)) {
                    return w;
                }
                // interfaces
                do {
                    if (t == null || isInterface(t)) {
                        return BasicValue.REFERENCE_VALUE;
                    }
                    t = getSuperClass(t);
                    if (isAssignableFrom(t, u)) {
                        return newValue(t);
                    }
                } while (true);
            }
        }
        return BasicValue.UNINITIALIZED_VALUE;
    }
    return v;
}
Also used : Type(jdk.internal.org.objectweb.asm.Type)

Example 13 with Type

use of jdk.internal.org.objectweb.asm.Type in project Bytecoder by mirkosertic.

the class GeneratorAdapter method valueOf.

/**
 * Generates the instructions to box the top stack value using Java 5's
 * valueOf() method. This value is replaced by its boxed equivalent on top
 * of the stack.
 *
 * @param type
 *            the type of the top stack value.
 */
public void valueOf(final Type type) {
    if (type.getSort() == Type.OBJECT || type.getSort() == Type.ARRAY) {
        return;
    }
    if (type == Type.VOID_TYPE) {
        push((String) null);
    } else {
        Type boxed = getBoxedType(type);
        invokeStatic(boxed, new Method("valueOf", boxed, new Type[] { type }));
    }
}
Also used : Type(jdk.internal.org.objectweb.asm.Type)

Example 14 with Type

use of jdk.internal.org.objectweb.asm.Type in project Bytecoder by mirkosertic.

the class GeneratorAdapter method loadArgs.

/**
 * Generates the instructions to load the given method arguments on the
 * stack.
 *
 * @param arg
 *            the index of the first method argument to be loaded.
 * @param count
 *            the number of method arguments to be loaded.
 */
public void loadArgs(final int arg, final int count) {
    int index = getArgIndex(arg);
    for (int i = 0; i < count; ++i) {
        Type t = argumentTypes[arg + i];
        loadInsn(t, index);
        index += t.getSize();
    }
}
Also used : Type(jdk.internal.org.objectweb.asm.Type)

Example 15 with Type

use of jdk.internal.org.objectweb.asm.Type in project jdk8u_jdk by JetBrains.

the class AdviceAdapter method visitInvokeDynamicInsn.

@Override
public void visitInvokeDynamicInsn(String name, String desc, Handle bsm, Object... bsmArgs) {
    mv.visitInvokeDynamicInsn(name, desc, bsm, bsmArgs);
    if (constructor) {
        Type[] types = Type.getArgumentTypes(desc);
        for (int i = 0; i < types.length; i++) {
            popValue();
            if (types[i].getSize() == 2) {
                popValue();
            }
        }
        Type returnType = Type.getReturnType(desc);
        if (returnType != Type.VOID_TYPE) {
            pushValue(OTHER);
            if (returnType.getSize() == 2) {
                pushValue(OTHER);
            }
        }
    }
}
Also used : Type(jdk.internal.org.objectweb.asm.Type)

Aggregations

Type (jdk.internal.org.objectweb.asm.Type)30 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)2 List (java.util.List)2 AbstractInsnNode (jdk.internal.org.objectweb.asm.tree.AbstractInsnNode)2 ClassNode (jdk.internal.org.objectweb.asm.tree.ClassNode)2 IincInsnNode (jdk.internal.org.objectweb.asm.tree.IincInsnNode)2 InsnList (jdk.internal.org.objectweb.asm.tree.InsnList)2 JumpInsnNode (jdk.internal.org.objectweb.asm.tree.JumpInsnNode)2 LabelNode (jdk.internal.org.objectweb.asm.tree.LabelNode)2 LookupSwitchInsnNode (jdk.internal.org.objectweb.asm.tree.LookupSwitchInsnNode)2 MethodNode (jdk.internal.org.objectweb.asm.tree.MethodNode)2 TableSwitchInsnNode (jdk.internal.org.objectweb.asm.tree.TableSwitchInsnNode)2 TryCatchBlockNode (jdk.internal.org.objectweb.asm.tree.TryCatchBlockNode)2 VarInsnNode (jdk.internal.org.objectweb.asm.tree.VarInsnNode)2 Analyzer (jdk.internal.org.objectweb.asm.tree.analysis.Analyzer)2 BasicValue (jdk.internal.org.objectweb.asm.tree.analysis.BasicValue)2 SimpleVerifier (jdk.internal.org.objectweb.asm.tree.analysis.SimpleVerifier)2