org.objectweb.asm.tree.AbstractInsnNode.getType()方法的使用及代码示例

x33g5p2x  于11个月前 转载在 其他  
字(6.8k)|赞(0)|评价(0)|浏览(37)

本文整理了Java中org.objectweb.asm.tree.AbstractInsnNode.getType()方法的一些代码示例,展示了AbstractInsnNode.getType()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AbstractInsnNode.getType()方法的具体详情如下:
包路径:org.objectweb.asm.tree.AbstractInsnNode
类名称:AbstractInsnNode
方法名:getType

AbstractInsnNode.getType介绍

[英]Returns the type of this instruction.
[中]返回此指令的类型。

代码示例

代码示例来源:origin: pxb1988/dex2jar

@Override
  public void execute(AbstractInsnNode insn, Interpreter<JvmValue> interpreter) throws AnalyzerException {
    if (insn.getType() == AbstractInsnNode.FRAME || insn.getType() == AbstractInsnNode.LINE || insn.getType() == AbstractInsnNode.LABEL) {
      return;
    }
    if (insn.getOpcode() == Opcodes.RETURN) {
      interpreter.returnOperation(insn, null, null);
    } else if (insn.getOpcode() == Opcodes.GOTO) {
      interpreter.unaryOperation(insn, null);
    } else if (insn.getOpcode() == RET) {
      throw new RuntimeException("not support yet!");
    } else {
      super.execute(insn, interpreter);
    }
  }
}

代码示例来源:origin: Meituan-Dianping/Robust

public byte[] transformCode(byte[] b1, String className) throws IOException {
  ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS);
  ClassReader cr = new ClassReader(b1);
  ClassNode classNode = new ClassNode();
  Map<String, Boolean> methodInstructionTypeMap = new HashMap<>();
  cr.accept(classNode, 0);
  final List<MethodNode> methods = classNode.methods;
  for (MethodNode m : methods) {
    InsnList inList = m.instructions;
    boolean isMethodInvoke = false;
    for (int i = 0; i < inList.size(); i++) {
      if (inList.get(i).getType() == AbstractInsnNode.METHOD_INSN) {
        isMethodInvoke = true;
      }
    }
    methodInstructionTypeMap.put(m.name + m.desc, isMethodInvoke);
  }
  InsertMethodBodyAdapter insertMethodBodyAdapter = new InsertMethodBodyAdapter(cw, className, methodInstructionTypeMap);
  cr.accept(insertMethodBodyAdapter, ClassReader.EXPAND_FRAMES);
  return cw.toByteArray();
}

代码示例来源:origin: pxb1988/dex2jar

private void cleanDebug(MethodNode mn) {
  for (AbstractInsnNode p = mn.instructions.getFirst(); p != null; ) {
    if (p.getType() == AbstractInsnNode.LINE) {
      AbstractInsnNode q = p.getNext();
      mn.instructions.remove(p);
      p = q;
    } else {
      p = p.getNext();
    }
  }
  mn.localVariables = null;
}

代码示例来源:origin: pxb1988/dex2jar

if (in.getType() != AbstractInsnNode.LINE && in.getType() != AbstractInsnNode.FRAME) {
  if(in.getType()==AbstractInsnNode.LABEL){
    pw.print("  ");
  }else {

代码示例来源:origin: pxb1988/dex2jar

setCurrentEmit(index);
if (p.getType() == AbstractInsnNode.LABEL) {
  emit(getLabel((LabelNode) p));
  if (handlers.get(index)) {
if (p.getType() == AbstractInsnNode.JUMP_INSN) {
  JumpInsnNode jump = (JumpInsnNode) p;
  stack.push(jump.label);

代码示例来源:origin: pxb1988/dex2jar

if (p.getType() == AbstractInsnNode.LABEL) {
  stmts.add(getLabel((LabelNode) p));

代码示例来源:origin: Sable/soot

edge.stack = null;
do {
 int type = insn.getType();
 if (type == FIELD_INSN) {
  convertFieldInsn((FieldInsnNode) insn);

代码示例来源:origin: pxb1988/dex2jar

private void initParentCount(int[] parentCount) {
  parentCount[0] = 1;
  for (AbstractInsnNode p = insnList.getFirst(); p != null; p = p.getNext()) {
    if (p.getType() == AbstractInsnNode.JUMP_INSN) {
      JumpInsnNode jump = (JumpInsnNode) p;
      parentCount[insnList.indexOf(jump.label)]++;

代码示例来源:origin: fge/grappa

private static boolean isLabelOrJump(final AbstractInsnNode node)
{
  return node.getType() == AbstractInsnNode.LABEL
    || node.getType() == AbstractInsnNode.JUMP_INSN;
}

代码示例来源:origin: stackoverflow.com

// Assuming you have loaded classNode
for (MethodNode method : classNode.methods){
  for (AbstractInsnNode ain : method.instructions.toArray()) {
    if (ain.getType() == AbstractInsnNode.FIELD_INSN) {
      FieldInsnNode fin = (FieldInsnNode) ain;
      //fin.name = Field name
      //fin.owner = ClassNode's name
    }
  }
}

代码示例来源:origin: co.paralleluniverse/quasar

@Override
public int getType() {
  return orgInsn.getType();
}

代码示例来源:origin: EvoSuite/evosuite

/**
 * <p>
 * getType
 * </p>
 * 
 * @return a {@link java.lang.String} object.
 */
public String getType() {
  // TODO explain
  String type = "";
  if (asmNode.getType() >= 0 && asmNode.getType() < Printer.TYPES.length)
    type = Printer.TYPES[asmNode.getType()];
  return type;
}

代码示例来源:origin: org.jacoco/org.jacoco.core

private static AbstractInsnNode next(AbstractInsnNode i) {
  do {
    i = i.getNext();
  } while (i != null && (AbstractInsnNode.FRAME == i.getType()
      || AbstractInsnNode.LABEL == i.getType()
      || AbstractInsnNode.LINE == i.getType()));
  return i;
}

代码示例来源:origin: org.jacoco/org.jacoco.core

/**
 * Returns first instruction from given and following it that is not
 * {@link AbstractInsnNode#FRAME}, {@link AbstractInsnNode#LABEL},
 * {@link AbstractInsnNode#LINE}.
 */
static AbstractInsnNode skipNonOpcodes(AbstractInsnNode cursor) {
  while (cursor != null && (cursor.getType() == AbstractInsnNode.FRAME
      || cursor.getType() == AbstractInsnNode.LABEL
      || cursor.getType() == AbstractInsnNode.LINE)) {
    cursor = cursor.getNext();
  }
  return cursor;
}

代码示例来源:origin: joshiejack/Mariculture

public static AbstractInsnNode getFirstInstruction(AbstractInsnNode insn)  {
  for (AbstractInsnNode instruction = insn; instruction != null; instruction = instruction.getNext())  {
    if (instruction.getType() != AbstractInsnNode.LABEL && instruction.getType() != AbstractInsnNode.LINE) {
      return instruction;
    }
  }
  return null;
}

代码示例来源:origin: org.parboiled/parboiled-java

public void newControlFlowEdge(int instructionIndex, int successorIndex) {
  AbstractInsnNode fromInsn = method.instructions.get(instructionIndex);
  AbstractInsnNode toInsn = method.instructions.get(successorIndex);
  if (fromInsn.getType() == AbstractInsnNode.LABEL || fromInsn.getType() == AbstractInsnNode.JUMP_INSN ||
      toInsn.getType() == AbstractInsnNode.LABEL || toInsn.getType() == AbstractInsnNode.JUMP_INSN) {
    additionalEdges.add(new Edge(fromInsn, toInsn));
  }
}

代码示例来源:origin: squeek502/VeganOption

public AbstractInsnNode getOrFindInstruction(AbstractInsnNode firstInsnToCheck, boolean reverseDirection)
{
  for (AbstractInsnNode instruction = firstInsnToCheck; instruction != null; instruction = reverseDirection ? instruction.getPrevious() : instruction.getNext())
  {
    if (instruction.getType() != AbstractInsnNode.LABEL && instruction.getType() != AbstractInsnNode.LINE)
      return instruction;
  }
  return null;
}

代码示例来源:origin: org.lwjgl.lwjgl/lwjgl_util

static String getOpcodeName(final AbstractInsnNode insn) {
  final String op = OPCODE_TO_NAME.get(insn.getOpcode());
  return INSNTYPE_TO_NAME.get(insn.getType()) + ": " + insn.getOpcode() + (op == null ? "" : " [" + OPCODE_TO_NAME.get(insn.getOpcode()) + "]");
}

代码示例来源:origin: org.jacoco/org.jacoco.core

private boolean hasLineNumber(final MethodNode methodNode) {
  for (AbstractInsnNode i = methodNode.instructions
      .getFirst(); i != null; i = i.getNext()) {
    if (AbstractInsnNode.LINE == i.getType()) {
      return true;
    }
  }
  return false;
}

代码示例来源:origin: org.parboiled/parboiled-java

@SuppressWarnings({"SuspiciousMethodCalls"})
public void process(ParserClassNode classNode, RuleMethod method) throws Exception {
  checkArgNotNull(classNode, "classNode");
  checkArgNotNull(method, "method");
  AbstractInsnNode current = method.instructions.getFirst();
  while (current != null) {
    AbstractInsnNode next = current.getNext();
    if (current.getType() == AbstractInsnNode.LABEL && !method.getUsedLabels().contains(current)) {
      method.instructions.remove(current);
    }
    current = next;
  }
}

相关文章