當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。