Example usage for org.objectweb.asm MethodVisitor visitInsn

List of usage examples for org.objectweb.asm MethodVisitor visitInsn

Introduction

In this page you can find the example usage for org.objectweb.asm MethodVisitor visitInsn.

Prototype

public void visitInsn(final int opcode) 

Source Link

Document

Visits a zero operand instruction.

Usage

From source file:com.gargoylesoftware.js.nashorn.internal.codegen.types.IntType.java

License:Open Source License

@Override
public Type ldc(final MethodVisitor method, final Object c) {
    assert c instanceof Integer;

    final int value = ((Integer) c);

    switch (value) {
    case -1:/*from  www .j  ava 2  s.  c o  m*/
        method.visitInsn(ICONST_M1);
        break;
    case 0:
        method.visitInsn(ICONST_0);
        break;
    case 1:
        method.visitInsn(ICONST_1);
        break;
    case 2:
        method.visitInsn(ICONST_2);
        break;
    case 3:
        method.visitInsn(ICONST_3);
        break;
    case 4:
        method.visitInsn(ICONST_4);
        break;
    case 5:
        method.visitInsn(ICONST_5);
        break;
    default:
        if (value == (byte) value) {
            method.visitIntInsn(BIPUSH, value);
        } else if (value == (short) value) {
            method.visitIntInsn(SIPUSH, value);
        } else {
            method.visitLdcInsn(c);
        }
        break;
    }

    return Type.INT;
}

From source file:com.gargoylesoftware.js.nashorn.internal.codegen.types.IntType.java

License:Open Source License

@Override
public Type convert(final MethodVisitor method, final Type to) {
    if (to.isEquivalentTo(this)) {
        return to;
    }/* ww w . j  a va2  s.c  o  m*/

    if (to.isNumber()) {
        method.visitInsn(I2D);
    } else if (to.isLong()) {
        method.visitInsn(I2L);
    } else if (to.isBoolean()) {
        //nop
    } else if (to.isString()) {
        invokestatic(method, TO_STRING);
    } else if (to.isObject()) {
        invokestatic(method, VALUE_OF);
    } else {
        throw new UnsupportedOperationException("Illegal conversion " + this + " -> " + to);
    }

    return to;
}

From source file:com.gargoylesoftware.js.nashorn.internal.codegen.types.IntType.java

License:Open Source License

@Override
public Type add(final MethodVisitor method, final int programPoint) {
    if (programPoint == INVALID_PROGRAM_POINT) {
        method.visitInsn(IADD);
    } else {/*ww  w.  jav  a2 s . c  o  m*/
        method.visitInvokeDynamicInsn("iadd", "(II)I", MATHBOOTSTRAP, programPoint);
    }
    return INT;
}

From source file:com.gargoylesoftware.js.nashorn.internal.codegen.types.IntType.java

License:Open Source License

@Override
public Type shr(final MethodVisitor method) {
    method.visitInsn(IUSHR);
    return INT;
}

From source file:com.gargoylesoftware.js.nashorn.internal.codegen.types.IntType.java

License:Open Source License

@Override
public Type sar(final MethodVisitor method) {
    method.visitInsn(ISHR);
    return INT;
}

From source file:com.gargoylesoftware.js.nashorn.internal.codegen.types.IntType.java

License:Open Source License

@Override
public Type shl(final MethodVisitor method) {
    method.visitInsn(ISHL);
    return INT;
}

From source file:com.gargoylesoftware.js.nashorn.internal.codegen.types.IntType.java

License:Open Source License

@Override
public Type and(final MethodVisitor method) {
    method.visitInsn(IAND);
    return INT;
}

From source file:com.gargoylesoftware.js.nashorn.internal.codegen.types.IntType.java

License:Open Source License

@Override
public Type or(final MethodVisitor method) {
    method.visitInsn(IOR);
    return INT;
}

From source file:com.gargoylesoftware.js.nashorn.internal.codegen.types.IntType.java

License:Open Source License

@Override
public Type xor(final MethodVisitor method) {
    method.visitInsn(IXOR);
    return INT;
}

From source file:com.gargoylesoftware.js.nashorn.internal.codegen.types.IntType.java

License:Open Source License

@Override
public Type sub(final MethodVisitor method, final int programPoint) {
    if (programPoint == INVALID_PROGRAM_POINT) {
        method.visitInsn(ISUB);
    } else {/*from  ww w. j a va2  s  . c om*/
        method.visitInvokeDynamicInsn("isub", "(II)I", MATHBOOTSTRAP, programPoint);
    }
    return INT;
}