當前位置: 首頁>>代碼示例>>Java>>正文


Java Textifier.print方法代碼示例

本文整理匯總了Java中org.objectweb.asm.util.Textifier.print方法的典型用法代碼示例。如果您正苦於以下問題:Java Textifier.print方法的具體用法?Java Textifier.print怎麽用?Java Textifier.print使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.objectweb.asm.util.Textifier的用法示例。


在下文中一共展示了Textifier.print方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: dump

import org.objectweb.asm.util.Textifier; //導入方法依賴的package包/類
private static void dump(MethodNode method) {
	Textifier textifier = new Textifier();
	method.accept(new TraceMethodVisitor(textifier));

	StringWriter writer = new StringWriter();

	try (PrintWriter pw = new PrintWriter(writer)) {
		textifier.print(pw);
	}

	System.out.println(writer.toString());
}
 
開發者ID:sfPlayer1,項目名稱:Matcher,代碼行數:13,代碼來源:Analysis.java

示例2: toString

import org.objectweb.asm.util.Textifier; //導入方法依賴的package包/類
/** compiles to bytecode, and returns debugging output */
static String toString(Class<?> iface, String source, CompilerSettings settings) {
    StringWriter output = new StringWriter();
    PrintWriter outputWriter = new PrintWriter(output);
    Textifier textifier = new Textifier();
    try {
        Compiler.compile(iface, "<debugging>", source, settings, textifier);
    } catch (Exception e) {
        textifier.print(outputWriter);
        e.addSuppressed(new Exception("current bytecode: \n" + output));
        IOUtils.reThrowUnchecked(e);
        throw new AssertionError();
    }
    
    textifier.print(outputWriter);
    return output.toString();
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:18,代碼來源:Debugger.java

示例3: visitEnd

import org.objectweb.asm.util.Textifier; //導入方法依賴的package包/類
@Override
public void visitEnd() {
  try {
    accept(inner);
    super.visitEnd();
  } catch(Exception e){
    Textifier t = new Textifier();
    accept(new TraceMethodVisitor(t));
    StringBuilderWriter sw = new StringBuilderWriter();
    PrintWriter pw = new PrintWriter(sw);
    t.print(pw);
    pw.flush();
    String bytecode = sw.getBuilder().toString();
    logger.error(String.format("Failure while rendering method %s, %s, %s.  ByteCode:\n %s", name, desc, signature, bytecode), e);
    throw new RuntimeException(String.format("Failure while rendering method %s, %s, %s.  ByteCode:\n %s", name, desc, signature, bytecode), e);
  }
}
 
開發者ID:skhalifa,項目名稱:QDrill,代碼行數:18,代碼來源:ValueHolderReplacementVisitor.java

示例4: trace

import org.objectweb.asm.util.Textifier; //導入方法依賴的package包/類
/** Returns a human readable string for the code that this {@link BytecodeProducer} generates. */
public final String trace() {
  // TODO(lukes): textifier has support for custom label names by overriding appendLabel.
  // Consider trying to make use of (using the Label.info field? adding a custom NamedLabel
  // sub type?)
  Textifier textifier =
      new Textifier(Opcodes.ASM6) {
        {
          // reset tab sizes.  Since we don't care about formatting class names or method
          // signatures (only code). We only need to set the tab2,tab3 and ltab settings (tab is
          // for class members).
          this.tab = null; // trigger an error if used.
          this.tab2 = "  "; // tab setting for instructions
          this.tab3 = ""; // tab setting for switch cases
          this.ltab = ""; // tab setting for labels
        }
      };
  gen(new CodeBuilder(new TraceMethodVisitor(textifier), 0, "trace", "()V"));
  StringWriter writer = new StringWriter();
  textifier.print(new PrintWriter(writer));
  return writer.toString(); // Note textifier always adds a trailing newline
}
 
開發者ID:google,項目名稱:closure-templates,代碼行數:23,代碼來源:BytecodeProducer.java

示例5: toString

import org.objectweb.asm.util.Textifier; //導入方法依賴的package包/類
public String toString() {
    Textifier t = new Textifier();
    accept(new TraceMethodVisitor(t));
    StringWriter sw = new StringWriter();
    t.print(new PrintWriter(sw));
    return sw.toString();
}
 
開發者ID:4Space,項目名稱:4Space-5,代碼行數:8,代碼來源:InsnListSection.java

示例6: print

import org.objectweb.asm.util.Textifier; //導入方法依賴的package包/類
/**
 * Prints an individual method behavior. [debugging]
 * 
 * @param node the node to print
 * 
 * @since 1.00
 */
public static void print(MethodNode node) {
    Textifier tf = new Textifier();
    node.accept(new TraceMethodVisitor(tf));
    PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out));
    tf.print(pw);
    pw.flush();
}
 
開發者ID:SSEHUB,項目名稱:spassMeter,代碼行數:15,代碼來源:Utils.java

示例7: visitMethod

import org.objectweb.asm.util.Textifier; //導入方法依賴的package包/類
@Override
public MethodVisitor visitMethod(final int access, final String name,
    final String desc, final String signature, final String[] exceptions)
{
    // Unused?
    /*
    final MethodVisitor mv = super.visitMethod(access, name, desc,
        signature, exceptions);
    */

    return new MethodNode(Opcodes.ASM5, access, name, desc, signature,
        exceptions)
    {
        @Override
        public void visitEnd()
        {
            super.visitEnd();

            try {
                final BasicInterpreter basicInterpreter
                    = new BasicInterpreter();
                final Analyzer<BasicValue> analyzer
                    = new Analyzer<>(basicInterpreter);
                final AbstractInsnNode[] nodes = instructions.toArray();
                final Frame<BasicValue>[] frames
                    = analyzer.analyze(className, this);
                int areturn = -1;
                for (int i = nodes.length -1; i >= 0; i--)
                {
                    if (nodes[i].getOpcode() == Opcodes.ARETURN) {
                        areturn = i;
                        System.out.println(className + "." + name + desc);
                        System.out.println("Found areturn at: " + i);
                    } else if (areturn != -1
                        && nodes[i].getOpcode() != -1
                        && frames[i].getStackSize() == 0) {
                        System.out.println("Found start of block at: " + i);

                        final InsnList list = new InsnList();
                        for (int j = i; j <= areturn; j++)
                            list.add(nodes[j]);
                        final Textifier textifier = new Textifier();
                        final PrintWriter pw = new PrintWriter(System.out);
                        list.accept(new TraceMethodVisitor(textifier));
                        textifier.print(pw);
                        pw.flush();
                        System.out.println("\n\n");
                        areturn = -1;
                    }
                }
            }
            catch (AnalyzerException e) {
                e.printStackTrace();
            }

            if (mv != null)
                accept(mv);
        }
    };
}
 
開發者ID:fge,項目名稱:grappa,代碼行數:61,代碼來源:ClassVisitorExample.java


注:本文中的org.objectweb.asm.util.Textifier.print方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。