當前位置: 首頁>>代碼示例>>Java>>正文


Java AbstractInsnNode.getOpcode方法代碼示例

本文整理匯總了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);
}
 
開發者ID:acmerli,項目名稱:fastAOP,代碼行數:23,代碼來源:SourceInterpreter.java

示例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};
}
 
開發者ID:shaunlebron,項目名稱:flex-fov,代碼行數:31,代碼來源:ParticleTransformer.java

示例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);
}
 
開發者ID:evernat,項目名稱:dead-code-detector,代碼行數:11,代碼來源:LocalVariablesAnalyzer.java

示例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);
		}
	}
}
 
開發者ID:evernat,項目名稱:dead-code-detector,代碼行數:15,代碼來源:LocalVariablesAnalyzer.java

示例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()");
                    }
                }
            }
        }
    }
}
 
開發者ID:Yarichi,項目名稱:Proyecto-DASI,代碼行數:40,代碼來源:OverclockingClassTransformer.java

示例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);
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:11,代碼來源:ESLoggerUsageChecker.java

示例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);
}
 
開發者ID:ItzSomebody,項目名稱:Spigot-Nonce-ID-Finder,代碼行數:15,代碼來源:SourceInterpreter.java

示例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);
}
 
開發者ID:ItzSomebody,項目名稱:BukkitPlugin-Message-Injector,代碼行數:31,代碼來源:SourceInterpreter.java

示例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};
}
 
開發者ID:shaunlebron,項目名稱:flex-fov,代碼行數:31,代碼來源:ParticleBreakingTransformer.java

示例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.");
    }
}
 
開發者ID:ItzSomebody,項目名稱:Simple-JAR-Watermark,代碼行數:71,代碼來源:BasicInterpreter.java

示例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;
}
 
開發者ID:jonathanedgecombe,項目名稱:anvil,代碼行數:5,代碼來源:AsmUtils.java

示例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;
}
 
開發者ID:acmerli,項目名稱:fastAOP,代碼行數:43,代碼來源:BasicVerifier.java

示例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;
}
 
開發者ID:jonathanedgecombe,項目名稱:anvil,代碼行數:5,代碼來源:AsmUtils.java

示例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;
}
 
開發者ID:jonathanedgecombe,項目名稱:anvil,代碼行數:5,代碼來源:AsmUtils.java

示例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;
}
 
開發者ID:inferjay,項目名稱:r8,代碼行數:5,代碼來源:JarSourceCode.java


注:本文中的org.objectweb.asm.tree.AbstractInsnNode.getOpcode方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。