本文整理汇总了Java中org.objectweb.asm.tree.InsnNode.getOpcode方法的典型用法代码示例。如果您正苦于以下问题:Java InsnNode.getOpcode方法的具体用法?Java InsnNode.getOpcode怎么用?Java InsnNode.getOpcode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.objectweb.asm.tree.InsnNode
的用法示例。
在下文中一共展示了InsnNode.getOpcode方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: convertArrayLoadInsn
import org.objectweb.asm.tree.InsnNode; //导入方法依赖的package包/类
private void convertArrayLoadInsn(InsnNode insn) {
StackFrame frame = getFrame(insn);
Operand[] out = frame.out();
Operand opr;
if (out == null) {
Operand indx = popImmediate();
Operand base = popImmediate();
ArrayRef ar = Jimple.v().newArrayRef(
base.stackOrValue(), indx.stackOrValue());
indx.addBox(ar.getIndexBox());
base.addBox(ar.getBaseBox());
opr = new Operand(insn, ar);
frame.in(indx, base);
frame.boxes(ar.getIndexBox(), ar.getBaseBox());
frame.out(opr);
} else {
opr = out[0];
frame.mergeIn(pop(), pop());
}
int op = insn.getOpcode();
if (op == DALOAD || op == LALOAD)
pushDual(opr);
else
push(opr);
}
示例2: convertArrayStoreInsn
import org.objectweb.asm.tree.InsnNode; //导入方法依赖的package包/类
private void convertArrayStoreInsn(InsnNode insn) {
int op = insn.getOpcode();
boolean dword = op == LASTORE || op == DASTORE;
StackFrame frame = getFrame(insn);
if (!units.containsKey(insn)) {
Operand valu = dword ? popImmediateDual() : popImmediate();
Operand indx = popImmediate();
Operand base = popLocal();
ArrayRef ar = Jimple.v().newArrayRef(
base.stackOrValue(), indx.stackOrValue());
indx.addBox(ar.getIndexBox());
base.addBox(ar.getBaseBox());
AssignStmt as = Jimple.v().newAssignStmt(ar, valu.stackOrValue());
valu.addBox(as.getRightOpBox());
frame.in(valu, indx, base);
frame.boxes(as.getRightOpBox(),
ar.getIndexBox(), ar.getBaseBox());
setUnit(insn, as);
} else {
frame.mergeIn(dword ? popDual() : pop(), pop(), pop());
}
}
示例3: transformInsnNode
import org.objectweb.asm.tree.InsnNode; //导入方法依赖的package包/类
@Override
protected AbstractInsnNode transformInsnNode(MethodNode mn, InsnNode insnNode) {
//String desc = DescriptorMapping.getInstance().getMethodDesc(className, mn.name, mn.desc);
Type returnType = Type.getReturnType(mn.desc);
if (!returnType.equals(Type.BOOLEAN_TYPE)) {
return insnNode;
}
if (insnNode.getOpcode() == Opcodes.IRETURN) {
BooleanTestabilityTransformation.logger.debug("Inserting conversion before IRETURN of " + this.booleanTestabilityTransformation.className + "."
+ mn.name);
// If this function cannot be transformed, add a call to convert the value to a proper Boolean
MethodInsnNode n = new MethodInsnNode(Opcodes.INVOKESTATIC,
Type.getInternalName(BooleanHelper.class), "intToBoolean",
Type.getMethodDescriptor(Type.BOOLEAN_TYPE,
new Type[] { Type.INT_TYPE }));
mn.instructions.insertBefore(insnNode, n);
}
return insnNode;
}
示例4: transformInsnNode
import org.objectweb.asm.tree.InsnNode; //导入方法依赖的package包/类
@Override
protected AbstractInsnNode transformInsnNode(MethodNode mn, InsnNode insnNode) {
BooleanTestabilityTransformation.logger.info("Checking transformation of InsnNode ");
if (insnNode.getOpcode() == Opcodes.ICONST_0
&& this.booleanTestabilityTransformation.isBooleanAssignment(insnNode, mn)) {
TransformationStatistics.insertedGet();
this.booleanTestabilityTransformation.insertGet(insnNode, mn.instructions);
} else if (insnNode.getOpcode() == Opcodes.ICONST_1
&& this.booleanTestabilityTransformation.isBooleanAssignment(insnNode, mn)) {
TransformationStatistics.insertedGet();
this.booleanTestabilityTransformation.insertGet(insnNode, mn.instructions);
//} else if (insnNode.getOpcode() == Opcodes.IRETURN
// && isBooleanAssignment(insnNode, mn)) {
// TransformationStatistics.insertedGet();
// insertGetBefore(insnNode, mn.instructions);
}
return insnNode;
}
示例5: convertConstInsn
import org.objectweb.asm.tree.InsnNode; //导入方法依赖的package包/类
private void convertConstInsn(InsnNode insn) {
int op = insn.getOpcode();
StackFrame frame = getFrame(insn);
Operand[] out = frame.out();
Operand opr;
if (out == null) {
Value v;
if (op == ACONST_NULL)
v = NullConstant.v();
else if (op >= ICONST_M1 && op <= ICONST_5)
v = IntConstant.v(op - ICONST_0);
else if (op == LCONST_0 || op == LCONST_1)
v = LongConstant.v(op - LCONST_0);
else if (op >= FCONST_0 && op <= FCONST_2)
v = FloatConstant.v(op - FCONST_0);
else if (op == DCONST_0 || op == DCONST_1)
v = DoubleConstant.v(op - DCONST_0);
else
throw new AssertionError("Unknown constant opcode: " + op);
opr = new Operand(insn, v);
frame.out(opr);
} else {
opr = out[0];
}
if (op == LCONST_0 || op == LCONST_1 ||
op == DCONST_0 || op == DCONST_1) {
pushDual(opr);
} else {
push(opr);
}
}
示例6: convertUnopInsn
import org.objectweb.asm.tree.InsnNode; //导入方法依赖的package包/类
private void convertUnopInsn(InsnNode insn) {
int op = insn.getOpcode();
boolean dword = op == LNEG || op == DNEG;
StackFrame frame = getFrame(insn);
Operand[] out = frame.out();
Operand opr;
if (out == null) {
Operand op1 = dword ? popImmediateDual() : popImmediate();
Value v1 = op1.stackOrValue();
UnopExpr unop;
if (op >= INEG && op <= DNEG)
unop = Jimple.v().newNegExpr(v1);
else if (op == ARRAYLENGTH)
unop = Jimple.v().newLengthExpr(v1);
else
throw new AssertionError("Unknown unop: " + op);
op1.addBox(unop.getOpBox());
opr = new Operand(insn, unop);
frame.in(op1);
frame.boxes(unop.getOpBox());
frame.out(opr);
} else {
opr = out[0];
frame.mergeIn(dword ? popDual() : pop());
}
if (dword)
pushDual(opr);
else
push(opr);
}
示例7: convertReturnInsn
import org.objectweb.asm.tree.InsnNode; //导入方法依赖的package包/类
private void convertReturnInsn(InsnNode insn) {
int op = insn.getOpcode();
boolean dword = op == LRETURN || op == DRETURN;
StackFrame frame = getFrame(insn);
if (!units.containsKey(insn)) {
Operand val = dword ? popImmediateDual() : popImmediate();
ReturnStmt ret = Jimple.v().newReturnStmt(val.stackOrValue());
val.addBox(ret.getOpBox());
frame.in(val);
frame.boxes(ret.getOpBox());
setUnit(insn, ret);
} else {
frame.mergeIn(dword ? popDual() : pop());
}
}
示例8: transformMethod
import org.objectweb.asm.tree.InsnNode; //导入方法依赖的package包/类
/**
* <p>transformMethod</p>
*
* @param mn a {@link org.objectweb.asm.tree.MethodNode} object.
*/
public void transformMethod(MethodNode mn) {
AbstractInsnNode node = mn.instructions.getFirst();
while (node != mn.instructions.getLast()) {
AbstractInsnNode next = node.getNext();
if (node instanceof InsnNode) {
InsnNode in = (InsnNode) node;
if (in.getOpcode() == Opcodes.LCMP) {
insertLongComparison(in, mn.instructions);
TransformationStatistics.transformedComparison();
} else if (in.getOpcode() == Opcodes.DCMPG) {
TransformationStatistics.transformedComparison();
insertDoubleComparisonG(in, mn.instructions);
} else if (in.getOpcode() == Opcodes.DCMPL) {
TransformationStatistics.transformedComparison();
insertDoubleComparisonL(in, mn.instructions);
} else if (in.getOpcode() == Opcodes.FCMPG) {
TransformationStatistics.transformedComparison();
insertFloatComparisonG(in, mn.instructions);
} else if (in.getOpcode() == Opcodes.FCMPL) {
TransformationStatistics.transformedComparison();
insertFloatComparisonL(in, mn.instructions);
}
}
node = next;
}
}
示例9: convertBinopInsn
import org.objectweb.asm.tree.InsnNode; //导入方法依赖的package包/类
private void convertBinopInsn(InsnNode insn) {
int op = insn.getOpcode();
boolean dword = op == DADD || op == LADD ||
op == DSUB || op == LSUB ||
op == DMUL || op == LMUL ||
op == DDIV || op == LDIV ||
op == DREM || op == LREM ||
op == LSHL || op == LSHR ||
op == LUSHR || op == LAND ||
op == LOR || op == LXOR ||
op == LCMP || op == DCMPL ||
op == DCMPG;
StackFrame frame = getFrame(insn);
Operand[] out = frame.out();
Operand opr;
if (out == null) {
Operand op2 = (dword && op != LSHL && op != LSHR && op != LUSHR) ?
popImmediateDual() : popImmediate();
Operand op1 = dword ? popImmediateDual() : popImmediate();
Value v1 = op1.stackOrValue();
Value v2 = op2.stackOrValue();
BinopExpr binop;
if (op >= IADD && op <= DADD)
binop = Jimple.v().newAddExpr(v1, v2);
else if (op >= ISUB && op <= DSUB)
binop = Jimple.v().newSubExpr(v1, v2);
else if (op >= IMUL && op <= DMUL)
binop = Jimple.v().newMulExpr(v1, v2);
else if (op >= IDIV && op <= DDIV)
binop = Jimple.v().newDivExpr(v1, v2);
else if (op >= IREM && op <= DREM)
binop = Jimple.v().newRemExpr(v1, v2);
else if (op >= ISHL && op <= LSHL)
binop = Jimple.v().newShlExpr(v1, v2);
else if (op >= ISHR && op <= LSHR)
binop = Jimple.v().newShrExpr(v1, v2);
else if (op >= IUSHR && op <= LUSHR)
binop = Jimple.v().newUshrExpr(v1, v2);
else if (op >= IAND && op <= LAND)
binop = Jimple.v().newAndExpr(v1, v2);
else if (op >= IOR && op <= LOR)
binop = Jimple.v().newOrExpr(v1, v2);
else if (op >= IXOR && op <= LXOR)
binop = Jimple.v().newXorExpr(v1, v2);
else if (op == LCMP)
binop = Jimple.v().newCmpExpr(v1, v2);
else if (op == FCMPL || op == DCMPL)
binop = Jimple.v().newCmplExpr(v1, v2);
else if (op == FCMPG || op == DCMPG)
binop = Jimple.v().newCmpgExpr(v1, v2);
else
throw new AssertionError("Unknown binop: " + op);
op1.addBox(binop.getOp1Box());
op2.addBox(binop.getOp2Box());
opr = new Operand(insn, binop);
frame.in(op2, op1);
frame.boxes(binop.getOp2Box(), binop.getOp1Box());
frame.out(opr);
} else {
opr = out[0];
if (dword) {
if (op != LSHL && op != LSHR && op != LUSHR)
frame.mergeIn(popDual(), popDual());
else
frame.mergeIn(pop(), popDual());
} else {
frame.mergeIn(pop(), pop());
}
}
if (dword && (op < LCMP || op > DCMPG))
pushDual(opr);
else
push(opr);
}
示例10: convertPrimCastInsn
import org.objectweb.asm.tree.InsnNode; //导入方法依赖的package包/类
private void convertPrimCastInsn(InsnNode insn) {
int op = insn.getOpcode();
boolean tod = op == I2L || op == I2D ||
op == F2L || op == F2D ||
op == D2L || op == L2D;
boolean fromd = op == D2L || op == L2D ||
op == D2I || op == L2I ||
op == D2F || op == L2F;
StackFrame frame = getFrame(insn);
Operand[] out = frame.out();
Operand opr;
if (out == null) {
Type totype;
if (op == I2L || op == F2L || op == D2L)
totype = LongType.v();
else if (op == L2I || op == F2I || op == D2I)
totype = IntType.v();
else if (op == I2F || op == L2F || op == D2F)
totype = FloatType.v();
else if (op == I2D || op == L2D || op == F2D)
totype = DoubleType.v();
else if (op == I2B)
totype = ByteType.v();
else if (op == I2S)
totype = ShortType.v();
else if (op == I2C)
totype = CharType.v();
else
throw new AssertionError("Unknonw prim cast op: " + op);
Operand val = fromd ? popImmediateDual() : popImmediate();
CastExpr cast = Jimple.v().newCastExpr(val.stackOrValue(), totype);
opr = new Operand(insn, cast);
val.addBox(cast.getOpBox());
frame.in(val);
frame.boxes(cast.getOpBox());
frame.out(opr);
} else {
opr = out[0];
frame.mergeIn(fromd ? popDual() : pop());
}
if (tod)
pushDual(opr);
else
push(opr);
}