Example usage for org.objectweb.asm Opcodes LSTORE

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

Introduction

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

Prototype

int LSTORE

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

Click Source Link

Usage

From source file:com.mebigfatguy.junitflood.jvm.OperandStack.java

License:Apache License

public void performVarInsn(int opcode, int var) {
    switch (opcode) {
    case Opcodes.ILOAD:
    case Opcodes.LLOAD:
    case Opcodes.FLOAD:
    case Opcodes.DLOAD:
    case Opcodes.ALOAD:
        stack.add(registers.get(Integer.valueOf(var)));
        break;/*from  w w w  .  j  a v  a  2s.c  o m*/

    case Opcodes.ISTORE:
    case Opcodes.LSTORE:
    case Opcodes.FSTORE:
    case Opcodes.DSTORE:
    case Opcodes.ASTORE:
        registers.put(Integer.valueOf(var), stack.remove(stack.size() - 1));
        break;

    case Opcodes.RET:
        //nop - a fudge
        break;
    }
}

From source file:com.offbynull.coroutines.instrumenter.asm.InstructionUtils.java

License:Open Source License

/**
 * Pops the stack in to the the local variable table. You may run in to problems if the item on top of the stack isn't of the same type
 * as the variable it's being put in to.
 * @param variable variable within the local variable table to save to
 * @return instructions to pop an item off the top of the stack and save it to {@code variable}
 * @throws NullPointerException if any argument is {@code null}
 * @throws IllegalArgumentException if {@code variable} has been released
 */// w  w  w.  j a va 2  s .  c om
public static InsnList saveVar(Variable variable) {
    Validate.notNull(variable);

    InsnList ret = new InsnList();
    switch (variable.getType().getSort()) {
    case Type.BOOLEAN:
    case Type.BYTE:
    case Type.CHAR:
    case Type.SHORT:
    case Type.INT:
        ret.add(new VarInsnNode(Opcodes.ISTORE, variable.getIndex()));
        break;
    case Type.LONG:
        ret.add(new VarInsnNode(Opcodes.LSTORE, variable.getIndex()));
        break;
    case Type.FLOAT:
        ret.add(new VarInsnNode(Opcodes.FSTORE, variable.getIndex()));
        break;
    case Type.DOUBLE:
        ret.add(new VarInsnNode(Opcodes.DSTORE, variable.getIndex()));
        break;
    case Type.OBJECT:
    case Type.ARRAY:
        ret.add(new VarInsnNode(Opcodes.ASTORE, variable.getIndex()));
        break;
    default:
        throw new IllegalStateException(); // should never happen, there is code in Variable/VariableTable to make sure invalid
                                           // types aren't set
    }

    return ret;
}

From source file:com.offbynull.coroutines.instrumenter.asm.InstructionUtils.java

License:Open Source License

/**
 * Generates instructions to load the local variables table from an object array.
 *
 * @param arrayLocalsVar variable that the object array containing local variables table is stored
 * @param tempObjectVar variable to use for temporary objects
 * @param frame execution frame at the instruction for which the local variables table is to be restored
 * @return instructions to load the local variables table from an array
 * @throws NullPointerException if any argument is {@code null}
 * @throws IllegalArgumentException if variables have the same index, or if variables have been released, or if variables are of wrong
 * type//ww  w.  java 2s .c  o  m
 */
public static InsnList loadLocalVariableTable(Variable arrayLocalsVar, Variable tempObjectVar,
        Frame<BasicValue> frame) {
    Validate.notNull(arrayLocalsVar);
    Validate.notNull(tempObjectVar);
    Validate.notNull(frame);
    Validate.isTrue(arrayLocalsVar.getType().equals(Type.getType(Object[].class)));
    Validate.isTrue(tempObjectVar.getType().equals(Type.getType(Object.class)));
    validateLocalIndicies(arrayLocalsVar.getIndex(), tempObjectVar.getIndex());
    InsnList ret = new InsnList();

    // Load the locals
    for (int i = 0; i < frame.getLocals(); i++) {
        BasicValue basicValue = frame.getLocal(i);
        Type type = basicValue.getType();

        // If type == null, basicValue is pointing to uninitialized var -- basicValue.toString() will return ".". This means that this
        // slot contains nothing to load. So, skip this slot if we encounter it (such that it will remain uninitialized).
        if (type == null) {
            continue;
        }

        // If type is 'Lnull;', this means that the slot has been assigned null and that "there has been no merge yet that would 'raise'
        // the type toward some class or interface type" (from ASM mailing list). We know this slot will always contain null at this
        // point in the code so there's no specific value to load up from the array. Instead we push a null in to that slot, thereby
        // keeping the same 'Lnull;' type originally assigned to that slot (it doesn't make sense to do a CHECKCAST because 'null' is
        // not a real class and can never be a real class -- null is a reserved word in Java).
        if (type.getSort() == Type.OBJECT && "Lnull;".equals(type.getDescriptor())) {
            ret.add(new InsnNode(Opcodes.ACONST_NULL));
            ret.add(new VarInsnNode(Opcodes.ASTORE, i));
            continue;
        }

        // Load item from locals storage array
        ret.add(new VarInsnNode(Opcodes.ALOAD, arrayLocalsVar.getIndex()));
        ret.add(new LdcInsnNode(i));
        ret.add(new InsnNode(Opcodes.AALOAD));

        // Convert the item from an object stores it in local vars table.
        switch (type.getSort()) {
        case Type.BOOLEAN:
            ret.add(new TypeInsnNode(Opcodes.CHECKCAST, "java/lang/Boolean"));
            ret.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL, "java/lang/Boolean", "booleanValue", "()Z",
                    false));
            ret.add(new VarInsnNode(Opcodes.ISTORE, i));
            break;
        case Type.BYTE:
            ret.add(new TypeInsnNode(Opcodes.CHECKCAST, "java/lang/Byte"));
            ret.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL, "java/lang/Byte", "byteValue", "()B", false));
            ret.add(new VarInsnNode(Opcodes.ISTORE, i));
            break;
        case Type.SHORT:
            ret.add(new TypeInsnNode(Opcodes.CHECKCAST, "java/lang/Short"));
            ret.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL, "java/lang/Short", "shortValue", "()S", false));
            ret.add(new VarInsnNode(Opcodes.ISTORE, i));
            break;
        case Type.CHAR:
            ret.add(new TypeInsnNode(Opcodes.CHECKCAST, "java/lang/Character"));
            ret.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL, "java/lang/Character", "charValue", "()C",
                    false));
            ret.add(new VarInsnNode(Opcodes.ISTORE, i));
            break;
        case Type.INT:
            ret.add(new TypeInsnNode(Opcodes.CHECKCAST, "java/lang/Integer"));
            ret.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL, "java/lang/Integer", "intValue", "()I", false));
            ret.add(new VarInsnNode(Opcodes.ISTORE, i));
            break;
        case Type.FLOAT:
            ret.add(new TypeInsnNode(Opcodes.CHECKCAST, "java/lang/Float"));
            ret.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL, "java/lang/Float", "floatValue", "()F", false));
            ret.add(new VarInsnNode(Opcodes.FSTORE, i));
            break;
        case Type.LONG:
            ret.add(new TypeInsnNode(Opcodes.CHECKCAST, "java/lang/Long"));
            ret.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL, "java/lang/Long", "longValue", "()J", false));
            ret.add(new VarInsnNode(Opcodes.LSTORE, i));
            break;
        case Type.DOUBLE:
            ret.add(new TypeInsnNode(Opcodes.CHECKCAST, "java/lang/Double"));
            ret.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL, "java/lang/Double", "doubleValue", "()D", false));
            ret.add(new VarInsnNode(Opcodes.DSTORE, i));
            break;
        case Type.ARRAY:
        case Type.OBJECT:
            ret.add(new TypeInsnNode(Opcodes.CHECKCAST, basicValue.getType().getInternalName()));
            ret.add(new VarInsnNode(Opcodes.ASTORE, i));
            break;
        case Type.METHOD:
        case Type.VOID:
        default:
            throw new IllegalStateException();
        }
    }

    return ret;
}

From source file:com.offbynull.coroutines.instrumenter.LocalsStateGenerators.java

License:Open Source License

/**
 * Generates instructions to load the local variables table.
 * @param markerType debug marker type/*ww w . j  av  a 2s .  co m*/
 * @param storageVars variables to load locals from
 * @param frame execution frame at the instruction for which the local variables table is to be restored
 * @return instructions to load the local variables table from an array
 * @throws NullPointerException if any argument is {@code null}
 */
public static InsnList loadLocals(MarkerType markerType, StorageVariables storageVars,
        Frame<BasicValue> frame) {
    Validate.notNull(markerType);
    Validate.notNull(storageVars);
    Validate.notNull(frame);

    Variable intsVar = storageVars.getIntStorageVar();
    Variable floatsVar = storageVars.getFloatStorageVar();
    Variable longsVar = storageVars.getLongStorageVar();
    Variable doublesVar = storageVars.getDoubleStorageVar();
    Variable objectsVar = storageVars.getObjectStorageVar();

    int intsCounter = 0;
    int floatsCounter = 0;
    int longsCounter = 0;
    int doublesCounter = 0;
    int objectsCounter = 0;

    InsnList ret = new InsnList();

    // Load the locals
    ret.add(debugMarker(markerType, "Loading locals"));
    for (int i = 0; i < frame.getLocals(); i++) {
        BasicValue basicValue = frame.getLocal(i);
        Type type = basicValue.getType();

        // If type == null, basicValue is pointing to uninitialized var -- basicValue.toString() will return ".". This means that this
        // slot contains nothing to load. So, skip this slot if we encounter it (such that it will remain uninitialized).
        if (type == null) {
            ret.add(debugMarker(markerType, "Skipping uninitialized value at " + i));
            continue;
        }

        // If type is 'Lnull;', this means that the slot has been assigned null and that "there has been no merge yet that would 'raise'
        // the type toward some class or interface type" (from ASM mailing list). We know this slot will always contain null at this
        // point in the code so there's no specific value to load up from the array. Instead we push a null in to that slot, thereby
        // keeping the same 'Lnull;' type originally assigned to that slot (it doesn't make sense to do a CHECKCAST because 'null' is
        // not a real class and can never be a real class -- null is a reserved word in Java).
        if (type.getSort() == Type.OBJECT && "Lnull;".equals(type.getDescriptor())) {
            ret.add(debugMarker(markerType, "Putting null value at " + i));
            ret.add(new InsnNode(Opcodes.ACONST_NULL));
            ret.add(new VarInsnNode(Opcodes.ASTORE, i));
            continue;
        }

        // Load the locals
        switch (type.getSort()) {
        case Type.BOOLEAN:
        case Type.BYTE:
        case Type.SHORT:
        case Type.CHAR:
        case Type.INT:
            ret.add(debugMarker(markerType,
                    "Loading int to LVT index " + i + " from storage index " + intsCounter));
            ret.add(new VarInsnNode(Opcodes.ALOAD, intsVar.getIndex())); // [int[]]
            ret.add(new LdcInsnNode(intsCounter)); // [int[], idx]
            ret.add(new InsnNode(Opcodes.IALOAD)); // [val]
            ret.add(new VarInsnNode(Opcodes.ISTORE, i)); // []
            intsCounter++;
            break;
        case Type.FLOAT:
            ret.add(debugMarker(markerType,
                    "Loading float to LVT index " + i + " from storage index " + floatsCounter));
            ret.add(new VarInsnNode(Opcodes.ALOAD, floatsVar.getIndex())); // [float[]]
            ret.add(new LdcInsnNode(floatsCounter)); // [float[], idx]
            ret.add(new InsnNode(Opcodes.FALOAD)); // [val]
            ret.add(new VarInsnNode(Opcodes.FSTORE, i)); // []
            floatsCounter++;
            break;
        case Type.LONG:
            ret.add(debugMarker(markerType,
                    "Loading long to LVT index " + i + " from storage index " + longsCounter));
            ret.add(new VarInsnNode(Opcodes.ALOAD, longsVar.getIndex())); // [long[]]
            ret.add(new LdcInsnNode(longsCounter)); // [long[], idx]
            ret.add(new InsnNode(Opcodes.LALOAD)); // [val_PART1, val_PART2]
            ret.add(new VarInsnNode(Opcodes.LSTORE, i)); // []
            longsCounter++;
            break;
        case Type.DOUBLE:
            ret.add(debugMarker(markerType,
                    "Loading double to LVT index " + i + " from storage index " + doublesCounter));
            ret.add(new VarInsnNode(Opcodes.ALOAD, doublesVar.getIndex())); // [double[]]
            ret.add(new LdcInsnNode(doublesCounter)); // [double[], idx]
            ret.add(new InsnNode(Opcodes.DALOAD)); // [val_PART1, val_PART2]
            ret.add(new VarInsnNode(Opcodes.DSTORE, i)); // []
            doublesCounter++;
            break;
        case Type.ARRAY:
        case Type.OBJECT:
            ret.add(debugMarker(markerType,
                    "Loading object to LVT index " + i + " from storage index " + objectsCounter));
            ret.add(new VarInsnNode(Opcodes.ALOAD, objectsVar.getIndex())); // [Object[]]
            ret.add(new LdcInsnNode(objectsCounter)); // [Object[], idx]
            ret.add(new InsnNode(Opcodes.AALOAD)); // [val]
            // must cast, otherwise the jvm won't know the type that's in the localvariable slot and it'll fail when the code tries
            // to access a method/field on it
            ret.add(new TypeInsnNode(Opcodes.CHECKCAST, basicValue.getType().getInternalName()));
            ret.add(new VarInsnNode(Opcodes.ASTORE, i)); // []
            objectsCounter++;
            break;
        case Type.METHOD:
        case Type.VOID:
        default:
            throw new IllegalStateException();
        }
    }

    return ret;
}

From source file:com.sun.fortress.compiler.asmbytecodeoptimizer.DefUseChains.java

License:Open Source License

private static void removeUnboxedValueInsns(AbstractInterpretationValue val, ByteCodeMethodVisitor bcmv) {
    for (Insn i : val.getDefs())
        removeInsn(bcmv, i, val, "RemovingBoxedValueDefinition");

    for (Insn i : val.getUses()) {
        if (i.isBoxingMethod()) {
            removeInsn(bcmv, i, val, "RemoveBoxingMethod");
        } else if (i.isUnBoxingMethod()) {
            removeInsn(bcmv, i, val, "UnboxingMethod");
        } else if (i.isCheckCast()) {
            removeInsn(bcmv, i, val, "CheckCast"); // FIXME CHF
        } else if (i instanceof VarInsn) {
            VarInsn vi = (VarInsn) i;/*w  ww .  j a  va2s  .c  om*/
            if (vi.opcode == Opcodes.ASTORE) {
                int j = bcmv.insns.indexOf(i);
                removeInsn(bcmv, i, val, "astoreconversion" + val.getType());
                if (val.getType().equals("Lcom/sun/fortress/compiler/runtimeValues/FZZ32;"))
                    bcmv.insns.add(j, new VarInsn("ISTORE", Opcodes.ISTORE, val.getValueNumber(), vi.index));
                else if (val.getType().equals("Lcom/sun/fortress/compiler/runtimeValues/FZZ64;"))
                    bcmv.insns.add(j, new VarInsn("LSTORE", Opcodes.LSTORE, val.getValueNumber(), vi.index));
                else if (val.getType().equals("Lcom/sun/fortress/compiler/runtimeValues/FRR32;"))
                    bcmv.insns.add(j, new VarInsn("FSTORE", Opcodes.FSTORE, val.getValueNumber(), vi.index));
                else if (val.getType().equals("Lcom/sun/fortress/compiler/runtimeValues/FRR64;"))
                    bcmv.insns.add(j, new VarInsn("DSTORE", Opcodes.DSTORE, val.getValueNumber(), vi.index));
                else if (val.getType().equals("Lcom/sun/fortress/compiler/runtimeValues/FBoolean;"))
                    bcmv.insns.add(j, new VarInsn("ISTORE", Opcodes.ISTORE, val.getValueNumber(), vi.index));
                else
                    bcmv.insns.add(j, new VarInsn("ASTORE", Opcodes.ASTORE, val.getValueNumber(), vi.index));
            } else if (vi.opcode == Opcodes.ALOAD) {
                int j = bcmv.insns.indexOf(i);
                removeInsn(bcmv, i, val, "Aloadconversion" + val.getType());
                if (val.getType().equals("Lcom/sun/fortress/compiler/runtimeValues/FZZ32;"))
                    bcmv.insns.add(j, new VarInsn("ILOAD", Opcodes.ILOAD, val.getValueNumber(), vi.index));
                else if (val.getType().equals("Lcom/sun/fortress/compiler/runtimeValues/FZZ64;"))
                    bcmv.insns.add(j, new VarInsn("LLOAD", Opcodes.LLOAD, val.getValueNumber(), vi.index));
                else if (val.getType().equals("Lcom/sun/fortress/compiler/runtimeValues/FRR32;"))
                    bcmv.insns.add(j, new VarInsn("FLOAD", Opcodes.FLOAD, val.getValueNumber(), vi.index));
                else if (val.getType().equals("Lcom/sun/fortress/compiler/runtimeValues/FRR64;"))
                    bcmv.insns.add(j, new VarInsn("DLOAD", Opcodes.DLOAD, val.getValueNumber(), vi.index));
                else if (val.getType().equals("Lcom/sun/fortress/compiler/runtimeValues/FBoolean;"))
                    bcmv.insns.add(j, new VarInsn("ILOAD", Opcodes.ILOAD, val.getValueNumber(), vi.index));
                else
                    bcmv.insns.add(j, new VarInsn("ALOAD", Opcodes.ALOAD, val.getValueNumber(), vi.index));
            }
        } else if (i instanceof SingleInsn) {
            SingleInsn si = (SingleInsn) i;
            if (si.opcode == Opcodes.ARETURN) {
                int j = bcmv.insns.indexOf(i);
                if (val.getType().equals("Lcom/sun/fortress/compiler/runtimeValues/FZZ32;"))
                    bcmv.insns.add(j, new MethodInsn("INVOKESTATIC", Opcodes.INVOKESTATIC,
                            "com/sun/fortress/compiler/runtimeValues/FZZ32", "make",
                            "(I)Lcom/sun/fortress/compiler/runtimeValues/FZZ32;", "ReboxingReturnValue"));
                else if (val.getType().equals("Lcom/sun/fortress/compiler/runtimeValues/FZZ64;"))
                    bcmv.insns.add(j, new MethodInsn("INVOKESTATIC", Opcodes.INVOKESTATIC,
                            "com/sun/fortress/compiler/runtimeValues/FZZ64", "make",
                            "(J)Lcom/sun/fortress/compiler/runtimeValues/FZZ64;", "ReboxingReturnValue"));
                else if (val.getType().equals("Lcom/sun/fortress/compiler/runtimeValues/FRR32;"))
                    bcmv.insns.add(j, new MethodInsn("INVOKESTATIC", Opcodes.INVOKESTATIC,
                            "com/sun/fortress/compiler/runtimeValues/FRR32", "make",
                            "(F)Lcom/sun/fortress/compiler/runtimeValues/FRR32;", "ReboxingReturnValue"));
                else if (val.getType().equals("Lcom/sun/fortress/compiler/runtimeValues/FRR64;"))
                    bcmv.insns.add(j, new MethodInsn("INVOKESTATIC", Opcodes.INVOKESTATIC,
                            "com/sun/fortress/compiler/runtimeValues/FRR64", "make",
                            "(D)Lcom/sun/fortress/compiler/runtimeValues/FRR64;", "ReboxingReturnValue"));
                else if (val.getType().equals("Lcom/sun/fortress/compiler/runtimeValues/FVoid;"))
                    bcmv.insns.add(j, new MethodInsn("INVOKESTATIC", Opcodes.INVOKESTATIC,
                            "com/sun/fortress/compiler/runtimeValues/FVoid", "make",
                            "()Lcom/sun/fortress/compiler/runtimeValues/FVoid;", "ReboxingReturnValue"));
                else if (val.getType().equals("Lcom/sun/fortress/compiler/runtimeValues/FBoolean;"))
                    bcmv.insns.add(j, new MethodInsn("INVOKESTATIC", Opcodes.INVOKESTATIC,
                            "com/sun/fortress/compiler/runtimeValues/FBoolean", "make",
                            "(Z)Lcom/sun/fortress/compiler/runtimeValues/FBoolean;", "ReboxingReturnValue"));
                else if (val.getType().equals("Lcom/sun/fortress/compiler/runtimeValues/FJavaString;"))
                    bcmv.insns.add(j,
                            new MethodInsn("INVOKESTATIC", Opcodes.INVOKESTATIC,
                                    "com/sun/fortress/compiler/runtimeValues/FJavaString", "make",
                                    "(java.lang.String)Lcom/sun/fortress/compiler/runtimeValues/FJavaString;",
                                    "ReboxingReturnValue"));
                else
                    throw new RuntimeException("Don't recognize var type " + val.getType());
            }
        }
    }
}

From source file:com.sun.fortress.compiler.asmbytecodeoptimizer.Inlining.java

License:Open Source License

public static List<Insn> convertInsns(MethodInsn mi, List<Insn> insns, int[] args, int _index, Label end) {
    List<Insn> result = new ArrayList<Insn>();
    HashMap labels = new HashMap();
    int index = _index;
    for (Insn i : insns) {
        if (i.isExpanded()) {
            MethodInsn expanded = (MethodInsn) i;
            // This use of end should be OK because all returns should have been removed when inlined before.
            // What could go wrong?
            result.addAll(convertInsns(expanded, expanded.inlineExpansionInsns, args, _index, end));
        } else if (i instanceof SingleInsn) {
            SingleInsn si = (SingleInsn) i;
            switch (si.opcode) {
            case Opcodes.IRETURN:
            case Opcodes.LRETURN:
            case Opcodes.FRETURN:
            case Opcodes.DRETURN:
            case Opcodes.ARETURN:
            case Opcodes.RETURN:
                result.add(new JumpInsn("RETURN->GOTO", Opcodes.GOTO, end, newIndex(mi, index++)));
                break;
            default:
                result.add(i.copy(newIndex(mi, index++)));
            }/* w ww .ja  va  2s . c  o  m*/
        } else if (i instanceof VarInsn) {
            VarInsn vi = (VarInsn) i;
            switch (vi.opcode) {
            case Opcodes.ILOAD:
            case Opcodes.LLOAD:
            case Opcodes.FLOAD:
            case Opcodes.DLOAD:
            case Opcodes.ALOAD:
            case Opcodes.ISTORE:
            case Opcodes.LSTORE:
            case Opcodes.FSTORE:
            case Opcodes.DSTORE:
            case Opcodes.ASTORE:
                VarInsn newVarInsn = new VarInsn(vi.name, vi.opcode, args[vi.var], newIndex(mi, index++));
                result.add(newVarInsn);
                break;
            default:
                result.add(i.copy(newIndex(mi, index++)));
            }
        } else if (i instanceof VisitMaxs) {
        } else if (i instanceof VisitEnd) {
        } else if (i instanceof VisitCode) {
        } else if (i instanceof VisitFrame) {
        } else if (i instanceof LabelInsn) {
            LabelInsn li = (LabelInsn) i;
            if (labels.containsKey(li.label))
                result.add(new LabelInsn(li.name, (Label) labels.get(li.label), newIndex(mi, index++)));
            else {
                Label l = new Label();
                labels.put(li.label, l);
                result.add(new LabelInsn(li.name, l, newIndex(mi, index++)));
            }
        } else if (i instanceof JumpInsn) {
            JumpInsn ji = (JumpInsn) i;
            if (labels.containsKey(ji.label))
                result.add(
                        new JumpInsn(ji.name, ji.opcode, (Label) labels.get(ji.label), newIndex(mi, index++)));
            else {
                Label l = new Label();
                labels.put(ji.label, l);
                result.add(new JumpInsn(ji.name, ji.opcode, l, newIndex(mi, index++)));
            }
        } else if (i instanceof VisitLineNumberInsn) {
            VisitLineNumberInsn vlni = (VisitLineNumberInsn) i;
            if (labels.containsKey(vlni.start))
                result.add(new VisitLineNumberInsn(vlni.name, vlni.line, (Label) labels.get(vlni.start),
                        newIndex(mi, index++)));
            else {
                Label l = new Label();
                labels.put(vlni.start, l);
                result.add(new VisitLineNumberInsn(vlni.name, vlni.line, l, newIndex(mi, index++)));
            }
        } else if (i instanceof LocalVariableInsn) {
            LocalVariableInsn lvi = (LocalVariableInsn) i;
            if (labels.containsKey(lvi.start) && labels.containsKey(lvi.end)) {
                result.add(new LocalVariableInsn(lvi.name, lvi._name, lvi.desc, lvi.sig,
                        (Label) labels.get(lvi.start), (Label) labels.get(lvi.end), args[lvi._index],
                        newIndex(mi, index++)));
            } else
                throw new RuntimeException("NYI");
        } else if (i instanceof TryCatchBlock) {
            TryCatchBlock tcb = (TryCatchBlock) i;
            if (labels.containsKey(tcb.start) && labels.containsKey(tcb.end)
                    && labels.containsKey(tcb.handler)) {
                result.add(
                        new TryCatchBlock(tcb.name, (Label) labels.get(tcb.start), (Label) labels.get(tcb.end),
                                (Label) labels.get(tcb.handler), tcb.type, newIndex(mi, index++)));
            } else if (!labels.containsKey(tcb.start) && !labels.containsKey(tcb.end)
                    && !labels.containsKey(tcb.handler)) {
                Label s = new Label();
                Label e = new Label();
                Label h = new Label();
                labels.put(tcb.start, s);
                labels.put(tcb.end, e);
                labels.put(tcb.handler, h);
                result.add(new TryCatchBlock(tcb.name, s, e, h, tcb.type, newIndex(mi, index++)));
            } else
                throw new RuntimeException("NYI");
            // Need to add TableSwitch, LookupSwitch
        } else {
            result.add(i.copy(newIndex(mi, index++)));
        }
    }
    return result;
}

From source file:com.trigersoft.jaque.expression.ExpressionMethodVisitor.java

License:Apache License

@Override
public void visitVarInsn(int opcode, int var) {
    if (_me != null) {
        if (var == 0) {
            _exprStack.push(_me);//  w  ww .  j  ava  2  s  .co  m
            return;
        }
        var--;
    }
    Class<?> type;
    switch (opcode) {
    case Opcodes.ISTORE:
    case Opcodes.LSTORE:
    case Opcodes.FSTORE:
    case Opcodes.DSTORE:
    case Opcodes.ASTORE:
    case Opcodes.RET:
    default:
        throw notLambda(opcode);
    case Opcodes.ILOAD:
        type = Integer.TYPE;
        break;
    case Opcodes.LLOAD:
        type = Long.TYPE;
        break;
    case Opcodes.FLOAD:
        type = Float.TYPE;
        break;
    case Opcodes.DLOAD:
        type = Double.TYPE;
        break;
    case Opcodes.ALOAD:
        type = _argTypes[var];
        break;
    }

    _exprStack.push(Expression.parameter(type, var));
}

From source file:de.tuberlin.uebb.jbop.optimizer.methodsplitter.Block.java

License:Open Source License

private Type getTypeIfSimpleType(final AbstractInsnNode node) {
    final int opcode = node.getOpcode();
    if ((opcode == Opcodes.ILOAD) || (opcode == Opcodes.ISTORE) || (opcode == Opcodes.IRETURN)) {
        return Type.INT_TYPE;
    }//from  ww w.  j av  a  2  s .c o  m
    if ((opcode == Opcodes.FLOAD) || (opcode == Opcodes.FSTORE) || (opcode == Opcodes.FRETURN)) {
        return Type.FLOAT_TYPE;
    }
    if ((opcode == Opcodes.LLOAD) || (opcode == Opcodes.LSTORE) || (opcode == Opcodes.LRETURN)) {
        return Type.LONG_TYPE;
    }
    if ((opcode == Opcodes.DLOAD) || (opcode == Opcodes.DSTORE) || (opcode == Opcodes.DRETURN)) {
        return Type.DOUBLE_TYPE;
    }
    return null;
}

From source file:de.unisb.cs.st.javaslicer.common.classRepresentation.instructions.VarInstruction.java

License:Open Source License

public VarInstruction(final ReadMethod readMethod, final int opcode, final int lineNumber,
        final int localVarIndex) {
    super(readMethod, opcode, lineNumber);
    assert opcode == Opcodes.ILOAD || opcode == Opcodes.LLOAD || opcode == Opcodes.FLOAD
            || opcode == Opcodes.DLOAD || opcode == Opcodes.ALOAD || opcode == Opcodes.ISTORE
            || opcode == Opcodes.LSTORE || opcode == Opcodes.FSTORE || opcode == Opcodes.DSTORE
            || opcode == Opcodes.ASTORE || opcode == Opcodes.RET;
    this.localVarIndex = localVarIndex;
}

From source file:de.unisb.cs.st.javaslicer.common.classRepresentation.instructions.VarInstruction.java

License:Open Source License

private VarInstruction(final ReadMethod readMethod, final int lineNumber, final int opcode,
        final int localVarIndex, final int index) {
    super(readMethod, opcode, lineNumber, index);
    assert opcode == Opcodes.ILOAD || opcode == Opcodes.LLOAD || opcode == Opcodes.FLOAD
            || opcode == Opcodes.DLOAD || opcode == Opcodes.ALOAD || opcode == Opcodes.ISTORE
            || opcode == Opcodes.LSTORE || opcode == Opcodes.FSTORE || opcode == Opcodes.DSTORE
            || opcode == Opcodes.ASTORE || opcode == Opcodes.RET;
    this.localVarIndex = localVarIndex;
}