Example usage for org.objectweb.asm Opcodes FSTORE

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

Introduction

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

Prototype

int FSTORE

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

Click Source Link

Usage

From source file:org.brutusin.instrumentation.utils.TreeInstructions.java

License:Apache License

public static VarInsnNode getStoreInst(Type type, int position) {
    int opCode = -1;
    switch (type.getDescriptor().charAt(0)) {
    case 'B':
        opCode = Opcodes.ISTORE;/*from www.j  a v a  2 s. c  o  m*/
        break;
    case 'C':
        opCode = Opcodes.ISTORE;
        break;
    case 'D':
        opCode = Opcodes.DSTORE;
        break;
    case 'F':
        opCode = Opcodes.FSTORE;
        break;
    case 'I':
        opCode = Opcodes.ISTORE;
        break;
    case 'J':
        opCode = Opcodes.LSTORE;
        break;
    case 'L':
        opCode = Opcodes.ASTORE;
        break;
    case '[':
        opCode = Opcodes.ASTORE;
        break;
    case 'Z':
        opCode = Opcodes.ISTORE;
        break;
    case 'S':
        opCode = Opcodes.ISTORE;
        break;
    default:
        throw new ClassFormatError("Invalid method signature: " + type.getDescriptor());
    }
    return new VarInsnNode(opCode, position);
}

From source file:org.decojer.cavaj.readers.asm.ReadMethodVisitor.java

License:Open Source License

@Override
public void visitVarInsn(final int opcode, final int var) {
    T t = null;/*from w  ww .  jav a 2 s . c o m*/

    switch (opcode) {
    /********
     * LOAD *
     ********/
    case Opcodes.ALOAD:
        t = T.REF;
        // fall through
    case Opcodes.DLOAD:
        if (t == null) {
            t = T.DOUBLE;
        }
        // fall through
    case Opcodes.FLOAD:
        if (t == null) {
            t = T.FLOAT;
        }
        // fall through
    case Opcodes.ILOAD:
        if (t == null) {
            t = T.AINT;
        }
        // fall through
    case Opcodes.LLOAD:
        if (t == null) {
            t = T.LONG;
        }
        add(new LOAD(this.ops.size(), opcode, this.line, t, var));
        break;
    /*********
     * STORE *
     *********/
    case Opcodes.ASTORE:
        t = T.AREF; // RET allowed too
        // fall through
    case Opcodes.DSTORE:
        if (t == null) {
            t = T.DOUBLE;
        }
        // fall through
    case Opcodes.FSTORE:
        if (t == null) {
            t = T.FLOAT;
        }
        // fall through
    case Opcodes.ISTORE:
        if (t == null) {
            t = T.AINT;
        }
        // fall through
    case Opcodes.LSTORE:
        if (t == null) {
            t = T.LONG;
        }
        add(new STORE(this.ops.size(), opcode, this.line, t, var));
        break;
    /*******
     * RET *
     *******/
    case Opcodes.RET: {
        add(new RET(this.ops.size(), opcode, this.line, var));
        break;
    }
    default:
        log.warn(getM() + ": Unknown var insn opcode '" + opcode + "'!");
    }
}

From source file:org.elasticsearch.painless.Writer.java

License:Apache License

private void writeExecute() {
    final int access = Opcodes.ACC_PUBLIC;
    execute = new GeneratorAdapter(access, EXECUTE, SIGNATURE, null, writer);

    final Label fals = new Label();
    final Label end = new Label();
    execute.visitVarInsn(Opcodes.ALOAD, metadata.inputValueSlot);
    execute.push("#score");
    execute.invokeInterface(MAP_TYPE, MAP_GET);
    execute.dup();/*from  ww  w.j a  v  a 2  s  .co m*/
    execute.ifNull(fals);
    execute.checkCast(SCORE_ACCESSOR_TYPE);
    execute.invokeVirtual(SCORE_ACCESSOR_TYPE, SCORE_ACCESSOR_FLOAT);
    execute.goTo(end);
    execute.mark(fals);
    execute.pop();
    execute.push(0F);
    execute.mark(end);
    execute.visitVarInsn(Opcodes.FSTORE, metadata.scoreValueSlot);

    execute.push(settings.getMaxLoopCounter());
    execute.visitVarInsn(Opcodes.ISTORE, metadata.loopCounterSlot);

    visit(root);
    execute.endMethod();
}

From source file:org.elasticsearch.plan.a.Writer.java

License:Apache License

private void writeExecute() {
    final int access = Opcodes.ACC_PUBLIC | Opcodes.ACC_SYNTHETIC;
    execute = new GeneratorAdapter(access, EXECUTE, SIGNATURE, null, writer);

    final Label fals = new Label();
    final Label end = new Label();
    execute.visitVarInsn(Opcodes.ALOAD, metadata.inputValueSlot);
    execute.push("#score");
    execute.invokeInterface(MAP_TYPE, MAP_GET);
    execute.dup();//from  w  w w  .  j a va  2  s . c om
    execute.ifNull(fals);
    execute.checkCast(SCORE_ACCESSOR_TYPE);
    execute.invokeVirtual(SCORE_ACCESSOR_TYPE, SCORE_ACCESSOR_FLOAT);
    execute.goTo(end);
    execute.mark(fals);
    execute.pop();
    execute.push(0F);
    execute.mark(end);
    execute.visitVarInsn(Opcodes.FSTORE, metadata.scoreValueSlot);

    execute.push(settings.getMaxLoopCounter());
    execute.visitVarInsn(Opcodes.ISTORE, metadata.loopCounterSlot);

    visit(root);
    execute.endMethod();
}

From source file:org.evosuite.graphs.cfg.ASMWrapper.java

License:Open Source License

/**
 * <p>//w w  w. j  ava 2 s.co  m
 * isLocalVarDefinition
 * </p>
 * 
 * @return a boolean.
 */
public boolean isLocalVariableDefinition() {
    return asmNode.getOpcode() == Opcodes.ISTORE || asmNode.getOpcode() == Opcodes.LSTORE
            || asmNode.getOpcode() == Opcodes.FSTORE || asmNode.getOpcode() == Opcodes.DSTORE
            || asmNode.getOpcode() == Opcodes.ASTORE || asmNode.getOpcode() == Opcodes.IINC
            || isLocalArrayDefinition();
}

From source file:org.evosuite.graphs.cfg.BytecodeInstructionPool.java

License:Open Source License

/**
 * Determine how many bytes the current instruction occupies together with
 * its operands// ww w  .  j  av  a 2 s. com
 * 
 * @return
 */
private int getBytecodeIncrement(AbstractInsnNode instructionNode) {
    int opcode = instructionNode.getOpcode();
    switch (opcode) {
    case Opcodes.ALOAD: // index
    case Opcodes.ASTORE: // index
    case Opcodes.DLOAD:
    case Opcodes.DSTORE:
    case Opcodes.FLOAD:
    case Opcodes.FSTORE:
    case Opcodes.ILOAD:
    case Opcodes.ISTORE:
    case Opcodes.LLOAD:
    case Opcodes.LSTORE:
        VarInsnNode varNode = (VarInsnNode) instructionNode;
        if (varNode.var > 3)
            return 1;
        else
            return 0;
    case Opcodes.BIPUSH: // byte
    case Opcodes.NEWARRAY:
    case Opcodes.RET:
        return 1;
    case Opcodes.LDC:
        LdcInsnNode ldcNode = (LdcInsnNode) instructionNode;
        if (ldcNode.cst instanceof Double || ldcNode.cst instanceof Long)
            return 2; // LDC2_W
        else
            return 1;
    case 19: //LDC_W
    case 20: //LDC2_W
        return 2;
    case Opcodes.ANEWARRAY: // indexbyte1, indexbyte2
    case Opcodes.CHECKCAST: // indexbyte1, indexbyte2
    case Opcodes.GETFIELD:
    case Opcodes.GETSTATIC:
    case Opcodes.GOTO:
    case Opcodes.IF_ACMPEQ:
    case Opcodes.IF_ACMPNE:
    case Opcodes.IF_ICMPEQ:
    case Opcodes.IF_ICMPNE:
    case Opcodes.IF_ICMPGE:
    case Opcodes.IF_ICMPGT:
    case Opcodes.IF_ICMPLE:
    case Opcodes.IF_ICMPLT:
    case Opcodes.IFLE:
    case Opcodes.IFLT:
    case Opcodes.IFGE:
    case Opcodes.IFGT:
    case Opcodes.IFNE:
    case Opcodes.IFEQ:
    case Opcodes.IFNONNULL:
    case Opcodes.IFNULL:
    case Opcodes.IINC:
    case Opcodes.INSTANCEOF:
    case Opcodes.INVOKESPECIAL:
    case Opcodes.INVOKESTATIC:
    case Opcodes.INVOKEVIRTUAL:
    case Opcodes.JSR:
    case Opcodes.NEW:
    case Opcodes.PUTFIELD:
    case Opcodes.PUTSTATIC:
    case Opcodes.SIPUSH:
        // case Opcodes.LDC_W
        // case Opcodes.LDC2_W

        return 2;
    case Opcodes.MULTIANEWARRAY:
        return 3;
    case Opcodes.INVOKEDYNAMIC:
    case Opcodes.INVOKEINTERFACE:
        return 4;

    case Opcodes.LOOKUPSWITCH:
    case Opcodes.TABLESWITCH:
        // TODO: Could be more
        return 4;
    // case Opcodes.GOTO_W 
    // case Opcodes.JSR_W
    }
    return 0;
}

From source file:org.evosuite.instrumentation.mutation.ReplaceArithmeticOperator.java

License:Open Source License

@SuppressWarnings("rawtypes")
private static int getNextIndexFromLoad(MethodNode mn) {
    Iterator it = mn.instructions.iterator();
    int index = 0;
    while (it.hasNext()) {
        AbstractInsnNode node = (AbstractInsnNode) it.next();
        if (node instanceof VarInsnNode) {
            VarInsnNode varNode = (VarInsnNode) node;
            int varIndex = varNode.var;
            switch (varNode.getOpcode()) {
            case Opcodes.ALOAD:
            case Opcodes.ILOAD:
            case Opcodes.FLOAD:
            case Opcodes.IALOAD:
            case Opcodes.BALOAD:
            case Opcodes.CALOAD:
            case Opcodes.AALOAD:
            case Opcodes.ASTORE:
            case Opcodes.ISTORE:
            case Opcodes.FSTORE:
            case Opcodes.IASTORE:
            case Opcodes.BASTORE:
            case Opcodes.CASTORE:
            case Opcodes.AASTORE:
                index = Math.max(index, varIndex + 1);
                break;
            case Opcodes.DLOAD:
            case Opcodes.DSTORE:
            case Opcodes.LLOAD:
            case Opcodes.LSTORE:
            case Opcodes.DALOAD:
            case Opcodes.DASTORE:
            case Opcodes.LALOAD:
            case Opcodes.LASTORE:
                index = Math.max(index, varIndex + 2);
                break;
            }/*from   w  ww .  ja v  a  2  s .  c om*/
        }
    }

    return index;
}

From source file:org.glassfish.pfl.tf.spi.Util.java

License:Open Source License

public void initLocal(MethodVisitor mv, LocalVariableNode var) {
    info(2, "Initializing variable " + var);
    Type type = Type.getType(var.desc);
    switch (type.getSort()) {
    case Type.BYTE:
    case Type.BOOLEAN:
    case Type.CHAR:
    case Type.SHORT:
    case Type.INT:
        mv.visitInsn(Opcodes.ICONST_0);//w w w  .j a  v  a  2s  .  c  o  m
        mv.visitVarInsn(Opcodes.ISTORE, var.index);
        break;

    case Type.LONG:
        mv.visitInsn(Opcodes.LCONST_0);
        mv.visitVarInsn(Opcodes.LSTORE, var.index);
        break;

    case Type.FLOAT:
        mv.visitInsn(Opcodes.FCONST_0);
        mv.visitVarInsn(Opcodes.FSTORE, var.index);
        break;

    case Type.DOUBLE:
        mv.visitInsn(Opcodes.DCONST_0);
        mv.visitVarInsn(Opcodes.DSTORE, var.index);
        break;

    default:
        mv.visitInsn(Opcodes.ACONST_NULL);
        mv.visitVarInsn(Opcodes.ASTORE, var.index);
    }
}

From source file:org.glassfish.pfl.tf.spi.Util.java

License:Open Source License

public void storeFromXReturn(MethodVisitor mv, int returnOpcode, LocalVariableNode holder) {

    switch (returnOpcode) {
    case Opcodes.RETURN:
        // NOP/*from  w  ww  .  j a  va 2 s. com*/
        break;
    case Opcodes.ARETURN:
        mv.visitVarInsn(Opcodes.ASTORE, holder.index);
        break;
    case Opcodes.IRETURN:
        mv.visitVarInsn(Opcodes.ISTORE, holder.index);
        break;
    case Opcodes.LRETURN:
        mv.visitVarInsn(Opcodes.LSTORE, holder.index);
        break;
    case Opcodes.FRETURN:
        mv.visitVarInsn(Opcodes.FSTORE, holder.index);
        break;
    case Opcodes.DRETURN:
        mv.visitVarInsn(Opcodes.DSTORE, holder.index);
        break;
    }
}

From source file:org.jacoco.core.internal.flow.FrameSnapshotTest.java

License:Open Source License

@Test
public void should_capture_frame_when_frame_is_defined() {
    analyzer.visitInsn(Opcodes.FCONST_0);
    analyzer.visitVarInsn(Opcodes.FSTORE, 1);
    analyzer.visitInsn(Opcodes.ICONST_0);
    frame = FrameSnapshot.create(analyzer, 0);

    expectedVisitor.visitFrame(Opcodes.F_FULL, 2, arr("Foo", Opcodes.FLOAT), 1, arr(Opcodes.INTEGER));
}