FileDocCategorySizeDatePackage
TraceCodeVisitor.javaAPI DocGlassfish v2 API8959Thu Mar 02 11:51:18 GMT 2006oracle.toplink.libraries.asm.util

TraceCodeVisitor

public class TraceCodeVisitor extends PrintCodeVisitor
A {@link PrintCodeVisitor PrintCodeVisitor} that prints a disassembled view of the code it visits.
author
Eric Bruneton

Fields Summary
protected final CodeVisitor
cv
The {@link CodeVisitor CodeVisitor} to which this visitor delegates calls. May be null.
private final HashMap
labelNames
The label names. This map associate String values to Label keys.
Constructors Summary
public TraceCodeVisitor(CodeVisitor cv)
Constructs a new {@link TraceCodeVisitor TraceCodeVisitor} object.

param
cv the code visitor to which this adapter must delegate calls. May be null.

    this.cv = cv;
    this.labelNames = new HashMap();
  
Methods Summary
private voidappendLabel(oracle.toplink.libraries.asm.Label l)
Appends the name of the given label to {@link #buf buf}. Creates a new label name if the given label does not yet have one.

param
l a label.

    String name = (String)labelNames.get(l);
    if (name == null) {
      name = "L" + labelNames.size();
      labelNames.put(l, name);
    }
    buf.append(name);
  
public voidprintAttribute(oracle.toplink.libraries.asm.Attribute attr)

    buf.append("    CODE ATTRIBUTE ").append(attr.type).append(" : ")
      .append(attr.toString()).append("\n");

    if (cv != null) {
      cv.visitAttribute(attr);
    }
  
public voidprintFieldInsn(int opcode, java.lang.String owner, java.lang.String name, java.lang.String desc)

    buf.append("    ")
      .append(OPCODES[opcode])
      .append(" ")
      .append(owner)
      .append(" ")
      .append(name)
      .append(" ")
      .append(desc)
      .append("\n");

    if (cv != null) {
      cv.visitFieldInsn(opcode, owner, name, desc);
    }
  
public voidprintIincInsn(int var, int increment)

    buf.append("    IINC ")
      .append(var)
      .append(" ")
      .append(increment)
      .append("\n");

    if (cv != null) {
      cv.visitIincInsn(var, increment);
    }
  
public voidprintInsn(int opcode)

    buf.append("    ")
      .append(OPCODES[opcode])
      .append("\n");

    if (cv != null) {
      cv.visitInsn(opcode);
    }
  
public voidprintIntInsn(int opcode, int operand)

    buf.append("    ")
      .append(OPCODES[opcode])
      .append(" ").append(operand)
      .append("\n");

    if (cv != null) {
      cv.visitIntInsn(opcode, operand);
    }
  
public voidprintJumpInsn(int opcode, oracle.toplink.libraries.asm.Label label)

    buf.append("    ")
      .append(OPCODES[opcode]).
      append(" ");
    appendLabel(label);
    buf.append("\n");

    if (cv != null) {
      cv.visitJumpInsn(opcode, label);
    }
  
public voidprintLabel(oracle.toplink.libraries.asm.Label label)

    buf.append("   ");
    appendLabel(label);
    // buf.append(":  // ").append(label).append("\n");
    buf.append("\n");

    if (cv != null) {
      cv.visitLabel(label);
    }
  
public voidprintLdcInsn(java.lang.Object cst)

    buf.append("    LDC ");
    if (cst instanceof String) {
      buf.append("\"").append(cst).append("\"");
    } else if (cst instanceof Type) {
      buf.append(((Type)cst).getDescriptor() + ".class");
    } else {
      buf.append(cst);
    }
    buf.append("\n");

    if (cv != null) {
      cv.visitLdcInsn(cst);
    }
  
public voidprintLineNumber(int line, oracle.toplink.libraries.asm.Label start)

    buf.append("    LINENUMBER ")
      .append(line)
      .append(" ");
    appendLabel(start);
    buf.append("\n");

    if (cv != null) {
      cv.visitLineNumber(line, start);
    }
  
public voidprintLocalVariable(java.lang.String name, java.lang.String desc, oracle.toplink.libraries.asm.Label start, oracle.toplink.libraries.asm.Label end, int index)

    buf.append("    LOCALVARIABLE ")
      .append(name)
      .append(" ")
      .append(desc)
      .append(" ");
    appendLabel(start);
    buf.append(" ");
    appendLabel(end);
    buf.append(" ")
      .append(index)
      .append("\n");

    if (cv != null) {
      cv.visitLocalVariable(name, desc, start, end, index);
    }
  
public voidprintLookupSwitchInsn(oracle.toplink.libraries.asm.Label dflt, int[] keys, oracle.toplink.libraries.asm.Label[] labels)

    buf.append("    LOOKUPSWITCH\n");
    for (int i = 0; i < labels.length; ++i) {
      buf.append("      ")
        .append(keys[i])
        .append(": ");
      appendLabel(labels[i]);
      buf.append("\n");
    }
    buf.append("      default: ");
    appendLabel(dflt);
    buf.append("\n");

    if (cv != null) {
      cv.visitLookupSwitchInsn(dflt, keys, labels);
    }
  
public voidprintMaxs(int maxStack, int maxLocals)

    buf.append("    MAXSTACK = ")
      .append(maxStack)
      .append("\n    MAXLOCALS = ")
      .append(maxLocals)
      .append("\n\n");

    if (cv != null) {
      cv.visitMaxs(maxStack, maxLocals);
    }
  
public voidprintMethodInsn(int opcode, java.lang.String owner, java.lang.String name, java.lang.String desc)

    buf.append("    ")
      .append(OPCODES[opcode])
      .append(" ")
      .append(owner)
      .append(" ")
      .append(name)
      .append(" ")
      .append(desc)
      .append("\n");

    if (cv != null) {
      cv.visitMethodInsn(opcode, owner, name, desc);
    }
  
public voidprintMultiANewArrayInsn(java.lang.String desc, int dims)

    buf.append("    MULTIANEWARRAY ")
      .append(desc)
      .append(" ")
      .append(dims)
      .append("\n");

    if (cv != null) {
      cv.visitMultiANewArrayInsn(desc, dims);
    }
  
public voidprintTableSwitchInsn(int min, int max, oracle.toplink.libraries.asm.Label dflt, oracle.toplink.libraries.asm.Label[] labels)

    buf.append("    TABLESWITCH\n");
    for (int i = 0; i < labels.length; ++i) {
      buf.append("      ")
        .append(min + i)
        .append(": ");
      appendLabel(labels[i]);
      buf.append("\n");
    }
    buf.append("      default: ");
    appendLabel(dflt);
    buf.append("\n");

    if (cv != null) {
      cv.visitTableSwitchInsn(min, max, dflt, labels);
    }
  
public voidprintTryCatchBlock(oracle.toplink.libraries.asm.Label start, oracle.toplink.libraries.asm.Label end, oracle.toplink.libraries.asm.Label handler, java.lang.String type)

    buf.append("    TRYCATCHBLOCK ");
    appendLabel(start);
    buf.append(" ");
    appendLabel(end);
    buf.append(" ");
    appendLabel(handler);
    buf.append(" ")
      .append(type)
      .append("\n");

    if (cv != null) {
      cv.visitTryCatchBlock(start, end, handler, type);
    }
  
public voidprintTypeInsn(int opcode, java.lang.String desc)

    buf.append("    ")
      .append(OPCODES[opcode])
      .append(" ")
      .append(desc)
      .append("\n");

    if (cv != null) {
      cv.visitTypeInsn(opcode, desc);
    }
  
public voidprintVarInsn(int opcode, int var)

    buf.append("    ")
      .append(OPCODES[opcode])
      .append(" ")
      .append(var)
      .append("\n");

    if (cv != null) {
      cv.visitVarInsn(opcode, var);
    }