Java Code Examples for jdk.internal.org.objectweb.asm.Type#LONG

The following examples show how to use jdk.internal.org.objectweb.asm.Type#LONG . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GeneratorAdapter.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
private static Type getBoxedType(final Type type) {
    switch (type.getSort()) {
    case Type.BYTE:
        return BYTE_TYPE;
    case Type.BOOLEAN:
        return BOOLEAN_TYPE;
    case Type.SHORT:
        return SHORT_TYPE;
    case Type.CHAR:
        return CHARACTER_TYPE;
    case Type.INT:
        return INTEGER_TYPE;
    case Type.FLOAT:
        return FLOAT_TYPE;
    case Type.LONG:
        return LONG_TYPE;
    case Type.DOUBLE:
        return DOUBLE_TYPE;
    }
    return type;
}
 
Example 2
Source File: SimpleVerifier.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
@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");
    }
}
 
Example 3
Source File: SimpleVerifier.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
@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");
    }
}
 
Example 4
Source File: SimpleVerifier.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
@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");
    }
}
 
Example 5
Source File: GeneratorAdapter.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
/**
  * Generates the instruction to create a new array.
  *
  * @param type the type of the array elements.
  */
public void newArray(final Type type) {
    int arrayType;
    switch (type.getSort()) {
        case Type.BOOLEAN:
            arrayType = Opcodes.T_BOOLEAN;
            break;
        case Type.CHAR:
            arrayType = Opcodes.T_CHAR;
            break;
        case Type.BYTE:
            arrayType = Opcodes.T_BYTE;
            break;
        case Type.SHORT:
            arrayType = Opcodes.T_SHORT;
            break;
        case Type.INT:
            arrayType = Opcodes.T_INT;
            break;
        case Type.FLOAT:
            arrayType = Opcodes.T_FLOAT;
            break;
        case Type.LONG:
            arrayType = Opcodes.T_LONG;
            break;
        case Type.DOUBLE:
            arrayType = Opcodes.T_DOUBLE;
            break;
        default:
            typeInsn(Opcodes.ANEWARRAY, type);
            return;
    }
    mv.visitIntInsn(Opcodes.NEWARRAY, arrayType);
}
 
Example 6
Source File: BasicInterpreter.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
public BasicValue newValue(final Type type) {
    if (type == null) {
        return BasicValue.UNINITIALIZED_VALUE;
    }
    switch (type.getSort()) {
    case Type.VOID:
        return null;
    case Type.BOOLEAN:
    case Type.CHAR:
    case Type.BYTE:
    case Type.SHORT:
    case Type.INT:
        return BasicValue.INT_VALUE;
    case Type.FLOAT:
        return BasicValue.FLOAT_VALUE;
    case Type.LONG:
        return BasicValue.LONG_VALUE;
    case Type.DOUBLE:
        return BasicValue.DOUBLE_VALUE;
    case Type.ARRAY:
    case Type.OBJECT:
        return BasicValue.REFERENCE_VALUE;
    default:
        throw new Error("Internal error");
    }
}
 
Example 7
Source File: GeneratorAdapter.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Generates the instructions to unbox the top stack value. This value is
 * replaced by its unboxed equivalent on top of the stack.
 *
 * @param type
 *            the type of the top stack value.
 */
public void unbox(final Type type) {
    Type t = NUMBER_TYPE;
    Method sig = null;
    switch (type.getSort()) {
    case Type.VOID:
        return;
    case Type.CHAR:
        t = CHARACTER_TYPE;
        sig = CHAR_VALUE;
        break;
    case Type.BOOLEAN:
        t = BOOLEAN_TYPE;
        sig = BOOLEAN_VALUE;
        break;
    case Type.DOUBLE:
        sig = DOUBLE_VALUE;
        break;
    case Type.FLOAT:
        sig = FLOAT_VALUE;
        break;
    case Type.LONG:
        sig = LONG_VALUE;
        break;
    case Type.INT:
    case Type.SHORT:
    case Type.BYTE:
        sig = INT_VALUE;
    }
    if (sig == null) {
        checkCast(type);
    } else {
        checkCast(t);
        invokeVirtual(t, sig);
    }
}
 
Example 8
Source File: InstructionAdapter.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public void newarray(final Type type) {
    int typ;
    switch (type.getSort()) {
    case Type.BOOLEAN:
        typ = Opcodes.T_BOOLEAN;
        break;
    case Type.CHAR:
        typ = Opcodes.T_CHAR;
        break;
    case Type.BYTE:
        typ = Opcodes.T_BYTE;
        break;
    case Type.SHORT:
        typ = Opcodes.T_SHORT;
        break;
    case Type.INT:
        typ = Opcodes.T_INT;
        break;
    case Type.FLOAT:
        typ = Opcodes.T_FLOAT;
        break;
    case Type.LONG:
        typ = Opcodes.T_LONG;
        break;
    case Type.DOUBLE:
        typ = Opcodes.T_DOUBLE;
        break;
    default:
        mv.visitTypeInsn(Opcodes.ANEWARRAY, type.getInternalName());
        return;
    }
    mv.visitIntInsn(Opcodes.NEWARRAY, typ);
}
 
Example 9
Source File: LocalVariablesSorter.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a new local variable of the given type.
 *
 * @param type
 *            the type of the local variable to be created.
 * @return the identifier of the newly created local variable.
 */
public int newLocal(final Type type) {
    Object t;
    switch (type.getSort()) {
    case Type.BOOLEAN:
    case Type.CHAR:
    case Type.BYTE:
    case Type.SHORT:
    case Type.INT:
        t = Opcodes.INTEGER;
        break;
    case Type.FLOAT:
        t = Opcodes.FLOAT;
        break;
    case Type.LONG:
        t = Opcodes.LONG;
        break;
    case Type.DOUBLE:
        t = Opcodes.DOUBLE;
        break;
    case Type.ARRAY:
        t = type.getDescriptor();
        break;
    // case Type.OBJECT:
    default:
        t = type.getInternalName();
        break;
    }
    int local = newLocalMapping(type);
    setLocalType(local, type);
    setFrameLocal(local, t);
    changed = true;
    return local;
}
 
Example 10
Source File: GeneratorAdapter.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Generates the instructions to unbox the top stack value. This value is
 * replaced by its unboxed equivalent on top of the stack.
 *
 * @param type
 *            the type of the top stack value.
 */
public void unbox(final Type type) {
    Type t = NUMBER_TYPE;
    Method sig = null;
    switch (type.getSort()) {
    case Type.VOID:
        return;
    case Type.CHAR:
        t = CHARACTER_TYPE;
        sig = CHAR_VALUE;
        break;
    case Type.BOOLEAN:
        t = BOOLEAN_TYPE;
        sig = BOOLEAN_VALUE;
        break;
    case Type.DOUBLE:
        sig = DOUBLE_VALUE;
        break;
    case Type.FLOAT:
        sig = FLOAT_VALUE;
        break;
    case Type.LONG:
        sig = LONG_VALUE;
        break;
    case Type.INT:
    case Type.SHORT:
    case Type.BYTE:
        sig = INT_VALUE;
    }
    if (sig == null) {
        checkCast(type);
    } else {
        checkCast(t);
        invokeVirtual(t, sig);
    }
}
 
Example 11
Source File: BasicInterpreter.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
@Override
public BasicValue newValue(final Type type) {
    if (type == null) {
        return BasicValue.UNINITIALIZED_VALUE;
    }
    switch (type.getSort()) {
    case Type.VOID:
        return null;
    case Type.BOOLEAN:
    case Type.CHAR:
    case Type.BYTE:
    case Type.SHORT:
    case Type.INT:
        return BasicValue.INT_VALUE;
    case Type.FLOAT:
        return BasicValue.FLOAT_VALUE;
    case Type.LONG:
        return BasicValue.LONG_VALUE;
    case Type.DOUBLE:
        return BasicValue.DOUBLE_VALUE;
    case Type.ARRAY:
    case Type.OBJECT:
        return BasicValue.REFERENCE_VALUE;
    default:
        throw new Error("Internal error");
    }
}
 
Example 12
Source File: GeneratorAdapter.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Generates the instruction to create a new array.
 *
 * @param type
 *            the type of the array elements.
 */
public void newArray(final Type type) {
    int typ;
    switch (type.getSort()) {
    case Type.BOOLEAN:
        typ = Opcodes.T_BOOLEAN;
        break;
    case Type.CHAR:
        typ = Opcodes.T_CHAR;
        break;
    case Type.BYTE:
        typ = Opcodes.T_BYTE;
        break;
    case Type.SHORT:
        typ = Opcodes.T_SHORT;
        break;
    case Type.INT:
        typ = Opcodes.T_INT;
        break;
    case Type.FLOAT:
        typ = Opcodes.T_FLOAT;
        break;
    case Type.LONG:
        typ = Opcodes.T_LONG;
        break;
    case Type.DOUBLE:
        typ = Opcodes.T_DOUBLE;
        break;
    default:
        typeInsn(Opcodes.ANEWARRAY, type);
        return;
    }
    mv.visitIntInsn(Opcodes.NEWARRAY, typ);
}
 
Example 13
Source File: GeneratorAdapter.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Generates the instructions to jump to a label based on the comparison of
 * the top two stack values.
 *
 * @param type
 *            the type of the top two stack values.
 * @param mode
 *            how these values must be compared. One of EQ, NE, LT, GE, GT,
 *            LE.
 * @param label
 *            where to jump if the comparison result is <tt>true</tt>.
 */
public void ifCmp(final Type type, final int mode, final Label label) {
    switch (type.getSort()) {
    case Type.LONG:
        mv.visitInsn(Opcodes.LCMP);
        break;
    case Type.DOUBLE:
        mv.visitInsn(mode == GE || mode == GT ? Opcodes.DCMPL
                : Opcodes.DCMPG);
        break;
    case Type.FLOAT:
        mv.visitInsn(mode == GE || mode == GT ? Opcodes.FCMPL
                : Opcodes.FCMPG);
        break;
    case Type.ARRAY:
    case Type.OBJECT:
        switch (mode) {
        case EQ:
            mv.visitJumpInsn(Opcodes.IF_ACMPEQ, label);
            return;
        case NE:
            mv.visitJumpInsn(Opcodes.IF_ACMPNE, label);
            return;
        }
        throw new IllegalArgumentException("Bad comparison for type "
                + type);
    default:
        int intOp = -1;
        switch (mode) {
        case EQ:
            intOp = Opcodes.IF_ICMPEQ;
            break;
        case NE:
            intOp = Opcodes.IF_ICMPNE;
            break;
        case GE:
            intOp = Opcodes.IF_ICMPGE;
            break;
        case LT:
            intOp = Opcodes.IF_ICMPLT;
            break;
        case LE:
            intOp = Opcodes.IF_ICMPLE;
            break;
        case GT:
            intOp = Opcodes.IF_ICMPGT;
            break;
        }
        mv.visitJumpInsn(intOp, label);
        return;
    }
    mv.visitJumpInsn(mode, label);
}
 
Example 14
Source File: GeneratorAdapter.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Generates the instructions to jump to a label based on the comparison of
 * the top two stack values.
 *
 * @param type
 *            the type of the top two stack values.
 * @param mode
 *            how these values must be compared. One of EQ, NE, LT, GE, GT,
 *            LE.
 * @param label
 *            where to jump if the comparison result is <tt>true</tt>.
 */
public void ifCmp(final Type type, final int mode, final Label label) {
    switch (type.getSort()) {
    case Type.LONG:
        mv.visitInsn(Opcodes.LCMP);
        break;
    case Type.DOUBLE:
        mv.visitInsn(mode == GE || mode == GT ? Opcodes.DCMPL
                : Opcodes.DCMPG);
        break;
    case Type.FLOAT:
        mv.visitInsn(mode == GE || mode == GT ? Opcodes.FCMPL
                : Opcodes.FCMPG);
        break;
    case Type.ARRAY:
    case Type.OBJECT:
        switch (mode) {
        case EQ:
            mv.visitJumpInsn(Opcodes.IF_ACMPEQ, label);
            return;
        case NE:
            mv.visitJumpInsn(Opcodes.IF_ACMPNE, label);
            return;
        }
        throw new IllegalArgumentException("Bad comparison for type "
                + type);
    default:
        int intOp = -1;
        switch (mode) {
        case EQ:
            intOp = Opcodes.IF_ICMPEQ;
            break;
        case NE:
            intOp = Opcodes.IF_ICMPNE;
            break;
        case GE:
            intOp = Opcodes.IF_ICMPGE;
            break;
        case LT:
            intOp = Opcodes.IF_ICMPLT;
            break;
        case LE:
            intOp = Opcodes.IF_ICMPLE;
            break;
        case GT:
            intOp = Opcodes.IF_ICMPGT;
            break;
        }
        mv.visitJumpInsn(intOp, label);
        return;
    }
    mv.visitJumpInsn(mode, label);
}
 
Example 15
Source File: GeneratorAdapter.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Generates the instructions to jump to a label based on the comparison of
 * the top two stack values.
 *
 * @param type
 *            the type of the top two stack values.
 * @param mode
 *            how these values must be compared. One of EQ, NE, LT, GE, GT,
 *            LE.
 * @param label
 *            where to jump if the comparison result is <tt>true</tt>.
 */
public void ifCmp(final Type type, final int mode, final Label label) {
    switch (type.getSort()) {
    case Type.LONG:
        mv.visitInsn(Opcodes.LCMP);
        break;
    case Type.DOUBLE:
        mv.visitInsn(mode == GE || mode == GT ? Opcodes.DCMPL
                : Opcodes.DCMPG);
        break;
    case Type.FLOAT:
        mv.visitInsn(mode == GE || mode == GT ? Opcodes.FCMPL
                : Opcodes.FCMPG);
        break;
    case Type.ARRAY:
    case Type.OBJECT:
        switch (mode) {
        case EQ:
            mv.visitJumpInsn(Opcodes.IF_ACMPEQ, label);
            return;
        case NE:
            mv.visitJumpInsn(Opcodes.IF_ACMPNE, label);
            return;
        }
        throw new IllegalArgumentException("Bad comparison for type "
                + type);
    default:
        int intOp = -1;
        switch (mode) {
        case EQ:
            intOp = Opcodes.IF_ICMPEQ;
            break;
        case NE:
            intOp = Opcodes.IF_ICMPNE;
            break;
        case GE:
            intOp = Opcodes.IF_ICMPGE;
            break;
        case LT:
            intOp = Opcodes.IF_ICMPLT;
            break;
        case LE:
            intOp = Opcodes.IF_ICMPLE;
            break;
        case GT:
            intOp = Opcodes.IF_ICMPGT;
            break;
        }
        mv.visitJumpInsn(intOp, label);
        return;
    }
    mv.visitJumpInsn(mode, label);
}
 
Example 16
Source File: JavaAdapterBytecodeGenerator.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
private void convertReturnValue(final InstructionAdapter mv, final Class<?> returnType, final Type asmReturnType) {
    switch(asmReturnType.getSort()) {
    case Type.VOID:
        mv.pop();
        break;
    case Type.BOOLEAN:
        JSType.TO_BOOLEAN.invoke(mv);
        break;
    case Type.BYTE:
        JSType.TO_INT32.invoke(mv);
        mv.visitInsn(Opcodes.I2B);
        break;
    case Type.SHORT:
        JSType.TO_INT32.invoke(mv);
        mv.visitInsn(Opcodes.I2S);
        break;
    case Type.CHAR:
        // JSType doesn't have a TO_CHAR, so we have services supply us one.
        mv.invokestatic(SERVICES_CLASS_TYPE_NAME, "toCharPrimitive", TO_CHAR_PRIMITIVE_METHOD_DESCRIPTOR, false);
        break;
    case Type.INT:
        JSType.TO_INT32.invoke(mv);
        break;
    case Type.LONG:
        JSType.TO_LONG.invoke(mv);
        break;
    case Type.FLOAT:
        JSType.TO_NUMBER.invoke(mv);
        mv.visitInsn(Opcodes.D2F);
        break;
    case Type.DOUBLE:
        JSType.TO_NUMBER.invoke(mv);
        break;
    default:
        if(asmReturnType.equals(OBJECT_TYPE)) {
            // Must hide ConsString (and potentially other internal Nashorn types) from callers
            mv.invokestatic(SERVICES_CLASS_TYPE_NAME, "exportReturnValue", EXPORT_RETURN_VALUE_METHOD_DESCRIPTOR, false);
        } else if(asmReturnType.equals(STRING_TYPE)){
            // Well-known conversion to String. Not using the JSType one as we want to preserve null as null instead
            // of the string "n,u,l,l".
            mv.invokestatic(SERVICES_CLASS_TYPE_NAME, "toString", TO_STRING_METHOD_DESCRIPTOR, false);
        } else {
            // Invoke converter method handle for everything else. Note that we could have just added an asType or
            // filterReturnValue to the invoked handle instead, but then every instance would have the function
            // method handle wrapped in a separate converter method handle, making handle.invokeExact() megamorphic.
            if(classOverride) {
                mv.getstatic(generatedClassName, converterFields.get(returnType), METHOD_HANDLE_TYPE_DESCRIPTOR);
            } else {
                mv.visitVarInsn(ALOAD, 0);
                mv.getfield(generatedClassName, converterFields.get(returnType), METHOD_HANDLE_TYPE_DESCRIPTOR);
            }
            mv.swap();
            emitInvokeExact(mv, MethodType.methodType(returnType, Object.class));
        }
    }
}
 
Example 17
Source File: GeneratorAdapter.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Generates the instruction to push the given value on the stack.
 *
 * @param value
 *            the value to be pushed on the stack.
 */
public void push(final Type value) {
    if (value == null) {
        mv.visitInsn(Opcodes.ACONST_NULL);
    } else {
        switch (value.getSort()) {
        case Type.BOOLEAN:
            mv.visitFieldInsn(Opcodes.GETSTATIC, "java/lang/Boolean",
                    "TYPE", CLDESC);
            break;
        case Type.CHAR:
            mv.visitFieldInsn(Opcodes.GETSTATIC, "java/lang/Character",
                    "TYPE", CLDESC);
            break;
        case Type.BYTE:
            mv.visitFieldInsn(Opcodes.GETSTATIC, "java/lang/Byte", "TYPE",
                    CLDESC);
            break;
        case Type.SHORT:
            mv.visitFieldInsn(Opcodes.GETSTATIC, "java/lang/Short", "TYPE",
                    CLDESC);
            break;
        case Type.INT:
            mv.visitFieldInsn(Opcodes.GETSTATIC, "java/lang/Integer",
                    "TYPE", CLDESC);
            break;
        case Type.FLOAT:
            mv.visitFieldInsn(Opcodes.GETSTATIC, "java/lang/Float", "TYPE",
                    CLDESC);
            break;
        case Type.LONG:
            mv.visitFieldInsn(Opcodes.GETSTATIC, "java/lang/Long", "TYPE",
                    CLDESC);
            break;
        case Type.DOUBLE:
            mv.visitFieldInsn(Opcodes.GETSTATIC, "java/lang/Double",
                    "TYPE", CLDESC);
            break;
        default:
            mv.visitLdcInsn(value);
        }
    }
}
 
Example 18
Source File: AnalyzerAdapter.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Creates a new {@link AnalyzerAdapter}.
 *
 * @param api
 *            the ASM API version implemented by this visitor. Must be one
 *            of {@link Opcodes#ASM4} or {@link Opcodes#ASM5}.
 * @param owner
 *            the owner's class name.
 * @param access
 *            the method's access flags (see {@link Opcodes}).
 * @param name
 *            the method's name.
 * @param desc
 *            the method's descriptor (see {@link Type Type}).
 * @param mv
 *            the method visitor to which this adapter delegates calls. May
 *            be <tt>null</tt>.
 */
protected AnalyzerAdapter(final int api, final String owner,
        final int access, final String name, final String desc,
        final MethodVisitor mv) {
    super(api, mv);
    this.owner = owner;
    locals = new ArrayList<Object>();
    stack = new ArrayList<Object>();
    uninitializedTypes = new HashMap<Object, Object>();

    if ((access & Opcodes.ACC_STATIC) == 0) {
        if ("<init>".equals(name)) {
            locals.add(Opcodes.UNINITIALIZED_THIS);
        } else {
            locals.add(owner);
        }
    }
    Type[] types = Type.getArgumentTypes(desc);
    for (int i = 0; i < types.length; ++i) {
        Type type = types[i];
        switch (type.getSort()) {
        case Type.BOOLEAN:
        case Type.CHAR:
        case Type.BYTE:
        case Type.SHORT:
        case Type.INT:
            locals.add(Opcodes.INTEGER);
            break;
        case Type.FLOAT:
            locals.add(Opcodes.FLOAT);
            break;
        case Type.LONG:
            locals.add(Opcodes.LONG);
            locals.add(Opcodes.TOP);
            break;
        case Type.DOUBLE:
            locals.add(Opcodes.DOUBLE);
            locals.add(Opcodes.TOP);
            break;
        case Type.ARRAY:
            locals.add(types[i].getDescriptor());
            break;
        // case Type.OBJECT:
        default:
            locals.add(types[i].getInternalName());
        }
    }
    maxLocals = locals.size();
}
 
Example 19
Source File: AnalyzerAdapter.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Creates a new {@link AnalyzerAdapter}.
 *
 * @param api
 *            the ASM API version implemented by this visitor. Must be one
 *            of {@link Opcodes#ASM4} or {@link Opcodes#ASM5}.
 * @param owner
 *            the owner's class name.
 * @param access
 *            the method's access flags (see {@link Opcodes}).
 * @param name
 *            the method's name.
 * @param desc
 *            the method's descriptor (see {@link Type Type}).
 * @param mv
 *            the method visitor to which this adapter delegates calls. May
 *            be <tt>null</tt>.
 */
protected AnalyzerAdapter(final int api, final String owner,
        final int access, final String name, final String desc,
        final MethodVisitor mv) {
    super(api, mv);
    this.owner = owner;
    locals = new ArrayList<Object>();
    stack = new ArrayList<Object>();
    uninitializedTypes = new HashMap<Object, Object>();

    if ((access & Opcodes.ACC_STATIC) == 0) {
        if ("<init>".equals(name)) {
            locals.add(Opcodes.UNINITIALIZED_THIS);
        } else {
            locals.add(owner);
        }
    }
    Type[] types = Type.getArgumentTypes(desc);
    for (int i = 0; i < types.length; ++i) {
        Type type = types[i];
        switch (type.getSort()) {
        case Type.BOOLEAN:
        case Type.CHAR:
        case Type.BYTE:
        case Type.SHORT:
        case Type.INT:
            locals.add(Opcodes.INTEGER);
            break;
        case Type.FLOAT:
            locals.add(Opcodes.FLOAT);
            break;
        case Type.LONG:
            locals.add(Opcodes.LONG);
            locals.add(Opcodes.TOP);
            break;
        case Type.DOUBLE:
            locals.add(Opcodes.DOUBLE);
            locals.add(Opcodes.TOP);
            break;
        case Type.ARRAY:
            locals.add(types[i].getDescriptor());
            break;
        // case Type.OBJECT:
        default:
            locals.add(types[i].getInternalName());
        }
    }
    maxLocals = locals.size();
}
 
Example 20
Source File: GeneratorAdapter.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Generates the instruction to push the given value on the stack.
 *
 * @param value
 *            the value to be pushed on the stack.
 */
public void push(final Type value) {
    if (value == null) {
        mv.visitInsn(Opcodes.ACONST_NULL);
    } else {
        switch (value.getSort()) {
        case Type.BOOLEAN:
            mv.visitFieldInsn(Opcodes.GETSTATIC, "java/lang/Boolean",
                    "TYPE", CLDESC);
            break;
        case Type.CHAR:
            mv.visitFieldInsn(Opcodes.GETSTATIC, "java/lang/Character",
                    "TYPE", CLDESC);
            break;
        case Type.BYTE:
            mv.visitFieldInsn(Opcodes.GETSTATIC, "java/lang/Byte", "TYPE",
                    CLDESC);
            break;
        case Type.SHORT:
            mv.visitFieldInsn(Opcodes.GETSTATIC, "java/lang/Short", "TYPE",
                    CLDESC);
            break;
        case Type.INT:
            mv.visitFieldInsn(Opcodes.GETSTATIC, "java/lang/Integer",
                    "TYPE", CLDESC);
            break;
        case Type.FLOAT:
            mv.visitFieldInsn(Opcodes.GETSTATIC, "java/lang/Float", "TYPE",
                    CLDESC);
            break;
        case Type.LONG:
            mv.visitFieldInsn(Opcodes.GETSTATIC, "java/lang/Long", "TYPE",
                    CLDESC);
            break;
        case Type.DOUBLE:
            mv.visitFieldInsn(Opcodes.GETSTATIC, "java/lang/Double",
                    "TYPE", CLDESC);
            break;
        default:
            mv.visitLdcInsn(value);
        }
    }
}