Example usage for org.objectweb.asm Opcodes ISTORE

List of usage examples for org.objectweb.asm Opcodes ISTORE

Introduction

In this page you can find the example usage for org.objectweb.asm Opcodes ISTORE.

Prototype

int ISTORE

To view the source code for org.objectweb.asm Opcodes ISTORE.

Click Source Link

Usage

From source file:org.jacoco.core.internal.instr.FrameTracker.java

License:Open Source License

@Override
public void visitVarInsn(final int opcode, final int var) {
    final Object t;
    switch (opcode) {
    case Opcodes.ALOAD:
        push(get(var));
        break;//  w  w w.  j ava  2 s  .  c o  m
    case Opcodes.ILOAD:
        push(Opcodes.INTEGER);
        break;
    case Opcodes.FLOAD:
        push(Opcodes.FLOAT);
        break;
    case Opcodes.LLOAD:
        push(Opcodes.LONG);
        push(Opcodes.TOP);
        break;
    case Opcodes.DLOAD:
        push(Opcodes.DOUBLE);
        push(Opcodes.TOP);
        break;
    case Opcodes.ASTORE:
    case Opcodes.ISTORE:
    case Opcodes.FSTORE:
        t = pop();
        set(var, t);
        break;
    case Opcodes.LSTORE:
    case Opcodes.DSTORE:
        pop(1);
        t = pop();
        set(var, t);
        set(var + 1, Opcodes.TOP);
        break;
    default:
        throw new IllegalArgumentException();
    }
    mv.visitVarInsn(opcode, var);
}

From source file:org.jacoco.core.internal.instr.ProbeInserterTest.java

License:Open Source License

@Test
public void testVisitVarIns() {
    ProbeInserter pi = new ProbeInserter(0, "(II)V", actualVisitor, arrayStrategy);

    pi.visitVarInsn(Opcodes.ALOAD, 0);/* w w w . java 2  s . c  o m*/
    pi.visitVarInsn(Opcodes.ILOAD, 1);
    pi.visitVarInsn(Opcodes.ILOAD, 2);
    pi.visitVarInsn(Opcodes.ISTORE, 3);
    pi.visitVarInsn(Opcodes.FSTORE, 4);

    // Argument variables stay at the same position:
    expectedVisitor.visitVarInsn(Opcodes.ALOAD, 0);
    expectedVisitor.visitVarInsn(Opcodes.ILOAD, 1);
    expectedVisitor.visitVarInsn(Opcodes.ILOAD, 2);

    // Local variables are shifted by one:
    expectedVisitor.visitVarInsn(Opcodes.ISTORE, 4);
    expectedVisitor.visitVarInsn(Opcodes.FSTORE, 5);
}

From source file:org.jboss.byteman.agent.adapter.RuleGeneratorAdapter.java

License:Open Source License

/**
 * Generates the instruction to store the top stack value in a local
 * variable./*from  www.  ja va2s.  co m*/
 *
 * @param type the type of the local variable to be stored.
 * @param index an index in the frame's local variables array.
 */
private void storeInsn(final Type type, final int index) {
    visitVarInsn(type.getOpcode(Opcodes.ISTORE), index);
}

From source file:org.jboss.byteman.agent.adapter.RuleGeneratorAdapter.java

License:Open Source License

/**
 * override this so we can see track which local var slots are in use and avoid overwriting them
 * @param opcode//from  ww  w . j  av  a 2 s  .c  o  m
 * @param var
 */
public void visitVarInsn(final int opcode, final int var) {
    if (var >= nextLocal || localTypes.get(var) == null) {
        int size = 1;
        Type type = null;
        switch (opcode) {
        case Opcodes.ISTORE:
            type = Type.INT_TYPE;
            break;
        case Opcodes.LSTORE:
            type = Type.LONG_TYPE;
            size = 2;
            break;
        case Opcodes.FSTORE:
            type = Type.FLOAT_TYPE;
            break;
        case Opcodes.DSTORE:
            type = Type.DOUBLE_TYPE;
            size = 2;
            break;
        case Opcodes.ASTORE:
        // we don't know exactly what type this is but at least we know it is an object
        {
            String name = getTriggerClassName().replace('.', '/');
            type = Type.getType("L" + name + ";");
        }
            // type = Type.getType(Object.class);
            break;
        }
        if (var < nextLocal) {
            // just fill in the missing type
            localTypes.set(var, type);
        } else {

            // we may not have seen some of the locals so leave a blank spot for them in the types array
            for (int i = nextLocal; i < var; i++) {
                localTypes.add(null);
            }
            // now add entry for var

            localTypes.add(type);
            if (size > 1) {
                localTypes.add(null);
            }
            nextLocal = var + size;

            if (nextLocal > localHighWater) {
                localHighWater = nextLocal;
            }
        }
    }
    super.visitVarInsn(opcode, var);
}

From source file:org.jboss.byteman.agent.adapter.RuleGeneratorAdapter.java

License:Open Source License

/**
 * save a value on the stack to a local var slot
 * @param local the slot to save to// ww w.ja  v a 2  s .c om
 */

public void storeLocal(int local) {
    Type type = (Type) localTypes.get(local);
    visitVarInsn(type.getOpcode(Opcodes.ISTORE), local);
}

From source file:org.jtsan.LocalVarsSaver.java

License:Apache License

public void saveStack() {
    for (int i = types.size() - 1; i >= 0; i--) {
        mv.visitVarInsn(types.get(i).getOpcode(Opcodes.ISTORE), vars.get(i));
    }
}

From source file:org.jtsan.LocalVarsSaver.java

License:Apache License

public void saveReturnValue() {
    if (!hasReturnValue()) {
        throw new RuntimeException("Return value type is not porperly initialized to be saved.");
    }/*  w  w  w.  j  a  va  2 s .co  m*/
    mv.visitVarInsn(returnType.getOpcode(Opcodes.ISTORE), returnVar);
}

From source file:org.mbte.groovypp.compiler.bytecode.BytecodeExpr.java

License:Apache License

public static void store(ClassNode type, int idx, MethodVisitor mv) {
    if (type == double_TYPE) {
        mv.visitVarInsn(Opcodes.DSTORE, idx);
    } else if (type == float_TYPE) {
        mv.visitVarInsn(Opcodes.FSTORE, idx);
    } else if (type == long_TYPE) {
        mv.visitVarInsn(Opcodes.LSTORE, idx);
    } else if (type == boolean_TYPE || type == char_TYPE || type == byte_TYPE || type == int_TYPE
            || type == short_TYPE) {
        mv.visitVarInsn(Opcodes.ISTORE, idx);
    } else {//from  w w w  . j a  v a2 s .  c o m
        mv.visitVarInsn(Opcodes.ASTORE, idx);
    }
}

From source file:org.mbte.groovypp.compiler.StaticCompiler.java

License:Apache License

private void tailRecursive(ResolvedMethodBytecodeExpr resolvedMethodBytecodeExpr) {
    Parameter[] parameters = methodNode.getParameters();

    int varIndex = methodNode.isStatic() ? 0 : 1;
    if (varIndex != 0) {
        resolvedMethodBytecodeExpr.getObject().visit(mv);
    }/*w ww . j  a  va2 s. co  m*/
    for (int i = 0; i != parameters.length; ++i) {
        BytecodeExpr be = (BytecodeExpr) resolvedMethodBytecodeExpr.getBargs().getExpressions().get(i);
        be.visit(mv);
        final ClassNode paramType = parameters[i].getType();
        final ClassNode type = be.getType();
        BytecodeExpr.box(type, mv);
        BytecodeExpr.cast(TypeUtil.wrapSafely(type), TypeUtil.wrapSafely(paramType), mv);
        BytecodeExpr.unbox(paramType, mv);

        varIndex += (paramType == ClassHelper.long_TYPE || paramType == ClassHelper.double_TYPE) ? 2 : 1;
    }

    for (int i = parameters.length - 1; i >= 0; --i) {
        final ClassNode paramType = parameters[i].getType();
        varIndex -= (paramType == ClassHelper.long_TYPE || paramType == ClassHelper.double_TYPE) ? 2 : 1;

        if (paramType == double_TYPE) {
            mv.visitVarInsn(Opcodes.DSTORE, varIndex);
        } else if (paramType == float_TYPE) {
            mv.visitVarInsn(Opcodes.FSTORE, varIndex);
        } else if (paramType == long_TYPE) {
            mv.visitVarInsn(Opcodes.LSTORE, varIndex);
        } else if (paramType == boolean_TYPE || paramType == char_TYPE || paramType == byte_TYPE
                || paramType == int_TYPE || paramType == short_TYPE) {
            mv.visitVarInsn(Opcodes.ISTORE, varIndex);
        } else {
            mv.visitVarInsn(Opcodes.ASTORE, varIndex);
        }
    }

    if (!methodNode.isStatic()) {
        mv.visitVarInsn(ASTORE, 0);
    }
    mv.visitJumpInsn(GOTO, startLabel);
    return;
}

From source file:org.mutabilitydetector.checkers.settermethod.EffectiveAssignmentInsnVerifier.java

License:Apache License

private static boolean isAliasStoreInstruction(final AbstractInsnNode insn, final int aliasLocalVariable) {
    switch (insn.getOpcode()) {
    case Opcodes.ISTORE:
    case Opcodes.LSTORE:
    case Opcodes.FSTORE:
    case Opcodes.DSTORE:
    case Opcodes.ASTORE:
        final VarInsnNode varInsnNode = (VarInsnNode) insn;
        return aliasLocalVariable == varInsnNode.var;
    default:/*from   w  ww.  j  ava  2 s.c o  m*/
        return false;
    }
}