当前位置: 首页>>代码示例>>Java>>正文


Java Opcodes.LDC属性代码示例

本文整理汇总了Java中org.objectweb.asm.Opcodes.LDC属性的典型用法代码示例。如果您正苦于以下问题:Java Opcodes.LDC属性的具体用法?Java Opcodes.LDC怎么用?Java Opcodes.LDC使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.objectweb.asm.Opcodes的用法示例。


在下文中一共展示了Opcodes.LDC属性的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: newOperation

@Override
public BasicValue newOperation(AbstractInsnNode insnNode) throws AnalyzerException {
    switch (insnNode.getOpcode()) {
        case ICONST_0: return new IntegerConstantBasicValue(Type.INT_TYPE, 0);
        case ICONST_1: return new IntegerConstantBasicValue(Type.INT_TYPE, 1);
        case ICONST_2: return new IntegerConstantBasicValue(Type.INT_TYPE, 2);
        case ICONST_3: return new IntegerConstantBasicValue(Type.INT_TYPE, 3);
        case ICONST_4: return new IntegerConstantBasicValue(Type.INT_TYPE, 4);
        case ICONST_5: return new IntegerConstantBasicValue(Type.INT_TYPE, 5);
        case BIPUSH:
        case SIPUSH: return new IntegerConstantBasicValue(Type.INT_TYPE, ((IntInsnNode)insnNode).operand);
        case Opcodes.LDC: {
            Object constant = ((LdcInsnNode)insnNode).cst;
            if (constant instanceof Integer) {
                return new IntegerConstantBasicValue(Type.INT_TYPE, (Integer)constant);
            } else {
                return super.newOperation(insnNode);
            }
        }
        default: return super.newOperation(insnNode);
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:22,代码来源:ESLoggerUsageChecker.java

示例2: CanvasHook

public CanvasHook() {
	super(new Regex(
			new Instruction(Opcodes.GOTO, false),
			new Instruction(Opcodes.GETSTATIC, true),
			new Instruction(Opcodes.CHECKCAST, false),
			new Instruction(Opcodes.ALOAD, false),
			new Instruction(Opcodes.GETFIELD, false),
			new Instruction(Opcodes.LDC, false),
			new Instruction(Opcodes.INVOKEVIRTUAL, true),
			new Instruction(Opcodes.GOTO, false)
		));
}
 
开发者ID:jonathanedgecombe,项目名称:mithril,代码行数:12,代码来源:CanvasHook.java

示例3: analyzeInstruction

private void analyzeInstruction(Object instructionObject) {
	// CHECKSTYLE:OFF
	final AbstractInsnNode instruction = (AbstractInsnNode) instructionObject;
	// CHECKSTYLE:ON
	// rq : on ne considère pas une instruction d'incrémentation (opcode IINC, type
	// IincInsnNode) comme une instruction de lecture car elle ne lit pas elle-même la variable,
	// IINC équivaut à une écriture par incrémentation (store) de la variable
	if (isRead(instruction.getOpcode())) {
		// si c'est une lecture de variable, alors la variable est utilisée
		// (une instruction d'opcode xLOAD est forcément de type VarInsnNode)
		removeLocalVariable((VarInsnNode) instruction);
	} else if (isStore(instruction.getOpcode())) {
		if (instruction.getPrevious().getOpcode() == Opcodes.LDC) {
			// si c'est une écriture de variable avec une constante de méthode
			// alors la variable est utilisée si la même constante est lue ensuite
			// (une instruction d'opcode xSTORE est forcément de type VarInsnNode,
			// une instruction d'opcode LDC est forcément de type LdcInsnNode)
			varInstructionsByConstantesMap.put(((LdcInsnNode) instruction.getPrevious()).cst,
					(VarInsnNode) instruction);
		} else if (isSimpleConstant(instruction.getPrevious())) {
			// si c'est une écriture de variable avec une constante telle false, 0 ou 57
			// alors la variable est considérée comme utilisée
			removeLocalVariable((VarInsnNode) instruction);
		}
	} else {
		analyzeConstantInstruction(instruction);
	}
}
 
开发者ID:evernat,项目名称:dead-code-detector,代码行数:28,代码来源:LocalVariablesAnalyzer.java

示例4: analyzeConstantInstruction

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,代码行数:14,代码来源:LocalVariablesAnalyzer.java

示例5: canThrow

private boolean canThrow(AbstractInsnNode insn) {
  switch (insn.getOpcode()) {
    case Opcodes.AALOAD:
    case Opcodes.AASTORE:
    case Opcodes.ANEWARRAY:
      // ARETURN does not throw in its dex image.
    case Opcodes.ARRAYLENGTH:
    case Opcodes.ATHROW:
    case Opcodes.BALOAD:
    case Opcodes.BASTORE:
    case Opcodes.CALOAD:
    case Opcodes.CASTORE:
    case Opcodes.CHECKCAST:
    case Opcodes.DALOAD:
    case Opcodes.DASTORE:
      // DRETURN does not throw in its dex image.
    case Opcodes.FALOAD:
    case Opcodes.FASTORE:
      // FRETURN does not throw in its dex image.
    case Opcodes.GETFIELD:
    case Opcodes.GETSTATIC:
    case Opcodes.IALOAD:
    case Opcodes.IASTORE:
    case Opcodes.IDIV:
    case Opcodes.INSTANCEOF:
    case Opcodes.INVOKEDYNAMIC:
    case Opcodes.INVOKEINTERFACE:
    case Opcodes.INVOKESPECIAL:
    case Opcodes.INVOKESTATIC:
    case Opcodes.INVOKEVIRTUAL:
    case Opcodes.IREM:
      // IRETURN does not throw in its dex image.
    case Opcodes.LALOAD:
    case Opcodes.LASTORE:
    case Opcodes.LDIV:
    case Opcodes.LREM:
      // LRETURN does not throw in its dex image.
    case Opcodes.MONITORENTER:
    case Opcodes.MONITOREXIT:
    case Opcodes.MULTIANEWARRAY:
    case Opcodes.NEW:
    case Opcodes.NEWARRAY:
    case Opcodes.PUTFIELD:
    case Opcodes.PUTSTATIC:
      // RETURN does not throw in its dex image.
    case Opcodes.SALOAD:
    case Opcodes.SASTORE:
      return true;
    case Opcodes.LDC: {
      // const-class and const-string* may throw in dex.
      LdcInsnNode ldc = (LdcInsnNode) insn;
      return ldc.cst instanceof String || ldc.cst instanceof Type;
    }
    default:
      return false;
  }
}
 
开发者ID:inferjay,项目名称:r8,代码行数:57,代码来源:JarSourceCode.java

示例6: overclockServer

private static void overclockServer(ClassNode node, boolean isObfuscated)
{
    // We're attempting to replace this code (from the heart of MinecraftServer.run):
    /*       
        {
            while (i > 50L)
            {
                i -= 50L;
                this.tick();
            }
        }

        Thread.sleep(Math.max(1L, 50L - i));
    */

    // With this:
    /*       
    {
        while (i > TimeHelper.serverTickLength)
        {
            i -= TimeHelper.serverTickLength;
            this.tick();
        }
    }

    Thread.sleep(Math.max(1L, TimeHelper.serverTickLength - i));
*/
    // This allows us to alter the tick length via TimeHelper.
    
    final String methodName = "run";
    final String methodDescriptor = "()V"; // No params, returns void.

    System.out.println("MALMO: Found MinecraftServer, attempting to transform it");

    for (MethodNode method : node.methods)
    {
        if (method.name.equals(methodName) && method.desc.equals(methodDescriptor))
        {
            System.out.println("MALMO: Found MinecraftServer.run() method, attempting to transform it");
            for (AbstractInsnNode instruction : method.instructions.toArray())
            {
                if (instruction.getOpcode() == Opcodes.LDC)
                {
                    Object cst = ((LdcInsnNode)instruction).cst;
                    if ((cst instanceof Long) && (Long)cst == 50)
                    {
                        System.out.println("MALMO: Transforming LDC");
                        AbstractInsnNode replacement = new FieldInsnNode(Opcodes.GETSTATIC, "com/microsoft/Malmo/Utils/TimeHelper", "serverTickLength", "J");
                        method.instructions.set(instruction, replacement);
                    }
                }
            }
        }
    }
}
 
开发者ID:Yarichi,项目名称:Proyecto-DASI,代码行数:55,代码来源:OverclockingClassTransformer.java

示例7: LdcInsnNode

/**
 * Constructs a new {@link LdcInsnNode}.
 * 
 * @param cst
 *            the constant to be loaded on the stack. This parameter must be
 *            a non null {@link Integer}, a {@link Float}, a {@link Long}, a
 *            {@link Double} or a {@link String}.
 */
public LdcInsnNode(final Object cst) {
    super(Opcodes.LDC);
    this.cst = cst;
}
 
开发者ID:ItzSomebody,项目名称:DirectLeaks-AntiReleak-Remover,代码行数:12,代码来源:LdcInsnNode.java


注:本文中的org.objectweb.asm.Opcodes.LDC属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。