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

x33g5p2x  于10个月前 转载在 其他  
字(7.4k)|赞(0)|评价(0)|浏览(28)

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

AbstractInsnNode.accept介绍

[英]Makes the given code visitor visit this instruction.
[中]使给定的代码访问者访问此指令。

代码示例

代码示例来源:origin: jooby-project/jooby

@Override public String toString() {
 Printer printer = new ASMifier();
 TraceMethodVisitor visitor = new TraceMethodVisitor(printer);
 node.accept(visitor);
 return printer.getText().toString();
}

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

String format = "%05d %-" + (method.maxStack + method.maxLocals + 6) + "s|%s";
for (int j = 0; j < method.instructions.size(); ++j) {
  method.instructions.get(j).accept(mv);

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

in.accept(new MethodVisitor(ASM4) {

代码示例来源:origin: apache/groovy

Object insn = method.instructions.get(j);
if (insn instanceof AbstractInsnNode) {
  ((AbstractInsnNode) insn).accept(mv);
} else {
  mv.visitLabel((Label) insn);

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

static void printAnalyzerResult(MethodNode method, Analyzer a, final PrintWriter pw)
    throws IllegalArgumentException, IllegalAccessException {
  Frame[] frames = a.getFrames();
  Textifier t = new Textifier();
  TraceMethodVisitor mv = new TraceMethodVisitor(t);
  String format = "%05d %-" + (method.maxStack + method.maxLocals + 6) + "s|%s";
  for (int j = 0; j < method.instructions.size(); ++j) {
    method.instructions.get(j).accept(mv);
    StringBuffer s = new StringBuffer();
    Frame f = frames[j];
    if (f == null) {
      s.append('?');
    } else {
      for (int k = 0; k < f.getLocals(); ++k) {
        s.append(getShortName(f.getLocal(k).toString()));
      }
      s.append(" : ");
      for (int k = 0; k < f.getStackSize(); ++k) {
        s.append(getShortName(f.getStack(k).toString()));
      }
    }
    pw.printf(format, j, s, buf.get(t)); // mv.text.get(j));
  }
  for (int j = 0; j < method.tryCatchBlocks.size(); ++j) {
    ((TryCatchBlockNode) method.tryCatchBlocks.get(j)).accept(mv);
    pw.print(" " + buf.get(t));
  }
  pw.println();
  pw.flush();
}

代码示例来源:origin: kilim/kilim

bb.getInstruction(bb.startPos).accept(mv);

代码示例来源:origin: konsoletyper/teavm

instructions.get(index).accept(methodVisitor);
stackAfter[index] = stack;
flushInstructions();

代码示例来源:origin: kilim/kilim

private void transformIndyBootstrap(MethodVisitor mv, AbstractInsnNode ain) {
  InvokeDynamicInsnNode indy = (InvokeDynamicInsnNode)ain;
  Object[]bsmArgs = indy.bsmArgs;
  // Is it a lambda conversion
  if (indy.bsm.getOwner().equals("java/lang/invoke/LambdaMetafactory")) {
    Handle lambdaBody = (Handle)bsmArgs[1];
    String desc = lambdaBody.getDesc();
    if (detector.isPausable(lambdaBody.getOwner(), lambdaBody.getName(), desc)) {
      bsmArgs[0] = addFiberType((Type)bsmArgs[0]);
      bsmArgs[1] = new Handle(lambdaBody.getTag(), 
                  lambdaBody.getOwner(), 
                  lambdaBody.getName(), 
                  desc.replace(")", D_FIBER_LAST_ARG),
                  lambdaBody.isInterface());
      bsmArgs[2] = addFiberType((Type)bsmArgs[2]);
    }
  }
  ain.accept(mv);
}

代码示例来源:origin: kilim/kilim

transformIndyBootstrap(mv, ain);
} else {
  ain.accept(mv);

代码示例来源:origin: org.ow2.asm/asm-tree

/**
 * Makes the given visitor visit all the instructions in this list.
 *
 * @param methodVisitor the method visitor that must visit the instructions.
 */
public void accept(final MethodVisitor methodVisitor) {
 AbstractInsnNode currentInsn = firstInsn;
 while (currentInsn != null) {
  currentInsn.accept(methodVisitor);
  currentInsn = currentInsn.nextInsn;
 }
}

代码示例来源:origin: org.ow2.asm/asm-debug-all

/**
 * Makes the given visitor visit all of the instructions in this list.
 * 
 * @param mv
 *            the method visitor that must visit the instructions.
 */
public void accept(final MethodVisitor mv) {
  AbstractInsnNode insn = first;
  while (insn != null) {
    insn.accept(mv);
    insn = insn.next;
  }
}

代码示例来源:origin: junkdog/artemis-odb

private void resetField(FieldDescriptor field) {
    mv.visitVarInsn(ALOAD, 0);
    field.reset.accept(mv);
    mv.visitFieldInsn(PUTFIELD, meta.type.getInternalName(), field.name, field.desc);
  }
}

代码示例来源:origin: net.onedaybeard.artemis/artemis-odb-weaver

private void resetField(FieldDescriptor field) {
    mv.visitVarInsn(ALOAD, 0);
    field.reset.accept(mv);
    mv.visitFieldInsn(PUTFIELD, meta.type.getInternalName(), field.name, field.desc);
  }
}

代码示例来源:origin: org.multiverse/multiverse-instrumentation

public static String toString(AbstractInsnNode insnNode) {
  TraceMethodVisitor asmifier = new TraceMethodVisitor();
  insnNode.accept(asmifier);
  StringBuffer sb = new StringBuffer();
  for (String line : (List<String>) asmifier.getText()) {
    sb.append(line);
  }
  return sb.toString();
}

代码示例来源:origin: Glitchfiend/SereneSeasons

public static void printMethod(MethodNode methodNode, int startIndex, int count)
{
  Iterator<AbstractInsnNode> it = methodNode.instructions.iterator(startIndex);
  LOGGER.info("----- Printing " + methodNode.name + "... -----");
  while (it.hasNext() && (count > 0 || count == -1))
  {
    it.next().accept(methodVisitor);
    StringWriter stringWriter = new StringWriter();
    printer.print(new PrintWriter(stringWriter));
    printer.getText().clear();
    LOGGER.info(stringWriter.toString().replace("\n", ""));
    if (count != -1)
      count--;
  }
  LOGGER.info("----- Finished! -----");
}

代码示例来源:origin: Vazkii/Quark

private static String getNodeString(AbstractInsnNode node) {
  Printer printer = new Textifier();
  TraceMethodVisitor visitor = new TraceMethodVisitor(printer);
  node.accept(visitor);
  StringWriter sw = new StringWriter();
  printer.print(new PrintWriter(sw));
  printer.getText().clear();
  return sw.toString().replaceAll("\n", "").trim();
}

代码示例来源:origin: org.apache.drill.exec/drill-java-exec

@Override
public void accept(final MethodVisitor mv) {
 currentInsn = inner.getFirst();
 while (currentInsn != null) {
   currentFrame = frames[index];
   nextFrame = index + 1 < frames.length ? frames[index + 1] : null;
   currentInsn.accept(mv);
   currentInsn = currentInsn.getNext();
   index++;
 }
}

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

@Override
public void accept(final MethodNode methodNode,
    final MethodVisitor methodVisitor) {
  methodVisitor.visitCode();
  for (final TryCatchBlockNode n : methodNode.tryCatchBlocks) {
    n.accept(methodVisitor);
  }
  currentNode = methodNode.instructions.getFirst();
  while (currentNode != null) {
    currentNode.accept(methodVisitor);
    currentNode = currentNode.getNext();
  }
  methodVisitor.visitEnd();
}

代码示例来源:origin: com.github.bingoohuang/blackcat-instrument

public static void viewByteCode(byte[] bytecode) {
    ClassReader cr = new ClassReader(bytecode);
    ClassNode cn = new ClassNode();
    cr.accept(cn, 0);
    final List<MethodNode> mns = cn.methods;
    Printer printer = new Textifier();
    TraceMethodVisitor mp = new TraceMethodVisitor(printer);
    for (MethodNode mn : mns) {
      InsnList inList = mn.instructions;
      System.out.println(mn.name);
      for (int i = 0; i < inList.size(); i++) {
        inList.get(i).accept(mp);
        StringWriter sw = new StringWriter();
        printer.print(new PrintWriter(sw));
        printer.getText().clear();
        System.out.print(sw.toString());
      }
    }
  }
}

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

private void emitNewAndDup(MethodVisitor mv, Frame frame, int stackIndex, MethodInsnNode min) {
  int arguments = frame.getStackSize() - stackIndex - 1;
  int neededLocals = 0;
  for (int i = arguments; i >= 1; i--) {
    BasicValue v = (BasicValue) frame.getStack(stackIndex + i);
    mv.visitVarInsn(v.getType().getOpcode(Opcodes.ISTORE), lvarStack + 1 + neededLocals);
    neededLocals += v.getSize();
  }
  db.log(LogLevel.DEBUG, "Inserting NEW & DUP for constructor call %s%s with %d arguments (%d locals)", min.owner, min.desc, arguments, neededLocals);
  if (additionalLocals < neededLocals) {
    additionalLocals = neededLocals;
  }
  ((NewValue) frame.getStack(stackIndex - 1)).insn.accept(mv);
  ((NewValue) frame.getStack(stackIndex)).insn.accept(mv);
  for (int i = 1; i <= arguments; i++) {
    BasicValue v = (BasicValue) frame.getStack(stackIndex + i);
    neededLocals -= v.getSize();
    mv.visitVarInsn(v.getType().getOpcode(Opcodes.ILOAD), lvarStack + 1 + neededLocals);
  }
}

相关文章