Search in sources :

Example 21 with Type

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

the class SimpleVerifier method isSubTypeOf.

@Override
protected boolean isSubTypeOf(final BasicValue value, final BasicValue expected) {
    Type expectedType = expected.getType();
    Type type = value.getType();
    switch(expectedType.getSort()) {
        case Type.INT:
        case Type.FLOAT:
        case Type.LONG:
        case Type.DOUBLE:
            return type.equals(expectedType);
        case Type.ARRAY:
        case Type.OBJECT:
            if ("Lnull;".equals(type.getDescriptor())) {
                return true;
            } else if (type.getSort() == Type.OBJECT || type.getSort() == Type.ARRAY) {
                return isAssignableFrom(expectedType, type);
            } else {
                return false;
            }
        default:
            throw new Error("Internal error");
    }
}
Also used : Type(jdk.internal.org.objectweb.asm.Type)

Example 22 with Type

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

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 23 with Type

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

the class SimpleVerifier method isSubTypeOf.

@Override
protected boolean isSubTypeOf(final BasicValue value, final BasicValue expected) {
    Type expectedType = expected.getType();
    Type type = value.getType();
    switch(expectedType.getSort()) {
        case Type.INT:
        case Type.FLOAT:
        case Type.LONG:
        case Type.DOUBLE:
            return type.equals(expectedType);
        case Type.ARRAY:
        case Type.OBJECT:
            if ("Lnull;".equals(type.getDescriptor())) {
                return true;
            } else if (type.getSort() == Type.OBJECT || type.getSort() == Type.ARRAY) {
                return isAssignableFrom(expectedType, type);
            } else {
                return false;
            }
        default:
            throw new Error("Internal error");
    }
}
Also used : Type(jdk.internal.org.objectweb.asm.Type)

Example 24 with Type

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

the class AdviceAdapter method doVisitMethodInsn.

private void doVisitMethodInsn(int opcode, final String owner, final String name, final String desc, final boolean itf) {
    mv.visitMethodInsn(opcode, owner, name, desc, itf);
    if (constructor) {
        Type[] types = Type.getArgumentTypes(desc);
        for (int i = 0; i < types.length; i++) {
            popValue();
            if (types[i].getSize() == 2) {
                popValue();
            }
        }
        switch(opcode) {
            // break;
            case INVOKEINTERFACE:
            case INVOKEVIRTUAL:
                // objectref
                popValue();
                break;
            case INVOKESPECIAL:
                // objectref
                Object type = popValue();
                if (type == THIS && !superInitialized) {
                    onMethodEnter();
                    superInitialized = true;
                    // once super has been initialized it is no longer
                    // necessary to keep track of stack state
                    constructor = false;
                }
                break;
        }
        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)

Example 25 with Type

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

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