public static <T extends AbstractInsnNode> Predicate<T> opcode(final int opcode) { return it -> it.getOpcode() == opcode; }
Object readCst(AbstractInsnNode q) { switch (q.getOpcode()) { case Opcodes.LDC: case Opcodes.ICONST_5: return q.getOpcode() - Opcodes.ICONST_0; case Opcodes.LCONST_0: case Opcodes.LCONST_1: return (long) (q.getOpcode() - Opcodes.LCONST_0); case Opcodes.FCONST_0: case Opcodes.FCONST_1: case Opcodes.FCONST_2: return (float) (q.getOpcode() - Opcodes.FCONST_0); case Opcodes.DCONST_0: case Opcodes.DCONST_1: return (double) (q.getOpcode() - Opcodes.DCONST_0); case Opcodes.ACONST_NULL: return null;
public boolean isGetCurrentTask() { AbstractInsnNode ain = getInstruction(startPos); if (ain.getOpcode() == INVOKESTATIC) { MethodInsnNode min = (MethodInsnNode)ain; return min.owner.equals(TASK_CLASS) && min.name.equals("getCurrentTask"); } return false; }
int lastInstruction() { AbstractInsnNode ainode = getInstruction(endPos); return ainode.getOpcode(); }
@Override public void execute(AbstractInsnNode insn, Interpreter<JvmValue> interpreter) throws AnalyzerException { if (insn.getType() == AbstractInsnNode.FRAME || insn.getType() == AbstractInsnNode.LINE || insn.getType() == AbstractInsnNode.LABEL) { return; } if (insn.getOpcode() == Opcodes.RETURN) { interpreter.returnOperation(insn, null, null); } else if (insn.getOpcode() == Opcodes.GOTO) { interpreter.unaryOperation(insn, null); } else if (insn.getOpcode() == RET) { throw new RuntimeException("not support yet!"); } else { super.execute(insn, interpreter); } } }
private int findMethodCall(InsnList insns, LabelNode label) { boolean foundLabel = false; for (int i = 0; i < insns.size(); i++) { AbstractInsnNode n = insns.get(i); if (!foundLabel && n == label) { foundLabel = true; } else if (foundLabel && n.getOpcode() == Opcodes.INVOKEDYNAMIC) { return i; } } return -1; }
static String getDescriptionForTypeInsnNode(TypeInsnNode typeInsnNode) { AbstractInsnNode nextInsn = typeInsnNode.getNext(); StringJoiner argsDesc = new StringJoiner(",", "(", ")"); while (nextInsn != null) { if (nextInsn instanceof LdcInsnNode) { argsDesc.add("_"); } else if (nextInsn.getOpcode() == Opcodes.DUP) { //ignore } else { break; } nextInsn = nextInsn.getNext(); } if (typeInsnNode.getOpcode() == Opcodes.NEW) { return "new " + Util.extractSimpleName(typeInsnNode.desc, "/") + argsDesc.toString(); } return ""; } }
if (p.getOpcode() == Opcodes.INVOKESTATIC) { MethodInsnNode mn = (MethodInsnNode) p; key.owner = mn.owner;
void changeJSR_RET_toGOTOs() throws KilimException { int lastInsn = getInstruction(endPos).getOpcode(); if (lastInsn == JSR) { BasicBlock targetBB = successors.get(0); if (!targetBB.hasFlag(PAUSABLE_SUB)) return; changeLastInsnToGOTO(targetBB.startLabel); successors.clear(); successors.add(targetBB); // change the first ASTORE instruction in targetBB to a NOP assert targetBB.getInstruction(targetBB.startPos).getOpcode() == ASTORE; targetBB.setInstruction(targetBB.startPos, new NopInsn()); targetBB.unsetFlag(IS_SUBROUTINE); } else if (lastInsn == RET && hasFlag(PAUSABLE_SUB)) { changeLastInsnToGOTO(successors.get(0).startLabel); } }
values[i] = getLocal(xvalues.get(i)); if (insn.getOpcode() == MULTIANEWARRAY) { throw new UnsupportedOperationException("Not supported yet."); } else { String owner = "L" + mi.owner + ";"; String ps[] = toDescArray(Type.getArgumentTypes(mi.desc)); switch (insn.getOpcode()) { case INVOKEVIRTUAL: v = Exprs.nInvokeVirtual(values, owner, mi.name, ps, ret);
void setUnit(AbstractInsnNode insn, Unit u) { if (Options.v().keep_line_number() && lastLineNumber >= 0) { Tag lineTag = u.getTag("LineNumberTag"); if (lineTag == null) { lineTag = new LineNumberTag(lastLineNumber); u.addTag(lineTag); } else if (((LineNumberTag) lineTag).getLineNumber() != lastLineNumber) { throw new RuntimeException("Line tag mismatch"); } } Unit o = units.put(insn, u); if (o != null) { throw new AssertionError(insn.getOpcode() + " already has a unit, " + o); } }
AbstractInsnNode node = insns[i]; switch (node.getOpcode()) { case Opcodes.ALOAD: VarInsnNode vnode = (VarInsnNode) node;
if (p.getOpcode() == Opcodes.INVOKESTATIC) { MethodInsnNode mn = (MethodInsnNode) p; key.owner = mn.owner;
@Override public void returnOperation(AbstractInsnNode insn, JvmValue value, JvmValue expected) throws AnalyzerException { switch (insn.getOpcode()) { case IRETURN: case LRETURN: case FRETURN: case DRETURN: case ARETURN: emit(Stmts.nReturn(getLocal(value))); break; case RETURN: emit(Stmts.nReturnVoid()); break; } } };
@Override public JvmValue newOperation(AbstractInsnNode insn) throws AnalyzerException { switch (insn.getOpcode()) { case ACONST_NULL: return b(1, Exprs.nNull()); case ICONST_4: case ICONST_5: return b(1, Exprs.nInt(insn.getOpcode() - ICONST_0)); case LCONST_0: case LCONST_1: return b(2, Exprs.nLong(insn.getOpcode() - LCONST_0)); case FCONST_0: case FCONST_1: case FCONST_2: return b(1, Exprs.nFloat(insn.getOpcode() - FCONST_0)); case DCONST_0: case DCONST_1: return b(2, Exprs.nDouble(insn.getOpcode() - DCONST_0)); case BIPUSH: case SIPUSH:
AbstractInsnNode node = instructions.next(); switch (node.getOpcode()) { case Opcodes.NEW: TypeInsnNode newInsnNode = (TypeInsnNode) node;
tmp.execute(p, interpreter); int op = p.getOpcode(); if (p.getType() == AbstractInsnNode.JUMP_INSN) { JumpInsnNode jump = (JumpInsnNode) p;
int op = opr.insn.getOpcode(); if (l == null && op != GETFIELD && op != GETSTATIC && (op < IALOAD && op > SALOAD)) { continue;
parentCount[insnList.indexOf(jump.label)]++; int op = p.getOpcode(); if (op == Opcodes.TABLESWITCH || op == Opcodes.LOOKUPSWITCH) { if (op == Opcodes.TABLESWITCH) {
Local local2 = getLocal(value2); Local local3 = getLocal(value3); switch (insn.getOpcode()) { case IASTORE: emit(Stmts.nAssign(Exprs.nArray(local1, local2, "I"),