本文整理汇总了Java中org.objectweb.asm.tree.AbstractInsnNode.getOpcode方法的典型用法代码示例。如果您正苦于以下问题:Java AbstractInsnNode.getOpcode方法的具体用法?Java AbstractInsnNode.getOpcode怎么用?Java AbstractInsnNode.getOpcode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.objectweb.asm.tree.AbstractInsnNode
的用法示例。
在下文中一共展示了AbstractInsnNode.getOpcode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: newOperation
import org.objectweb.asm.tree.AbstractInsnNode; //导入方法依赖的package包/类
@Override
public SourceValue newOperation(final AbstractInsnNode insn) {
int size;
switch (insn.getOpcode()) {
case LCONST_0:
case LCONST_1:
case DCONST_0:
case DCONST_1:
size = 2;
break;
case LDC:
Object cst = ((LdcInsnNode) insn).cst;
size = cst instanceof Long || cst instanceof Double ? 2 : 1;
break;
case GETSTATIC:
size = Type.getType(((FieldInsnNode) insn).desc).getSize();
break;
default:
size = 1;
}
return new SourceValue(size, insn);
}
示例2: getMethodTransformers
import org.objectweb.asm.tree.AbstractInsnNode; //导入方法依赖的package包/类
@Override
public MethodTransformer[] getMethodTransformers() {
MethodTransformer transformRenderParticle = new MethodTransformer() {
@Override
public MethodName getName() {
return Names.Particle_renderParticle;
}
@Override
public void transform(ClassNode classNode, MethodNode method, boolean obfuscated) {
CLTLog.info("Found method: " + method.name + " " + method.desc);
for (AbstractInsnNode instruction : method.instructions.toArray()) {
if (instruction.getOpcode() == ANEWARRAY) {
CLTLog.info("Found ANEWARRAY in method " + getName().all());
instruction = instruction.getPrevious();
transformParticle(classNode, method, instruction, 14);
break;
}
}
}
};
return new MethodTransformer[] {transformRenderParticle};
}
示例3: isSimpleConstant
import org.objectweb.asm.tree.AbstractInsnNode; //导入方法依赖的package包/类
private static boolean isSimpleConstant(Object previousInstructionObject) {
// CHECKSTYLE:OFF
final AbstractInsnNode previousInstruction = (AbstractInsnNode) previousInstructionObject;
// CHECKSTYLE:ON
final int opcode = previousInstruction.getOpcode();
return (opcode >= Opcodes.ACONST_NULL && opcode <= Opcodes.DCONST_1
|| opcode == Opcodes.SIPUSH || opcode == Opcodes.BIPUSH)
&& (previousInstruction instanceof InsnNode
|| previousInstruction instanceof IntInsnNode);
}
示例4: analyzeConstantInstruction
import org.objectweb.asm.tree.AbstractInsnNode; //导入方法依赖的package包/类
private void analyzeConstantInstruction(Object instructionObject) {
// CHECKSTYLE:OFF
final AbstractInsnNode instruction = (AbstractInsnNode) instructionObject;
// CHECKSTYLE:ON
if (instruction.getOpcode() == Opcodes.LDC) {
// une instruction d'opcode LDC est forcément de type LdcInsnNode
final VarInsnNode varInstruction = varInstructionsByConstantesMap
.get(((LdcInsnNode) instruction).cst);
// varInstruction peut être null si cette constante n'est pas dans une variable
if (varInstruction != null) {
removeLocalVariable(varInstruction);
}
}
}
示例5: overclockRenderer
import org.objectweb.asm.tree.AbstractInsnNode; //导入方法依赖的package包/类
private static void overclockRenderer(ClassNode node, boolean isObfuscated)
{
// We're attempting to turn this line from Minecraft.runGameLoop:
// this.updateDisplay();
// into this:
// TimeHelper.updateDisplay();
// TimeHelper's method then decides whether or not to pass the call on to Minecraft.updateDisplay().
final String methodName = isObfuscated ? "as" : "runGameLoop";
final String methodDescriptor = "()V"; // No params, returns void.
System.out.println("MALMO: Found Minecraft, attempting to transform it");
for (MethodNode method : node.methods)
{
if (method.name.equals(methodName) && method.desc.equals(methodDescriptor))
{
System.out.println("MALMO: Found Minecraft.runGameLoop() method, attempting to transform it");
for (AbstractInsnNode instruction : method.instructions.toArray())
{
if (instruction.getOpcode() == Opcodes.INVOKEVIRTUAL)
{
MethodInsnNode visitMethodNode = (MethodInsnNode)instruction;
if (visitMethodNode.name.equals(isObfuscated ? "h" : "updateDisplay"))
{
visitMethodNode.owner = "com/microsoft/Malmo/Utils/TimeHelper";
if (isObfuscated)
{
visitMethodNode.name = "updateDisplay";
}
visitMethodNode.setOpcode(Opcodes.INVOKESTATIC);
method.instructions.remove(visitMethodNode.getPrevious()); // ALOAD 0 not needed for static invocation.
System.out.println("MALMO: Hooked into call to Minecraft.updateDisplay()");
}
}
}
}
}
}
示例6: unaryOperation
import org.objectweb.asm.tree.AbstractInsnNode; //导入方法依赖的package包/类
@Override
public BasicValue unaryOperation(AbstractInsnNode insnNode, BasicValue value) throws AnalyzerException {
if (insnNode.getOpcode() == Opcodes.ANEWARRAY && value instanceof IntegerConstantBasicValue) {
IntegerConstantBasicValue constantBasicValue = (IntegerConstantBasicValue) value;
String desc = ((TypeInsnNode) insnNode).desc;
return new ArraySizeBasicValue(Type.getType("[" + Type.getObjectType(desc)), constantBasicValue.minValue,
constantBasicValue.maxValue);
}
return super.unaryOperation(insnNode, value);
}
示例7: naryOperation
import org.objectweb.asm.tree.AbstractInsnNode; //导入方法依赖的package包/类
@Override
public SourceValue naryOperation(final AbstractInsnNode insn,
final List<? extends SourceValue> values) {
int size;
int opcode = insn.getOpcode();
if (opcode == MULTIANEWARRAY) {
size = 1;
} else {
String desc = (opcode == INVOKEDYNAMIC) ? ((InvokeDynamicInsnNode) insn).desc
: ((MethodInsnNode) insn).desc;
size = Type.getReturnType(desc).getSize();
}
return new SourceValue(size, insn);
}
示例8: binaryOperation
import org.objectweb.asm.tree.AbstractInsnNode; //导入方法依赖的package包/类
@Override
public SourceValue binaryOperation(final AbstractInsnNode insn,
final SourceValue value1, final SourceValue value2) {
int size;
switch (insn.getOpcode()) {
case LALOAD:
case DALOAD:
case LADD:
case DADD:
case LSUB:
case DSUB:
case LMUL:
case DMUL:
case LDIV:
case DDIV:
case LREM:
case DREM:
case LSHL:
case LSHR:
case LUSHR:
case LAND:
case LOR:
case LXOR:
size = 2;
break;
default:
size = 1;
}
return new SourceValue(size, insn);
}
示例9: getMethodTransformers
import org.objectweb.asm.tree.AbstractInsnNode; //导入方法依赖的package包/类
@Override
public MethodTransformer[] getMethodTransformers() {
MethodTransformer transformRenderParticle = new MethodTransformer() {
@Override
public MethodName getName() {
return Names.Particle_renderParticle;
}
@Override
public void transform(ClassNode classNode, MethodNode method, boolean obfuscated) {
CLTLog.info("Found method: " + method.name + " " + method.desc);
for (AbstractInsnNode instruction : method.instructions.toArray()) {
if (instruction.getOpcode() == ISHR) {
CLTLog.info("Found ISHR in method " + getName().all());
instruction = instruction.getPrevious().getPrevious();
transformParticle(classNode, method, instruction, 14);
break;
}
}
}
};
return new MethodTransformer[] {transformRenderParticle};
}
示例10: binaryOperation
import org.objectweb.asm.tree.AbstractInsnNode; //导入方法依赖的package包/类
@Override
public BasicValue binaryOperation(final AbstractInsnNode insn,
final BasicValue value1, final BasicValue value2)
throws AnalyzerException {
switch (insn.getOpcode()) {
case IALOAD:
case BALOAD:
case CALOAD:
case SALOAD:
case IADD:
case ISUB:
case IMUL:
case IDIV:
case IREM:
case ISHL:
case ISHR:
case IUSHR:
case IAND:
case IOR:
case IXOR:
return BasicValue.INT_VALUE;
case FALOAD:
case FADD:
case FSUB:
case FMUL:
case FDIV:
case FREM:
return BasicValue.FLOAT_VALUE;
case LALOAD:
case LADD:
case LSUB:
case LMUL:
case LDIV:
case LREM:
case LSHL:
case LSHR:
case LUSHR:
case LAND:
case LOR:
case LXOR:
return BasicValue.LONG_VALUE;
case DALOAD:
case DADD:
case DSUB:
case DMUL:
case DDIV:
case DREM:
return BasicValue.DOUBLE_VALUE;
case AALOAD:
return BasicValue.REFERENCE_VALUE;
case LCMP:
case FCMPL:
case FCMPG:
case DCMPL:
case DCMPG:
return BasicValue.INT_VALUE;
case IF_ICMPEQ:
case IF_ICMPNE:
case IF_ICMPLT:
case IF_ICMPGE:
case IF_ICMPGT:
case IF_ICMPLE:
case IF_ACMPEQ:
case IF_ACMPNE:
case PUTFIELD:
return null;
default:
throw new Error("Internal error.");
}
}
示例11: getNextPseudoInsn
import org.objectweb.asm.tree.AbstractInsnNode; //导入方法依赖的package包/类
public static @Nullable AbstractInsnNode getNextPseudoInsn(AbstractInsnNode insn) {
while ((insn = insn.getNext()) != null && insn.getOpcode() != -1);
return insn;
}
示例12: copyOperation
import org.objectweb.asm.tree.AbstractInsnNode; //导入方法依赖的package包/类
@Override
public BasicValue copyOperation(final AbstractInsnNode insn,
final BasicValue value) throws AnalyzerException {
Value expected;
switch (insn.getOpcode()) {
case ILOAD:
case ISTORE:
expected = BasicValue.INT_VALUE;
break;
case FLOAD:
case FSTORE:
expected = BasicValue.FLOAT_VALUE;
break;
case LLOAD:
case LSTORE:
expected = BasicValue.LONG_VALUE;
break;
case DLOAD:
case DSTORE:
expected = BasicValue.DOUBLE_VALUE;
break;
case ALOAD:
if (!value.isReference()) {
throw new AnalyzerException(insn, null, "an object reference",
value);
}
return value;
case ASTORE:
if (!value.isReference()
&& !BasicValue.RETURNADDRESS_VALUE.equals(value)) {
throw new AnalyzerException(insn, null,
"an object reference or a return address", value);
}
return value;
default:
return value;
}
if (!expected.equals(value)) {
throw new AnalyzerException(insn, null, expected, value);
}
return value;
}
示例13: getPreviousRealInsn
import org.objectweb.asm.tree.AbstractInsnNode; //导入方法依赖的package包/类
public static @Nullable AbstractInsnNode getPreviousRealInsn(AbstractInsnNode insn) {
while ((insn = insn.getPrevious()) != null && insn.getOpcode() == -1);
return insn;
}
示例14: getPreviousPseudoInsn
import org.objectweb.asm.tree.AbstractInsnNode; //导入方法依赖的package包/类
public static @Nullable AbstractInsnNode getPreviousPseudoInsn(AbstractInsnNode insn) {
while ((insn = insn.getPrevious()) != null && insn.getOpcode() != -1);
return insn;
}
示例15: isControlFlowInstruction
import org.objectweb.asm.tree.AbstractInsnNode; //导入方法依赖的package包/类
private static boolean isControlFlowInstruction(AbstractInsnNode insn) {
return isReturn(insn) || isThrow(insn) || isSwitch(insn) || (insn instanceof JumpInsnNode)
|| insn.getOpcode() == Opcodes.RET;
}