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


Java VarInsnNode.getOpcode方法代码示例

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


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

示例1: convertVarLoadInsn

import org.objectweb.asm.tree.VarInsnNode; //导入方法依赖的package包/类
private void convertVarLoadInsn(VarInsnNode insn) {
	int op = insn.getOpcode();
	boolean dword = op == LLOAD || op == DLOAD;
	StackFrame frame = getFrame(insn);
	Operand[] out = frame.out();
	Operand opr;
	if (out == null) {
		opr = new Operand(insn, getLocal(insn.var));
		frame.out(opr);
	} else {
		opr = out[0];
	}
	if (dword)
		pushDual(opr);
	else
		push(opr);
}
 
开发者ID:flankerhqd,项目名称:JAADAS,代码行数:18,代码来源:AsmMethodSource.java

示例2: convertVarStoreInsn

import org.objectweb.asm.tree.VarInsnNode; //导入方法依赖的package包/类
private void convertVarStoreInsn(VarInsnNode insn) {
	int op = insn.getOpcode();
	boolean dword = op == LSTORE || op == DSTORE;
	StackFrame frame = getFrame(insn);
	Operand opr = dword ? popDual() : pop();
	Local local = getLocal(insn.var);
	if (!units.containsKey(insn)) {
		DefinitionStmt as = Jimple.v().newAssignStmt(local, opr.stackOrValue());
		opr.addBox(as.getRightOpBox());
		frame.boxes(as.getRightOpBox());
		frame.in(opr);
		setUnit(insn, as);
	} else {
		frame.mergeIn(opr);
	}
	assignReadOps(local);
}
 
开发者ID:flankerhqd,项目名称:JAADAS,代码行数:18,代码来源:AsmMethodSource.java

示例3: convertVarInsn

import org.objectweb.asm.tree.VarInsnNode; //导入方法依赖的package包/类
private void convertVarInsn(VarInsnNode insn) {
	int op = insn.getOpcode();
	if (op >= ILOAD && op <= ALOAD) {
		convertVarLoadInsn(insn);
	} else if (op >= ISTORE && op <= ASTORE) {
		convertVarStoreInsn(insn);
	} else if (op == RET) {
		/* we handle it, even thought it should be removed */
		if (!units.containsKey(insn))
			setUnit(insn, Jimple.v().newRetStmt(getLocal(insn.var)));
	} else {
		throw new AssertionError("Unknown var op: " + op);
	}
}
 
开发者ID:flankerhqd,项目名称:JAADAS,代码行数:15,代码来源:AsmMethodSource.java

示例4: getVarTargets

import org.objectweb.asm.tree.VarInsnNode; //导入方法依赖的package包/类
private int[] getVarTargets(VarInsnNode insn) {
  if (insn.getOpcode() == Opcodes.RET) {
    throw new Unreachable("RET should be handled by the ASM jsr inliner");
  }
  return NO_TARGETS;
}
 
开发者ID:inferjay,项目名称:r8,代码行数:7,代码来源:JarSourceCode.java

示例5: transform

import org.objectweb.asm.tree.VarInsnNode; //导入方法依赖的package包/类
@Override
public void transform(ClassNode clazz, MethodNode method, InsnMatcher matcher) {
	@Nullable LocalVariableNode rateModVar = AsmUtils.getLocalVariable(method, "rateMod", "D");
	if (rateModVar == null)
		throw new InjectorException("Couldn't find rateMod variable");

	@Nullable LocalVariableNode skillDividerVar = AsmUtils.getLocalVariable(method, "skillDivider", "D");
	if (skillDividerVar == null)
		throw new InjectorException("Couldn't find skillDivider variable");

	@Nullable AbstractInsnNode insn = null;

	for (AbstractInsnNode it = method.instructions.getFirst(); it.getNext() != null; it = it.getNext()) {
		AbstractInsnNode next = it.getNext();
		if (!(it instanceof LdcInsnNode) || !(next instanceof VarInsnNode)) {
			continue;
		}

		LdcInsnNode ldc = (LdcInsnNode) it;
		VarInsnNode var = (VarInsnNode) next;

		if (!(ldc.cst instanceof Number) || var.getOpcode() != Opcodes.DSTORE || var.var != rateModVar.index) {
			continue;
		}

		Number rateModNumber = (Number) ldc.cst;
		if (rateModNumber.doubleValue() != 1.2D) {
			continue;
		}

		insn = next;
		break;
	}

	if (insn == null) {
		throw new InjectorException("Couldn't find end of sType if block");
	}

	/* this.skillDivider /= (double) Servers.localServer.getSkillGainRate(); */
	InsnList list = new InsnList();
	list.add(new VarInsnNode(Opcodes.DLOAD, skillDividerVar.index));
	list.add(new FieldInsnNode(Opcodes.GETSTATIC, "com/wurmonline/server/Servers", "localServer", "Lcom/wurmonline/server/ServerEntry;"));
	list.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL, "com/wurmonline/server/ServerEntry", "getSkillGainRate", "()F", false));
	list.add(new InsnNode(Opcodes.F2D));
	list.add(new InsnNode(Opcodes.DDIV));
	list.add(new VarInsnNode(Opcodes.DSTORE, skillDividerVar.index));

	method.instructions.insert(insn, list);
}
 
开发者ID:jonathanedgecombe,项目名称:anvil,代码行数:50,代码来源:SkillGainTransformer.java

示例6: toString

import org.objectweb.asm.tree.VarInsnNode; //导入方法依赖的package包/类
public static String toString(VarInsnNode vin) {
    // return AbstractVisitor.OPCODES[vin.getOpcode()] + " " + vin.var;
    return vin.getOpcode() + " " + vin.var;
}
 
开发者ID:vsilaev,项目名称:tascalate-async-await,代码行数:5,代码来源:BytecodeTraceUtil.java

示例7: transform

import org.objectweb.asm.tree.VarInsnNode; //导入方法依赖的package包/类
@Override
public void transform(String className, ClassNode node) {
	for (MethodNode method : node.methods) {
		if (method.name.equals(PLACE_ITEM.getEnvName()) && method.desc.equals(PLACE_ITEM.getDesc())) {
			boolean inserted = false;
			
			for (ListIterator<AbstractInsnNode> iterator = method.instructions.iterator(); iterator.hasNext();) {
				AbstractInsnNode insn = iterator.next();
				
				if (insn.getNext() instanceof VarInsnNode && insn.getNext().getNext() instanceof VarInsnNode && insn.getNext().getNext().getNext() instanceof MethodInsnNode) {
					VarInsnNode next1 = (VarInsnNode) insn.getNext();
					VarInsnNode next2 = (VarInsnNode) next1.getNext();
					MethodInsnNode next3 = (MethodInsnNode) next2.getNext();
					
					if (next1.getOpcode() == Opcodes.ALOAD && next1.var == 0 && 
						next2.getOpcode() == Opcodes.ILOAD && next2.var == 14 &&
						next3.getOpcode() == Opcodes.INVOKEVIRTUAL && next3.owner.equals(setCount.getOwnerInternalName()) && 
						next3.name.equals(setCount.getEnvName()) && next3.desc.equals(setCount.getDesc())) {
						
						int varIndex = method.maxLocals; method.maxLocals++;
						InsnList postEvent = new InsnList();
						LabelNode label = new LabelNode(new Label());
						
						postEvent.add(new TypeInsnNode(Opcodes.NEW, CHANGE_SIZE_EVENT.getInternalName()));
						postEvent.add(new InsnNode(Opcodes.DUP));
						postEvent.add(new VarInsnNode(Opcodes.ALOAD, 1));
						postEvent.add(new VarInsnNode(Opcodes.ALOAD, 0));
						postEvent.add(new VarInsnNode(Opcodes.ILOAD, 10));
						postEvent.add(new VarInsnNode(Opcodes.ILOAD, 14));
						postEvent.add(new MethodInsnNode(Opcodes.INVOKESPECIAL, CHANGE_SIZE_EVENT_INIT.getOwnerInternalName(), CHANGE_SIZE_EVENT_INIT.getEnvName(), CHANGE_SIZE_EVENT_INIT.getDesc(), false));
						postEvent.add(new VarInsnNode(Opcodes.ASTORE, varIndex));
						postEvent.add(new FieldInsnNode(Opcodes.GETSTATIC, EVENTHANDLER_CHANGE_SIZE.getOwnerInternalName(), EVENTHANDLER_CHANGE_SIZE.getEnvName(), EVENTHANDLER_CHANGE_SIZE.getDesc()));
						postEvent.add(new VarInsnNode(Opcodes.ALOAD, varIndex));
						postEvent.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL, POST.getOwnerInternalName(), POST.getEnvName(), POST.getDesc(), false));
						postEvent.add(new JumpInsnNode(Opcodes.IFEQ, label));
						postEvent.add(new VarInsnNode(Opcodes.ALOAD, varIndex));
						postEvent.add(new FieldInsnNode(Opcodes.GETFIELD, NEW_SIZE.getOwnerInternalName(), NEW_SIZE.getEnvName(), NEW_SIZE.getDesc()));
						postEvent.add(new VarInsnNode(Opcodes.ISTORE, 14));
						postEvent.add(label);
						postEvent.add(new FrameNode(Opcodes.F_SAME, 0, null, 0, null));
						
						method.instructions.insert(insn, postEvent);
						
						inserted = true; break;
					}
				}
			}
			
			if (inserted) break;
		}
	}
}
 
开发者ID:MrNobody98,项目名称:morecommands,代码行数:53,代码来源:TransformForgeHooks.java

示例8: processMethod

import org.objectweb.asm.tree.VarInsnNode; //导入方法依赖的package包/类
private void processMethod(MethodNode methodNode) {
    InsnList insns = methodNode.instructions;

    // Filter out debugging nodes/labels
    int count = 0;
    int maxCount = insns.size();
    AbstractInsnNode[] nodes = new AbstractInsnNode[maxCount];
    for (AbstractInsnNode node = insns.getFirst(); node != null; node = node.getNext())
        if (node.getOpcode() > 0)
            nodes[count++] = node;

    // Find mapper get() calls and create an own flyweight instance for each
    for (int i = 0; i <= count - 4; i++) {
        if (!(nodes[i + 0] instanceof VarInsnNode))
            continue;
        if (!(nodes[i + 1] instanceof FieldInsnNode))
            continue;
        if (!(nodes[i + 2] instanceof VarInsnNode))
            continue;
        if (!(nodes[i + 3] instanceof MethodInsnNode))
            continue;

        VarInsnNode loadThis = (VarInsnNode) nodes[i + 0];
        FieldInsnNode getField = (FieldInsnNode) nodes[i + 1];
        VarInsnNode loadEntity = (VarInsnNode) nodes[i + 2];
        MethodInsnNode getMethod = (MethodInsnNode) nodes[i + 3];

        if (loadThis.var != 0 || loadThis.getOpcode() != ALOAD)
            continue;

        if (!getField.owner.equals(metadata.internalName) ||
                !getField.desc.equals("L" + WeaverConstants.MAPPER_NAME + ";") ||
                !metadata.mappersByName.containsKey(getField.name))
            continue;
        if (loadEntity.getOpcode() != ILOAD)
            continue;
        if (!getMethod.owner.equals(WeaverConstants.MAPPER_NAME) ||
                !getMethod.desc.equals("(I)L" + WeaverConstants.COMPONENT_NAME + ";") ||
                !getMethod.name.equals("get"))
            continue;

        SystemMapper mapper = metadata.mappersByName.get(getField.name);

        // Add field to hold the flyweight
        String fieldName = "flyweight$" + flyweightFields.size();
        String fieldDesc = mapper.componentType.getDescriptor();
        FieldNode fieldNode = new FieldNode(ACC_PRIVATE, fieldName, fieldDesc, null, null);
        fieldNode.visitAnnotation("Lcom/github/antag99/retinazer/SkipWire;", true);
        FlyweightField flyweightField = new FlyweightField();
        flyweightField.fieldNode = fieldNode;
        flyweightField.mapper = mapper;
        flyweightFields.add(flyweightField);

        // Rewrite access to use the flyweight
        getField.owner = metadata.internalName;
        getField.name = fieldName;
        getField.desc = fieldDesc;
        insns.insert(getField, new InsnNode(DUP));
        insns.insert(loadEntity, new FieldInsnNode(PUTFIELD, mapper.componentType.getInternalName(),
                WeaverConstants.INDEX_FIELD_NAME, WeaverConstants.INDEX_FIELD_DESC));
        insns.remove(getMethod);
    }
}
 
开发者ID:antag99,项目名称:retinazer,代码行数:64,代码来源:SystemProcessor.java

示例9: transformVarInsnNode

import org.objectweb.asm.tree.VarInsnNode; //导入方法依赖的package包/类
@Override
protected AbstractInsnNode transformVarInsnNode(MethodNode mn, VarInsnNode varNode) {
	if (varNode.getOpcode() == Opcodes.ISTORE
	        && this.booleanTestabilityTransformation.isBooleanVariable(varNode.var, mn)) {

		// Check if ICONST_0 or ICONST_1 are on the stack
		ControlDependenceGraph cdg = GraphPool.getInstance(this.booleanTestabilityTransformation.classLoader).getCDG(this.booleanTestabilityTransformation.className.replace("/",
		                                                                                                                    "."),
		                                                                                                  mn.name
		                                                                                                          + mn.desc);
		int index = mn.instructions.indexOf(varNode);
		BytecodeInstruction insn = BytecodeInstructionPool.getInstance(this.booleanTestabilityTransformation.classLoader).getInstruction(this.booleanTestabilityTransformation.className.replace("/",
		                                                                                                                                        "."),
		                                                                                                                      mn.name
		                                                                                                                              + mn.desc,
		                                                                                                                      index);
		//varNode);
		if (insn == null) {
			// TODO: Debug this on org.exolab.jms.net.uri.URI
			BooleanTestabilityTransformation.logger.info("WARNING: Instruction not found!");
			return varNode;
		}
		if (insn.getASMNode().getOpcode() != varNode.getOpcode()) {
			BooleanTestabilityTransformation.logger.info("Found wrong bytecode instruction at this index!");
			insn = BytecodeInstructionPool.getInstance(this.booleanTestabilityTransformation.classLoader).getInstruction(this.booleanTestabilityTransformation.className,
			                                                                                                  mn.name
			                                                                                                          + mn.desc,
			                                                                                                  varNode);
			if (insn == null) {
				// TODO: Debug this on org.exolab.jms.net.uri.URI
				BooleanTestabilityTransformation.logger.info("WARNING: Instruction not found!");
				return varNode;
			}
		}
		Set<ControlDependency> dependencies = insn.getControlDependencies();
		BooleanTestabilityTransformation.logger.info("Found flag assignment: " + insn + ", checking "
		        + dependencies.size() + " control dependencies");

		for (ControlDependency dep : dependencies) {
			if (!addedNodes.contains(dep))
				handleDependency(dep, cdg, mn, varNode, insn);
		}

		// Only do completion if there's only one dependency
		// Not sure how other cases would look like
		/*
						//if (dependencies.size() > 1)
						//	return varNode;
						//else
						if (dependencies.isEmpty())
							return varNode;

						ControlDependency dep = dependencies.iterator().next();
						if (!addedNodes.contains(dep))
							handleDependency(dep, cdg, mn, varNode, insn);
							*/

	}
	return varNode;
}
 
开发者ID:EvoSuite,项目名称:evosuite,代码行数:61,代码来源:ImplicitElseTransformer.java

示例10: getNextIndexFromLoad

import org.objectweb.asm.tree.VarInsnNode; //导入方法依赖的package包/类
@SuppressWarnings("rawtypes")
private static int getNextIndexFromLoad(MethodNode mn) {
	Iterator it = mn.instructions.iterator();
	int index = 0;
	while (it.hasNext()) {
		AbstractInsnNode node = (AbstractInsnNode) it.next();
		if (node instanceof VarInsnNode) {
			VarInsnNode varNode = (VarInsnNode) node;
			int varIndex = varNode.var;
			switch (varNode.getOpcode()) {
			case Opcodes.ALOAD:
			case Opcodes.ILOAD:
			case Opcodes.FLOAD:
			case Opcodes.IALOAD:
			case Opcodes.BALOAD:
			case Opcodes.CALOAD:
			case Opcodes.AALOAD:
			case Opcodes.ASTORE:
			case Opcodes.ISTORE:
			case Opcodes.FSTORE:
			case Opcodes.IASTORE:
			case Opcodes.BASTORE:
			case Opcodes.CASTORE:
			case Opcodes.AASTORE:
				index = Math.max(index, varIndex + 1);
				break;
			case Opcodes.DLOAD:
			case Opcodes.DSTORE:
			case Opcodes.LLOAD:
			case Opcodes.LSTORE:
			case Opcodes.DALOAD:
			case Opcodes.DASTORE:
			case Opcodes.LALOAD:
			case Opcodes.LASTORE:
				index = Math.max(index, varIndex + 2);
				break;
			}
		}
	}

	return index;
}
 
开发者ID:EvoSuite,项目名称:evosuite,代码行数:43,代码来源:ReplaceArithmeticOperator.java


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