本文整理汇总了Java中org.objectweb.asm.tree.TypeInsnNode类的典型用法代码示例。如果您正苦于以下问题:Java TypeInsnNode类的具体用法?Java TypeInsnNode怎么用?Java TypeInsnNode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TypeInsnNode类属于org.objectweb.asm.tree包,在下文中一共展示了TypeInsnNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: remap
import org.objectweb.asm.tree.TypeInsnNode; //导入依赖的package包/类
@Override
protected void remap() {
findNode(getObfType().getJvmStandard()).ifPresent((classNode -> classNode.methods.forEach((methodNode -> {
if (methodNode.name.equals("<init>")) {
methodNode.instructions.iterator().forEachRemaining((insnNode) -> {
if (insnNode.getOpcode() == Opcodes.ANEWARRAY) {
if (insnNode instanceof TypeInsnNode) {
TypeInsnNode typeInsnNode = (TypeInsnNode) insnNode;
Type type = Type.getType(typeInsnNode.desc);
getMappings().putClass(type.getInternalName(), "net.minecraft.world" +
".IWorldEventListener");
}
}
});
}
}))));
}
示例2: visit
import org.objectweb.asm.tree.TypeInsnNode; //导入依赖的package包/类
@Override
public void visit(Branch.Condition.NumLoopEnd cond) {
assert (destLabel != null);
il.add(new VarInsnNode(ALOAD, slot(cond.var())));
il.add(new TypeInsnNode(CHECKCAST, Type.getInternalName(Number.class)));
il.add(new VarInsnNode(ALOAD, slot(cond.limit())));
il.add(new TypeInsnNode(CHECKCAST, Type.getInternalName(Number.class)));
il.add(new VarInsnNode(ALOAD, slot(cond.step())));
il.add(new TypeInsnNode(CHECKCAST, Type.getInternalName(Number.class)));
il.add(DispatchMethods.continueLoop());
if (!isSub() || resolver.isLocalLabel(destLabel)) {
// local jump
il.add(new JumpInsnNode(IFEQ, l(destLabel)));
} else {
// non-local jump
LabelNode l_nojump = new LabelNode();
il.add(new JumpInsnNode(IFNE, l_nojump));
il.add(_nonLocalGoto(destLabel));
il.add(l_nojump);
il.add(new FrameNode(F_SAME, 0, null, 0, null));
}
}
示例3: insnEqual
import org.objectweb.asm.tree.TypeInsnNode; //导入依赖的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;
}
}
示例4: handle
import org.objectweb.asm.tree.TypeInsnNode; //导入依赖的package包/类
@Override
public void handle(AbstractInsnNode node) throws IncorrectNodeException {
super.handle(node);
LOG.debug(logNode(node));
checkType(node, TypeInsnNode.class);
ExpressionStack stack = mState.getActiveStack();
int opCode = node.getOpcode();
String desc = ((TypeInsnNode) node).desc;
if (opCode == Opcodes.NEW) {
stack.push(new NewExpression(opCode, desc));
}
if (opCode == Opcodes.INSTANCEOF) {
stack.push(new InstanceOfExpression(opCode, desc));
}
if (opCode == Opcodes.ANEWARRAY) {
stack.push(new ArrayCreationExpression(opCode, desc));
}
}
示例5: build
import org.objectweb.asm.tree.TypeInsnNode; //导入依赖的package包/类
@Override
public InsnList build(MethodContext context) {
Type returnType = context.getResultType();
InsnList insnList = new InsnList();
LabelNode continueLabel = new LabelNode();
insnList.add(new InsnNode(DUP));
insnList.add(new FieldInsnNode(GETSTATIC, Type.getInternalName(clazz), field, Type.getDescriptor(Object.class)));
insnList.add(new JumpInsnNode(IF_ACMPEQ, continueLabel));
if (returnType.getSize() == 0) {
insnList.add(new InsnNode(POP));
insnList.add(new InsnNode(RETURN));
} else if (isPrimitive(returnType)) {
insnList.add(new UnboxPrimitives(returnType).build(context));
insnList.add(new InsnNode(returnType.getOpcode(IRETURN)));
} else {
insnList.add(new TypeInsnNode(CHECKCAST, returnType.getInternalName()));
insnList.add(new InsnNode(ARETURN));
}
insnList.add(continueLabel);
insnList.add(new InsnNode(POP));
return insnList;
}
示例6: build
import org.objectweb.asm.tree.TypeInsnNode; //导入依赖的package包/类
@Override
public InsnList build(MethodContext context) {
Type[] argumentTypes = context.getArgumentTypes();
InsnList insnList = new InsnList();
insnList.add(new LdcInsnNode(argumentTypes.length));
insnList.add(new TypeInsnNode(Opcodes.ANEWARRAY, Type.getInternalName(java.lang.reflect.Type.class)));
for (int i = 0; i < argumentTypes.length; i++) {
insnList.add(new InsnNode(DUP));
insnList.add(new LdcInsnNode(i));
insnList.add(new PushBoxedType(argumentTypes[i]).build(context));
insnList.add(new InsnNode(AASTORE));
}
return insnList;
}
示例7: build
import org.objectweb.asm.tree.TypeInsnNode; //导入依赖的package包/类
@Override
public InsnList build(MethodContext context) {
Type[] argumentTypes = context.getArgumentTypes();
int[] arguments = context.getArguments();
InsnList insnList = new InsnList();
insnList.add(new LdcInsnNode(arguments.length));
insnList.add(new TypeInsnNode(Opcodes.ANEWARRAY, Type.getInternalName(Object.class)));
for (int i = 0; i < arguments.length; i++) {
insnList.add(new InsnNode(DUP));
insnList.add(new LdcInsnNode(i));
int index = arguments[i];
Type type = argumentTypes[i];
insnList.add(new VarInsnNode(type.getOpcode(ILOAD), index));
insnList.add(new BoxPrimitives(type).build(context));
insnList.add(new InsnNode(AASTORE));
}
return insnList;
}
示例8: build
import org.objectweb.asm.tree.TypeInsnNode; //导入依赖的package包/类
@Override
public InsnList build(MethodContext context) {
Type[] argumentTypes = Type.getArgumentTypes(call.desc);
InsnList insnList = new InsnList();
insnList.add(new LdcInsnNode(argumentTypes.length));
insnList.add(new TypeInsnNode(Opcodes.ANEWARRAY, Type.getInternalName(java.lang.reflect.Type.class)));
for (int i = 0; i < argumentTypes.length; i++) {
insnList.add(new InsnNode(DUP));
insnList.add(new LdcInsnNode(i));
insnList.add(new PushBoxedType(argumentTypes[i]).build(context));
insnList.add(new InsnNode(AASTORE));
}
return insnList;
}
示例9: skipCheckCastBackwards
import org.objectweb.asm.tree.TypeInsnNode; //导入依赖的package包/类
private AbstractInsnNode skipCheckCastBackwards(AbstractInsnNode node)
{
// skip possible (?) ALOAD 0 if not static
if (! this.isStatic && (node instanceof VarInsnNode) && (node.getOpcode() == ALOAD) && (((VarInsnNode) node).var == 0))
{
node = node.getPrevious();
}
// skip possible check cast
if ((node instanceof TypeInsnNode) && (node.getOpcode() == CHECKCAST))
{
node = node.getPrevious();
}
// skip possible (?) ALOAD 0 if not static
if (! this.isStatic && (node instanceof VarInsnNode) && (node.getOpcode() == ALOAD) && (((VarInsnNode) node).var == 0))
{
node = node.getPrevious();
}
return node;
}
示例10: transformObjectFactoryClient
import org.objectweb.asm.tree.TypeInsnNode; //导入依赖的package包/类
private byte[] transformObjectFactoryClient(byte[] before) {
ClassNode classNode = new ClassNode();
ClassReader reader = new ClassReader(before);
reader.accept(classNode, 0);
for (MethodNode m : classNode.methods) {
if (m.name.equals("preBeginGame")) {
m.instructions.clear();
m.instructions.add(new TypeInsnNode(NEW, "alexiil/mods/load/LiteLoaderProgress"));
m.instructions.add(new MethodInsnNode(INVOKESPECIAL, "alexiil/mods/load/LiteLoaderProgress", "<init>", "()V", false));
m.instructions.add(new InsnNode(RETURN));
}
}
ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS);
classNode.accept(cw);
return cw.toByteArray();
}
示例11: transformDamageItem
import org.objectweb.asm.tree.TypeInsnNode; //导入依赖的package包/类
private void transformDamageItem(MethodNode method) {
InsnList postEvent = new InsnList();
LabelNode label = new LabelNode(new Label());
postEvent.add(new TypeInsnNode(Opcodes.NEW, DAMAGE_ITEM_EVENT.getInternalName()));
postEvent.add(new InsnNode(Opcodes.DUP));
postEvent.add(new VarInsnNode(Opcodes.ALOAD, 2));
postEvent.add(new VarInsnNode(Opcodes.ILOAD, 1));
postEvent.add(new VarInsnNode(Opcodes.ALOAD, 0));
postEvent.add(new MethodInsnNode(Opcodes.INVOKESPECIAL, DAMAGE_ITEM_EVENT_INIT.getOwnerInternalName(), DAMAGE_ITEM_EVENT_INIT.getEnvName(), DAMAGE_ITEM_EVENT_INIT.getDesc(), false));
postEvent.add(new VarInsnNode(Opcodes.ASTORE, 3));
postEvent.add(new FieldInsnNode(Opcodes.GETSTATIC, EVENTHANDLER_DAMAGE_ITEM.getOwnerInternalName(), EVENTHANDLER_DAMAGE_ITEM.getEnvName(), EVENTHANDLER_DAMAGE_ITEM.getDesc()));
postEvent.add(new VarInsnNode(Opcodes.ALOAD, 3));
postEvent.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL, POST.getOwnerInternalName(), POST.getEnvName(), POST.getDesc(), false));
postEvent.add(new JumpInsnNode(Opcodes.IFEQ, label));
postEvent.add(new InsnNode(Opcodes.RETURN));
postEvent.add(label);
postEvent.add(new FrameNode(Opcodes.F_APPEND, 1, new Object[] {DAMAGE_ITEM_EVENT.getInternalName()}, 0, null));
postEvent.add(new VarInsnNode(Opcodes.ALOAD, 3));
postEvent.add(new FieldInsnNode(Opcodes.GETFIELD, DAMAGE.getOwnerInternalName(), DAMAGE.getEnvName(), DAMAGE.getDesc()));
postEvent.add(new VarInsnNode(Opcodes.ISTORE, 1));
method.instructions.insert(postEvent);
}
示例12: insnEqual
import org.objectweb.asm.tree.TypeInsnNode; //导入依赖的package包/类
public static boolean insnEqual(AbstractInsnNode node1, AbstractInsnNode node2) {
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;
}
}
示例13: addMapperValueMethod
import org.objectweb.asm.tree.TypeInsnNode; //导入依赖的package包/类
private void addMapperValueMethod(ClassNode domain, ClassNode mapper)
{
if (DomainMojoHelper.log().isDebugEnabled())
DomainMojoHelper.log().debug("Add mapperValue(IDataSource)V method...");
MethodNode mn = new MethodNode(ACC_PUBLIC, "mapperValue", "(Lgemlite/core/internal/domain/IDataSource;)L"
+ domain.name + ";", null, null);
InsnList insn = mn.instructions;
insn.add(new TypeInsnNode(NEW, domain.name));
insn.add(new InsnNode(DUP));
insn.add(AsmHelper.newMethodInsnNode(INVOKESPECIAL, domain.name, "<init>", "()V", false));
insn.add(new VarInsnNode(ASTORE, 2));
insn.add(new VarInsnNode(ALOAD, 0));
insn.add(new VarInsnNode(ALOAD, 1));
insn.add(new VarInsnNode(ALOAD, 2));
insn.add(AsmHelper.newMethodInsnNode(INVOKEVIRTUAL, mapper.name, "mapperValue",
"(Lgemlite/core/internal/domain/IDataSource;L" + domain.name + ";)L" + domain.name + ";", false));
insn.add(new InsnNode(POP));
insn.add(new VarInsnNode(ALOAD, 2));
insn.add(new InsnNode(ARETURN));
mapper.methods.add(mn);
if (DomainMojoHelper.log().isDebugEnabled())
DomainMojoHelper.log().debug("Add mapperValue(IDataSource)V method done.");
}
示例14: injectProcessInterceptor
import org.objectweb.asm.tree.TypeInsnNode; //导入依赖的package包/类
private void injectProcessInterceptor( MethodNode method, String parent, String realName, String methodParam )
{
SpaceCoreLog.fine( "Injecting at beginning of method...." );
String realParent = ObfuscationUtils.asmify( parent );
String realClass = ObfuscationUtils.asmify( realName );
InsnList instructions = new InsnList();
instructions.add( new VarInsnNode( ALOAD, 1 ) );
instructions.add( new VarInsnNode( ALOAD, 0 ) );
instructions.add( new TypeInsnNode( CHECKCAST, realParent ) );
instructions.add( new MethodInsnNode( INVOKESTATIC, "com/spacechase0/minecraft/spacecore/network/PacketInterceptor", "intercept", "(L" + methodParam + ";L" + realParent + ";)V" ) );
//System.out.println( methodParam+" "+realClass );
method.instructions.insertBefore( method.instructions.get( 0 ), instructions );
}
示例15: injectSendInterceptor
import org.objectweb.asm.tree.TypeInsnNode; //导入依赖的package包/类
private void injectSendInterceptor( MethodNode method, String parent, String methodParam )
{
SpaceCoreLog.fine( "Injecting at beginning of method...." );
String realParent = ObfuscationUtils.asmify( parent );
//String realClass = ObfuscationUtils.asmify( realName );
InsnList instructions = new InsnList();
instructions.add( new VarInsnNode( ALOAD, 0 ) );
instructions.add( new VarInsnNode( ALOAD, 1 ) );
instructions.add( new TypeInsnNode( CHECKCAST, realParent ) );
instructions.add( new MethodInsnNode( INVOKESTATIC, "com/spacechase0/minecraft/spacecore/network/PacketInterceptor", "intercept", "(L" + realParent + ";L" + methodParam + ";)V" ) );
//System.out.println( methodParam+" "+realClass );
method.instructions.insertBefore( method.instructions.get( 0 ), instructions );
}