Java Code Examples for jdk.internal.org.objectweb.asm.Opcodes#AASTORE

The following examples show how to use jdk.internal.org.objectweb.asm.Opcodes#AASTORE . 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: InvokerBytecodeGenerator.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
private int arrayInsnOpcode(byte tcode, int aaop) throws InternalError {
    assert(aaop == Opcodes.AASTORE || aaop == Opcodes.AALOAD);
    int xas;
    switch (tcode) {
        case Opcodes.T_BOOLEAN: xas = Opcodes.BASTORE; break;
        case Opcodes.T_BYTE:    xas = Opcodes.BASTORE; break;
        case Opcodes.T_CHAR:    xas = Opcodes.CASTORE; break;
        case Opcodes.T_SHORT:   xas = Opcodes.SASTORE; break;
        case Opcodes.T_INT:     xas = Opcodes.IASTORE; break;
        case Opcodes.T_LONG:    xas = Opcodes.LASTORE; break;
        case Opcodes.T_FLOAT:   xas = Opcodes.FASTORE; break;
        case Opcodes.T_DOUBLE:  xas = Opcodes.DASTORE; break;
        case 0:                 xas = Opcodes.AASTORE; break;
        default:      throw new InternalError();
    }
    return xas - Opcodes.AASTORE + aaop;
}
 
Example 2
Source File: InvokerBytecodeGenerator.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
private int arrayInsnOpcode(byte tcode, int aaop) throws InternalError {
    assert(aaop == Opcodes.AASTORE || aaop == Opcodes.AALOAD);
    int xas;
    switch (tcode) {
        case Opcodes.T_BOOLEAN: xas = Opcodes.BASTORE; break;
        case Opcodes.T_BYTE:    xas = Opcodes.BASTORE; break;
        case Opcodes.T_CHAR:    xas = Opcodes.CASTORE; break;
        case Opcodes.T_SHORT:   xas = Opcodes.SASTORE; break;
        case Opcodes.T_INT:     xas = Opcodes.IASTORE; break;
        case Opcodes.T_LONG:    xas = Opcodes.LASTORE; break;
        case Opcodes.T_FLOAT:   xas = Opcodes.FASTORE; break;
        case Opcodes.T_DOUBLE:  xas = Opcodes.DASTORE; break;
        case 0:                 xas = Opcodes.AASTORE; break;
        default:      throw new InternalError();
    }
    return xas - Opcodes.AASTORE + aaop;
}
 
Example 3
Source File: InvokerBytecodeGenerator.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
void emitNewArray(Name name) throws InternalError {
    Class<?> rtype = name.function.methodType().returnType();
    if (name.arguments.length == 0) {
        // The array will be a constant.
        Object emptyArray;
        try {
            emptyArray = name.function.resolvedHandle().invoke();
        } catch (Throwable ex) {
            throw uncaughtException(ex);
        }
        assert(java.lang.reflect.Array.getLength(emptyArray) == 0);
        assert(emptyArray.getClass() == rtype);  // exact typing
        mv.visitLdcInsn(constantPlaceholder(emptyArray));
        emitReferenceCast(rtype, emptyArray);
        return;
    }
    Class<?> arrayElementType = rtype.getComponentType();
    assert(arrayElementType != null);
    emitIconstInsn(name.arguments.length);
    int xas = Opcodes.AASTORE;
    if (!arrayElementType.isPrimitive()) {
        mv.visitTypeInsn(Opcodes.ANEWARRAY, getInternalName(arrayElementType));
    } else {
        byte tc = arrayTypeCode(Wrapper.forPrimitiveType(arrayElementType));
        xas = arrayInsnOpcode(tc, xas);
        mv.visitIntInsn(Opcodes.NEWARRAY, tc);
    }
    // store arguments
    for (int i = 0; i < name.arguments.length; i++) {
        mv.visitInsn(Opcodes.DUP);
        emitIconstInsn(i);
        emitPushArgument(name, i);
        mv.visitInsn(xas);
    }
    // the array is left on the stack
    assertStaticType(rtype, name);
}
 
Example 4
Source File: InvokerBytecodeGenerator.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
void emitNewArray(Name name) throws InternalError {
    Class<?> rtype = name.function.methodType().returnType();
    if (name.arguments.length == 0) {
        // The array will be a constant.
        Object emptyArray;
        try {
            emptyArray = name.function.resolvedHandle().invoke();
        } catch (Throwable ex) {
            throw uncaughtException(ex);
        }
        assert(java.lang.reflect.Array.getLength(emptyArray) == 0);
        assert(emptyArray.getClass() == rtype);  // exact typing
        mv.visitLdcInsn(constantPlaceholder(emptyArray));
        emitReferenceCast(rtype, emptyArray);
        return;
    }
    Class<?> arrayElementType = rtype.getComponentType();
    assert(arrayElementType != null);
    emitIconstInsn(name.arguments.length);
    int xas = Opcodes.AASTORE;
    if (!arrayElementType.isPrimitive()) {
        mv.visitTypeInsn(Opcodes.ANEWARRAY, getInternalName(arrayElementType));
    } else {
        byte tc = arrayTypeCode(Wrapper.forPrimitiveType(arrayElementType));
        xas = arrayInsnOpcode(tc, xas);
        mv.visitIntInsn(Opcodes.NEWARRAY, tc);
    }
    // store arguments
    for (int i = 0; i < name.arguments.length; i++) {
        mv.visitInsn(Opcodes.DUP);
        emitIconstInsn(i);
        emitPushArgument(name, i);
        mv.visitInsn(xas);
    }
    // the array is left on the stack
    assertStaticType(rtype, name);
}