Пример #1
0
  static void printAnalyzerResult(MethodNode method, Analyzer a, final PrintWriter pw) {
    Frame[] frames = a.getFrames();
    TraceMethodVisitor mv = new TraceMethodVisitor();

    pw.println(method.name + method.desc);
    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())).append(' ');
        }
        s.append(" : ");
        for (int k = 0; k < f.getStackSize(); ++k) {
          s.append(getShortName(f.getStack(k).toString())).append(' ');
        }
      }
      while (s.length() < method.maxStack + method.maxLocals + 1) {
        s.append(' ');
      }
      pw.print(Integer.toString(j + 100000).substring(1));
      pw.print(" " + s + " : " + mv.buf); // mv.text.get(j));
    }
    for (int j = 0; j < method.tryCatchBlocks.size(); ++j) {
      ((TryCatchBlockNode) method.tryCatchBlocks.get(j)).accept(mv);
      pw.print(" " + mv.buf);
    }
    pw.println();
  }