本文整理汇总了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);
}
}
示例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)
));
}
示例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);
}
}
示例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);
}
}
}
示例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;
}
}
示例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);
}
}
}
}
}
}
示例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;
}