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


Java IincInsnNode类代码示例

本文整理汇总了Java中org.objectweb.asm.tree.IincInsnNode的典型用法代码示例。如果您正苦于以下问题:Java IincInsnNode类的具体用法?Java IincInsnNode怎么用?Java IincInsnNode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: insnEqual

import org.objectweb.asm.tree.IincInsnNode; //导入依赖的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;
	}
}
 
开发者ID:roryclaasen,项目名称:RorysMod,代码行数:27,代码来源:InstructionComparator.java

示例2: handle

import org.objectweb.asm.tree.IincInsnNode; //导入依赖的package包/类
@Override
public void handle(AbstractInsnNode node) throws IncorrectNodeException {
	super.handle(node);
	LOG.debug(logNode(node));
	checkType(node, IincInsnNode.class);

	ExpressionStack stack = mState.getActiveStack();
	LocalVariable variable = mState.getLocalVariable(((IincInsnNode) node).var);
	
	UnaryExpression.OpPosition opPosition = getUnaryOperandPosition(node);
	if (opPosition != null) {
		stack.push(new UnaryExpression(node.getOpcode(), variable, DataType.INT, opPosition));
	} else {
		stack.push(new AssignmentExpression(node.getOpcode(), new LeftHandSide(node.getOpcode(), variable),
				new PrimaryExpression(node.getOpcode(), ((IincInsnNode) node).incr, DataType.INT)));
	}
}
 
开发者ID:JozefCeluch,项目名称:thesis-disassembler,代码行数:18,代码来源:IincInsnNodeHandler.java

示例3: insnEqual

import org.objectweb.asm.tree.IincInsnNode; //导入依赖的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;
	}
}
 
开发者ID:NOVA-Team,项目名称:NOVA-Core,代码行数:25,代码来源:InstructionComparator.java

示例4: localVarValue

import org.objectweb.asm.tree.IincInsnNode; //导入依赖的package包/类
private InsnList localVarValue(AbstractInsnNode insnNode, int opositeOpcode, String param) {
	int varIdx = -1;
	if (insnNode instanceof VarInsnNode) {
		varIdx = ((VarInsnNode) insnNode).var;
	} else if (insnNode instanceof IincInsnNode) {
		varIdx = ((IincInsnNode) insnNode).var;
	} else {
		throw new RuntimeException("Not implemented for type " + insnNode.getClass());
	}
	InsnList instrumentation = new InsnList();
	MethodNode methodNode = (MethodNode) mv;
	if (methodNode.localVariables.size() <= varIdx) {
		throw new RuntimeException("varInsnNode is pointing outside of local variables!");
	}
	LocalVariableNode localVariableNode = getLocalVariableNode(varIdx, insnNode, methodNode);
	instrumentation.add(new VarInsnNode(opositeOpcode, varIdx));
	instrumentation.add(new LdcInsnNode(localVariableNode.name));
	instrumentation.add(new LdcInsnNode(currentLine));
	instrumentation.add(new MethodInsnNode(Opcodes.INVOKESTATIC,
			"org/evosuite/junit/TestRuntimeValuesDeterminer", "localVarValueChanged", "(" + param
					+ "Ljava/lang/String;I)V"));
	logger.debug("Adding localVarValueChanged for var {} in line {}.", localVariableNode.name, currentLine);
	return instrumentation;
}
 
开发者ID:EvoSuite,项目名称:evosuite,代码行数:25,代码来源:TestRuntimeValuesDeterminer.java

示例5: insnEqual

import org.objectweb.asm.tree.IincInsnNode; //导入依赖的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;
    }
}
 
开发者ID:Chicken-Bones,项目名称:CCObfuscator,代码行数:26,代码来源:InstructionComparator.java

示例6: toForLoop

import org.objectweb.asm.tree.IincInsnNode; //导入依赖的package包/类
/**
 * To for loop.
 * 
 * @param loop
 *          the loop
 * @return the for loop
 */
public static ForLoop toForLoop(final Loop loop) {
  if (loop == null) {
    return null;
  }
  
  if (!loop.isPlain()) {
    return null;
  }
  
  final VarInsnNode varNode = (VarInsnNode) loop.getCounter();
  final AbstractInsnNode endValue = loop.getEndValue();
  final JumpInsnNode ifNode = (JumpInsnNode) loop.getIfNode();
  final IincInsnNode iInc = (IincInsnNode) loop.getIInc();
  final ForLoopFooter footer = new ForLoopFooter(varNode, endValue, ifNode, iInc);
  
  final ForLoopBody body = new ForLoopBody(loop.getBody());
  final Number start = NodeHelper.getNumberValue(loop.getStartValue());
  
  final ForLoop forLoop = new ForLoop(body, footer, start);
  
  return forLoop;
  
}
 
开发者ID:tookar,项目名称:jBOP,代码行数:31,代码来源:LoopMatcher.java

示例7: getStoreOfLoopForIf

import org.objectweb.asm.tree.IincInsnNode; //导入依赖的package包/类
private static AbstractInsnNode getStoreOfLoopForIf(final AbstractInsnNode node) {
  if (node == null) {
    return null;
  }
  
  if (!NodeHelper.isIf(node)) {
    return null;
  }
  final AbstractInsnNode previous = ((JumpInsnNode) node).label.getPrevious();
  if (!NodeHelper.isGoto(previous)) {
    return null;
  }
  
  final AbstractInsnNode previous2 = previous.getPrevious();
  if (previous2 instanceof IincInsnNode) {
    return ((JumpInsnNode) previous).label.getPrevious();
  }
  return previous2;
}
 
开发者ID:tookar,项目名称:jBOP,代码行数:20,代码来源:LoopMatcher.java

示例8: getStoreOfLoopForIInc

import org.objectweb.asm.tree.IincInsnNode; //导入依赖的package包/类
private static AbstractInsnNode getStoreOfLoopForIInc(final AbstractInsnNode node) {
  if (node == null) {
    return null;
  }
  
  if (!(node instanceof IincInsnNode)) {
    return null;
  }
  final AbstractInsnNode next = node.getNext();
  if (NodeHelper.isGoto(next)) {
    return ((JumpInsnNode) next).label.getPrevious();
  }
  if (next instanceof LabelNode) {
    final AbstractInsnNode gotoNode = findGotoForLabel(next, true);
    if (gotoNode == null) {
      return null;
    }
    return gotoNode.getPrevious();
  }
  
  return null;
}
 
开发者ID:tookar,项目名称:jBOP,代码行数:23,代码来源:LoopMatcher.java

示例9: getLoopBounds

import org.objectweb.asm.tree.IincInsnNode; //导入依赖的package包/类
/**
 * Gets the loop bounds.
 * 
 * @param currentNode
 *          the current node
 * @return the loop bounds
 */
public static Pair<AbstractInsnNode, AbstractInsnNode> getLoopBounds(final AbstractInsnNode currentNode) {
  final AbstractInsnNode storeOfLoop;
  if (NodeHelper.isGoto(currentNode)) {
    storeOfLoop = getStoreOfLoopForGoto(currentNode);
  } else if (NodeHelper.isIf(currentNode)) {
    storeOfLoop = getStoreOfLoopForIf(currentNode);
  } else if (currentNode instanceof IincInsnNode) {
    storeOfLoop = getStoreOfLoopForIInc(currentNode);
  } else {
    storeOfLoop = currentNode;
  }
  final Loop loop = getLoop(storeOfLoop);
  if (loop == null) {
    return null;
  }
  return Pair.of(loop.getCounter().getPrevious(), loop.getEndOfLoop());
  
}
 
开发者ID:tookar,项目名称:jBOP,代码行数:26,代码来源:LoopMatcher.java

示例10: add

import org.objectweb.asm.tree.IincInsnNode; //导入依赖的package包/类
/**
 * Adds the given operation.
 * 
 * @param opcode
 *          the opcode
 * @param args
 *          the args
 * @return the class node builder
 */
public ClassNodeBuilder add(final int opcode, final Object... args) {
  if (opcode == IINC) {
    return addInsn(new IincInsnNode((Integer) args[0], (Integer) args[1]));
  }
  if (opcode >= NOP && opcode <= DCONST_1 || opcode >= POP && opcode <= DCMPG || opcode >= IALOAD && opcode <= SALOAD
      || opcode >= IASTORE && opcode <= SASTORE || opcode == ARRAYLENGTH || opcode == ATHROW) {
    return addInsn(new InsnNode(opcode));
  }
  if (opcode >= BIPUSH && opcode <= SIPUSH || opcode == NEWARRAY) {
    return addInsn(new IntInsnNode(opcode, (Integer) args[0]));
  }
  if (opcode == LDC) {
    return loadConstant(args[0]);
  }
  if (opcode >= ILOAD && opcode <= ALOAD) {
    return addInsn(new VarInsnNode(opcode, (Integer) args[0]));
  }
  if (opcode >= ISTORE && opcode <= ASTORE) {
    return addInsn(new VarInsnNode(opcode, (Integer) args[0]));
  }
  if (opcode >= IFEQ && opcode <= JSR) {
    return jump(opcode, (LabelNode) args[0]);
  }
  return this;
}
 
开发者ID:tookar,项目名称:jBOP,代码行数:35,代码来源:ClassNodeBuilder.java

示例11: testLocalVarInlinerIInc

import org.objectweb.asm.tree.IincInsnNode; //导入依赖的package包/类
/**
 * Tests that LocalVarInliner is working correctly.
 * There is a single (direct) store to the var, but
 * the var is altered via a iinc instruction. Therefore
 * the load of the variable is not replaced.
 */
@Test
public void testLocalVarInlinerIInc() {
  // INIT
  builder.addInsn(new InsnNode(ICONST_0)).//
      addInsn(new VarInsnNode(ISTORE, 1)).//
      addInsn(new IincInsnNode(1, 1)).//
      addInsn(new VarInsnNode(ILOAD, 1)).//
      addInsn(new InsnNode(IRETURN));//
  
  // RUN
  assertEquals(5, methodNode.instructions.size());
  final InsnList optimized = optimizer.optimize(methodNode.instructions, methodNode);
  
  // ASSERT
  assertEquals(5, optimized.size());
  assertTrue(optimizer.isOptimized());
  assertEquals(ICONST_1, optimized.get(3).getOpcode());
}
 
开发者ID:tookar,项目名称:jBOP,代码行数:25,代码来源:LocalVarInlinerTest.java

示例12: matchInstruction

import org.objectweb.asm.tree.IincInsnNode; //导入依赖的package包/类
public static boolean matchInstruction(AbstractInsnNode ain, AbstractInsnNode ain2) {
	if (ain.getOpcode() != ain2.getOpcode()) return false;
	if (ain instanceof InsnNode) {
		return true;
	} else if (ain instanceof VarInsnNode) {
		return ((VarInsnNode)ain).var == ((VarInsnNode)ain2).var;
	} else if (ain instanceof LdcInsnNode) {
		return ((LdcInsnNode)ain).cst.equals(((LdcInsnNode)ain2).cst);
	} else if (ain instanceof IntInsnNode) {
		return ((IntInsnNode)ain).operand == ((IntInsnNode)ain2).operand;
	} else if (ain instanceof TypeInsnNode) {
		return ((TypeInsnNode)ain).desc.equals(((TypeInsnNode)ain2).desc);
	} else if (ain instanceof FieldInsnNode) {
		FieldInsnNode fin = (FieldInsnNode)ain;
		FieldInsnNode fin2 = (FieldInsnNode)ain2;
		return fin.owner.equals(fin2.owner) && fin.name.equals(fin2.name) && fin.desc.equals(fin2.desc);
	} else if (ain instanceof MethodInsnNode) {
		MethodInsnNode min = (MethodInsnNode)ain;
		MethodInsnNode min2 = (MethodInsnNode)ain2;
		return min.owner.equals(min2.owner) && min.name.equals(min2.name) && min.desc.equals(min2.desc) && min.itf == min2.itf;
	} else if (ain instanceof JumpInsnNode) {
		return ((JumpInsnNode)ain).label == ((JumpInsnNode)ain2).label;
	} else if (ain instanceof IincInsnNode) {
		IincInsnNode iin = (IincInsnNode)ain;
		IincInsnNode iin2 = (IincInsnNode)ain2;
		return iin.var == iin2.var && iin.incr == iin2.incr;
	}
	return false;
}
 
开发者ID:Techjar,项目名称:VivecraftForgeExtensions,代码行数:30,代码来源:ASMUtil.java

示例13: convertIincInsn

import org.objectweb.asm.tree.IincInsnNode; //导入依赖的package包/类
private void convertIincInsn(IincInsnNode insn) {
	Local local = getLocal(insn.var);
	assignReadOps(local);
	if (!units.containsKey(insn)) {
		AddExpr add = Jimple.v().newAddExpr(local, IntConstant.v(insn.incr));
		setUnit(insn, Jimple.v().newAssignStmt(local, add));
	}
}
 
开发者ID:flankerhqd,项目名称:JAADAS,代码行数:9,代码来源:AsmMethodSource.java

示例14: areInsnsEqual

import org.objectweb.asm.tree.IincInsnNode; //导入依赖的package包/类
/**
 * Respects {@link #INT_WILDCARD} and {@link #WILDCARD} instruction properties.
 * Always returns true if {@code a} and {@code b} are label, line number, or frame instructions.
 * 
 * @return Whether or not the given instructions are equivalent.
 */
public boolean areInsnsEqual(AbstractInsnNode a, AbstractInsnNode b)
{
	if (a == b)
		return true;

	if (a == null || b == null)
		return false;

	if (a.equals(b))
		return true;

	if (a.getOpcode() != b.getOpcode())
		return false;

	switch (a.getType())
	{
		case AbstractInsnNode.VAR_INSN:
			return areVarInsnsEqual((VarInsnNode) a, (VarInsnNode) b);
		case AbstractInsnNode.TYPE_INSN:
			return areTypeInsnsEqual((TypeInsnNode) a, (TypeInsnNode) b);
		case AbstractInsnNode.FIELD_INSN:
			return areFieldInsnsEqual((FieldInsnNode) a, (FieldInsnNode) b);
		case AbstractInsnNode.METHOD_INSN:
			return areMethodInsnsEqual((MethodInsnNode) a, (MethodInsnNode) b);
		case AbstractInsnNode.LDC_INSN:
			return areLdcInsnsEqual((LdcInsnNode) a, (LdcInsnNode) b);
		case AbstractInsnNode.IINC_INSN:
			return areIincInsnsEqual((IincInsnNode) a, (IincInsnNode) b);
		case AbstractInsnNode.INT_INSN:
			return areIntInsnsEqual((IntInsnNode) a, (IntInsnNode) b);
		default:
			return true;
	}
}
 
开发者ID:Deadrik,项目名称:TFC2,代码行数:41,代码来源:InsnComparator.java

示例15: getLocalVariableSlot

import org.objectweb.asm.tree.IincInsnNode; //导入依赖的package包/类
/**
 * <p>
 * getLocalVar
 * </p>
 * 
 * @return a int.
 */
public int getLocalVariableSlot() {
	if (asmNode instanceof VarInsnNode)
		return ((VarInsnNode) asmNode).var;
	else if (asmNode instanceof IincInsnNode)
		return ((IincInsnNode) asmNode).var;
	else
		return -1;
}
 
开发者ID:EvoSuite,项目名称:evosuite,代码行数:16,代码来源:ASMWrapper.java


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