本文整理汇总了Java中org.objectweb.asm.tree.LdcInsnNode类的典型用法代码示例。如果您正苦于以下问题:Java LdcInsnNode类的具体用法?Java LdcInsnNode怎么用?Java LdcInsnNode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LdcInsnNode类属于org.objectweb.asm.tree包,在下文中一共展示了LdcInsnNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: remap
import org.objectweb.asm.tree.LdcInsnNode; //导入依赖的package包/类
@Override
protected void remap() {
Optional<ClassNode> classNode = findNode(TestMappings.class.getName());
classNode.ifPresent((cn) -> {
for (MethodNode method : cn.methods) {
TypeNameEnforcer returnType = TypeNameEnforcer.getReturnType(method);
if (returnType.getJvmStandard().equals("java/lang/String")) {
method.instructions.iterator().forEachRemaining((insnNode) -> {
if (insnNode instanceof LdcInsnNode) {
LdcInsnNode ldcInsnNode = (LdcInsnNode) insnNode;
String payload = (String) ldcInsnNode.cst;
if (!payload.equals("oops")) {
MethodRef methodRef = createObfMd(method);
MethodRef methodRef1 = createRemappedMd("correct", method);
getMappings().putMethod(methodRef, methodRef1);
}
}
});
}
}
});
}
示例2: stringEncryptionTransformer
import org.objectweb.asm.tree.LdcInsnNode; //导入依赖的package包/类
private static void stringEncryptionTransformer(ClassNode classNode) {
if (classNode.superName.equals("org/bukkit/plugin/java/JavaPlugin") || classNode.superName.equals("net/md_5/bungee/api/plugin/Plugin")) {
for (MethodNode methodNode : classNode.methods) {
InsnList nodes = methodNode.instructions;
for (int i = 0; i < nodes.size(); i++) {
AbstractInsnNode instruction = nodes.get(i);
if (instruction instanceof LdcInsnNode) {
if (instruction.getNext() instanceof MethodInsnNode) {
LdcInsnNode ldc = (LdcInsnNode) instruction;
MethodInsnNode methodinsnnode = (MethodInsnNode) ldc.getNext();
if (ldc.cst instanceof String) {
if (methodinsnnode.name.equalsIgnoreCase("\u0972") && methodinsnnode.desc.equalsIgnoreCase("(Ljava/lang/String;)Ljava/lang/String;")) {
methodNode.instructions.remove(methodinsnnode);
ldc.cst = decryptionArray((String)ldc.cst);
}
}
}
}
}
}
}
}
示例3: toNumericalValue
import org.objectweb.asm.tree.LdcInsnNode; //导入依赖的package包/类
public static InsnList toNumericalValue(String what) {
Objects.requireNonNull(what);
InsnList il = new InsnList();
il.add(new LdcInsnNode(what));
il.add(new MethodInsnNode(
INVOKESTATIC,
Type.getInternalName(Conversions.class),
"toNumericalValue",
Type.getMethodDescriptor(
Type.getType(Number.class),
Type.getType(Object.class),
Type.getType(String.class)),
false));
return il;
}
示例4: newOperation
import org.objectweb.asm.tree.LdcInsnNode; //导入依赖的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);
}
示例5: updateState
import org.objectweb.asm.tree.LdcInsnNode; //导入依赖的package包/类
private void updateState(LdcInsnNode insn) {
if (insn.cst instanceof Type) {
Type type = (Type) insn.cst;
state.push(type);
} else if (insn.cst instanceof String) {
state.push(STRING_TYPE);
} else if (insn.cst instanceof Long) {
state.push(Type.LONG_TYPE);
} else if (insn.cst instanceof Double) {
state.push(Type.DOUBLE_TYPE);
} else if (insn.cst instanceof Integer) {
state.push(Type.INT_TYPE);
} else {
assert insn.cst instanceof Float;
state.push(Type.FLOAT_TYPE);
}
}
示例6: build
import org.objectweb.asm.tree.LdcInsnNode; //导入依赖的package包/类
private void build(LdcInsnNode insn, IRBuilder builder) {
if (insn.cst instanceof Type) {
Type type = (Type) insn.cst;
int dest = state.push(type);
builder.addConstClass(dest, application.getTypeFromDescriptor(type.getDescriptor()));
} else if (insn.cst instanceof String) {
int dest = state.push(STRING_TYPE);
builder.addConstString(dest, application.getString((String) insn.cst));
} else if (insn.cst instanceof Long) {
int dest = state.push(Type.LONG_TYPE);
builder.addLongConst(dest, (Long) insn.cst);
} else if (insn.cst instanceof Double) {
int dest = state.push(Type.DOUBLE_TYPE);
builder.addDoubleConst(dest, Double.doubleToRawLongBits((Double) insn.cst));
} else if (insn.cst instanceof Integer) {
int dest = state.push(Type.INT_TYPE);
builder.addIntConst(dest, (Integer) insn.cst);
} else {
assert insn.cst instanceof Float;
int dest = state.push(Type.FLOAT_TYPE);
builder.addFloatConst(dest, Float.floatToRawIntBits((Float) insn.cst));
}
}
示例7: newOperation
import org.objectweb.asm.tree.LdcInsnNode; //导入依赖的package包/类
@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);
}
}
示例8: findID
import org.objectweb.asm.tree.LdcInsnNode; //导入依赖的package包/类
private static void findID(ClassNode classNode) throws Throwable {
for (MethodNode methodNode : classNode.methods) {
Iterator<AbstractInsnNode> insnIterator = methodNode.instructions.iterator();
while (insnIterator.hasNext()) {
AbstractInsnNode insnNode = insnIterator.next();
String str;
if ((insnNode.getType() == 9)) {
Object cst = ((LdcInsnNode) insnNode).cst;
if (cst instanceof String) {
str = ((LdcInsnNode) insnNode).cst.toString();
Matcher matcher = NONCEID_PATTERN.matcher(str);
if (matcher.find()) {
possiblenonces.add(str);
}
}
}
}
}
}
示例9: visit
import org.objectweb.asm.tree.LdcInsnNode; //导入依赖的package包/类
@Override
public void visit(LoadConst.Str node) {
// use byte strings?
if (context.compilerSettings.byteStrings()) {
if (context.compilerSettings.constCaching()) {
il.add(loadCachedConst(node.value()));
} else {
il.add(newByteString(node.value()));
}
} else {
// java.lang.String
il.add(new LdcInsnNode(node.value()));
}
il.add(new VarInsnNode(ASTORE, slot(node.dest())));
}
示例10: loadInt
import org.objectweb.asm.tree.LdcInsnNode; //导入依赖的package包/类
public static AbstractInsnNode loadInt(int i) {
switch (i) {
case -1: return new InsnNode(ICONST_M1);
case 0: return new InsnNode(ICONST_0);
case 1: return new InsnNode(ICONST_1);
case 2: return new InsnNode(ICONST_2);
case 3: return new InsnNode(ICONST_3);
case 4: return new InsnNode(ICONST_4);
case 5: return new InsnNode(ICONST_5);
default: {
if (i >= Byte.MIN_VALUE && i <= Byte.MAX_VALUE) return new IntInsnNode(BIPUSH, i);
else if (i >= Short.MIN_VALUE && i <= Short.MAX_VALUE) return new IntInsnNode(SIPUSH, i);
else return new LdcInsnNode(i);
}
}
}
示例11: toNumericalValue
import org.objectweb.asm.tree.LdcInsnNode; //导入依赖的package包/类
public static InsnList toNumericalValue(String what) {
Objects.requireNonNull(what);
InsnList il = new InsnList();
il.add(new LdcInsnNode(what));
il.add(new MethodInsnNode(
INVOKESTATIC,
Type.getInternalName(Conversions.class),
"toNumericalValue",
Type.getMethodDescriptor(
Type.getType(Number.class),
Type.getType(Object.class),
Type.getType(String.class)),
false));
return il;
}
示例12: patch
import org.objectweb.asm.tree.LdcInsnNode; //导入依赖的package包/类
@Override
public ClassVisitor patch(String className, ClassVisitor delegate) throws Exception {
return new FindingVisitor(
delegate,
new VarInsnNode(ALOAD, 4),
new LdcInsnNode(7000L),
new MethodInsnNode(INVOKEVIRTUAL, "java/lang/Thread", "join", "(J)V", false)
) {
@Override
public void handle(InsnList nodes, MethodVisitor visitor) {
visitor.visitVarInsn(ALOAD, 4);
visitor.visitFieldInsn(GETSTATIC, "org/squiddev/cctweaks/lua/Config$Computer", "computerThreadTimeout", "I");
visitor.visitInsn(I2L);
visitor.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Thread", "join", "(J)V", false);
}
}.onMethod("run").once().mustFind();
}
示例13: patch
import org.objectweb.asm.tree.LdcInsnNode; //导入依赖的package包/类
@Override
public ClassVisitor patch(String className, ClassVisitor delegate) throws Exception {
return new FindingVisitor(
delegate,
new LdcInsnNode("lua/bios.lua")
) {
@Override
public void handle(InsnList nodes, MethodVisitor visitor) {
Label finish = new Label(), def = new Label();
visitor.visitVarInsn(ALOAD, 0);
visitor.visitFieldInsn(GETFIELD, "dan200/computercraft/core/computer/Computer", "biosPath", "Ljava/lang/String;");
visitor.visitJumpInsn(IFNULL, def);
visitor.visitVarInsn(ALOAD, 0);
visitor.visitFieldInsn(GETFIELD, "dan200/computercraft/core/computer/Computer", "biosPath", "Ljava/lang/String;");
visitor.visitJumpInsn(GOTO, finish);
visitor.visitLabel(def);
visitor.visitLdcInsn("lua/bios.lua");
visitor.visitLabel(finish);
}
}.onMethod("initLua").mustFind();
}
示例14: convertLdcInsn
import org.objectweb.asm.tree.LdcInsnNode; //导入依赖的package包/类
private void convertLdcInsn(LdcInsnNode insn) {
Object val = insn.cst;
boolean dword = val instanceof Long || val instanceof Double;
StackFrame frame = getFrame(insn);
Operand[] out = frame.out();
Operand opr;
if (out == null) {
Value v = toSootValue(val);
opr = new Operand(insn, v);
frame.out(opr);
} else {
opr = out[0];
}
if (dword)
pushDual(opr);
else
push(opr);
}
示例15: insnEqual
import org.objectweb.asm.tree.LdcInsnNode; //导入依赖的package包/类
public static boolean insnEqual(AbstractInsnNode node1, AbstractInsnNode node2) {
if (node1.getType() != node2.getType()) {
return false;
} else if (node1.getOpcode() != node2.getOpcode()) {
return false;
}
switch (node2.getType()) {
case VAR_INSN:
return varInsnEqual((VarInsnNode) node1, (VarInsnNode) node2);
case TYPE_INSN:
return typeInsnEqual((TypeInsnNode) node1, (TypeInsnNode) node2);
case FIELD_INSN:
return fieldInsnEqual((FieldInsnNode) node1, (FieldInsnNode) node2);
case METHOD_INSN:
return methodInsnEqual((MethodInsnNode) node1, (MethodInsnNode) node2);
case LDC_INSN:
return ldcInsnEqual((LdcInsnNode) node1, (LdcInsnNode) node2);
case IINC_INSN:
return iincInsnEqual((IincInsnNode) node1, (IincInsnNode) node2);
case INT_INSN:
return intInsnEqual((IntInsnNode) node1, (IntInsnNode) node2);
default:
return true;
}
}