PrintCodeVisitorpublic abstract class PrintCodeVisitor extends Object implements CodeVisitorAn abstract code visitor that prints the code it visits. Each
visitXXX method clears the {@link #buf buf} buffer, calls the
corresponding printXXX method, and then adds the buffer's
content to the {@link #text text} list. In order to provide a concrete
print code visitor, one must implement the printXXX methods
in a sub class of this class. Each method should print the instructions it
visits in {@link #buf buf}. |
Fields Summary |
---|
protected final List | textThe text to be printed. See {@link PrintClassVisitor#text text}. | protected final StringBuffer | bufA buffer used to convert instructions to strings. | public static final String[] | OPCODESThe names of the Java Virtual Machine opcodes. |
Constructors Summary |
---|
protected PrintCodeVisitor()Constructs a new {@link PrintCodeVisitor PrintCodeVisitor} object.
this.buf = new StringBuffer();
this.text = new ArrayList();
|
Methods Summary |
---|
public java.util.List | getText()Returns the code printed by this code visitor.
return text;
| public abstract void | printAttribute(oracle.toplink.libraries.asm.Attribute attr)Prints a non standard code attribute.
| public abstract void | printFieldInsn(int opcode, java.lang.String owner, java.lang.String name, java.lang.String desc)Prints a field instruction. A field instruction is an instruction that
loads or stores the value of a field of an object.
| public abstract void | printIincInsn(int var, int increment)Prints an IINC instruction.
| public abstract void | printInsn(int opcode)Prints a zero operand instruction.- param
- opcode the opcode of the instruction to be printed. This opcode is
either NOP, ACONST_NULL, ICONST_M1, ICONST_0, ICONST_1, ICONST_2,
ICONST_3, ICONST_4, ICONST_5, LCONST_0, LCONST_1, FCONST_0, FCONST_1,
FCONST_2, DCONST_0, DCONST_1,
IALOAD, LALOAD, FALOAD, DALOAD, AALOAD, BALOAD, CALOAD, SALOAD,
IASTORE, LASTORE, FASTORE, DASTORE, AASTORE, BASTORE, CASTORE,
SASTORE,
POP, POP2, DUP, DUP_X1, DUP_X2, DUP2, DUP2_X1, DUP2_X2, SWAP,
IADD, LADD, FADD, DADD, ISUB, LSUB, FSUB, DSUB, IMUL, LMUL, FMUL,
DMUL, IDIV, LDIV, FDIV, DDIV, IREM, LREM, FREM, DREM, INEG, LNEG,
FNEG, DNEG, ISHL, LSHL, ISHR, LSHR, IUSHR, LUSHR, IAND, LAND, IOR,
LOR, IXOR, LXOR,
I2L, I2F, I2D, L2I, L2F, L2D, F2I, F2L, F2D, D2I, D2L, D2F, I2B, I2C,
I2S,
LCMP, FCMPL, FCMPG, DCMPL, DCMPG,
IRETURN, LRETURN, FRETURN, DRETURN, ARETURN, RETURN,
ARRAYLENGTH,
ATHROW,
MONITORENTER, or MONITOREXIT.
|
| public abstract void | printIntInsn(int opcode, int operand)Prints an instruction with a single int operand.
| public abstract void | printJumpInsn(int opcode, oracle.toplink.libraries.asm.Label label)Prints a jump instruction. A jump instruction is an instruction that may
jump to another instruction.
| public abstract void | printLabel(oracle.toplink.libraries.asm.Label label)Prints a label. A label designates the instruction that will be visited
just after it.
| public abstract void | printLdcInsn(java.lang.Object cst)Prints a LDC instruction.
| public abstract void | printLineNumber(int line, oracle.toplink.libraries.asm.Label start)Prints a line number declaration.
| public abstract void | printLocalVariable(java.lang.String name, java.lang.String desc, oracle.toplink.libraries.asm.Label start, oracle.toplink.libraries.asm.Label end, int index)Prints a local variable declaration.
| public abstract void | printLookupSwitchInsn(oracle.toplink.libraries.asm.Label dflt, int[] keys, oracle.toplink.libraries.asm.Label[] labels)Prints a LOOKUPSWITCH instruction.
| public abstract void | printMaxs(int maxStack, int maxLocals)Prints the maximum stack size and the maximum number of local variables of
the method.
| public abstract void | printMethodInsn(int opcode, java.lang.String owner, java.lang.String name, java.lang.String desc)Prints a method instruction. A method instruction is an instruction that
invokes a method.
| public abstract void | printMultiANewArrayInsn(java.lang.String desc, int dims)Prints a MULTIANEWARRAY instruction.
| public abstract void | printTableSwitchInsn(int min, int max, oracle.toplink.libraries.asm.Label dflt, oracle.toplink.libraries.asm.Label[] labels)Prints a TABLESWITCH instruction.
| public abstract void | printTryCatchBlock(oracle.toplink.libraries.asm.Label start, oracle.toplink.libraries.asm.Label end, oracle.toplink.libraries.asm.Label handler, java.lang.String type)Prints a try catch block.
| public abstract void | printTypeInsn(int opcode, java.lang.String desc)Prints a type instruction. A type instruction is an instruction that
takes a type descriptor as parameter.
| public abstract void | printVarInsn(int opcode, int var)Prints a local variable instruction. A local variable instruction is an
instruction that loads or stores the value of a local variable.
| public void | visitAttribute(oracle.toplink.libraries.asm.Attribute attr)
buf.setLength(0);
printAttribute(attr);
text.add(buf.toString());
| public void | visitFieldInsn(int opcode, java.lang.String owner, java.lang.String name, java.lang.String desc)
buf.setLength(0);
printFieldInsn(opcode, owner, name, desc);
text.add(buf.toString());
| public void | visitIincInsn(int var, int increment)
buf.setLength(0);
printIincInsn(var, increment);
text.add(buf.toString());
| public void | visitInsn(int opcode)
buf.setLength(0);
printInsn(opcode);
text.add(buf.toString());
| public void | visitIntInsn(int opcode, int operand)
buf.setLength(0);
printIntInsn(opcode, operand);
text.add(buf.toString());
| public void | visitJumpInsn(int opcode, oracle.toplink.libraries.asm.Label label)
buf.setLength(0);
printJumpInsn(opcode, label);
text.add(buf.toString());
| public void | visitLabel(oracle.toplink.libraries.asm.Label label)
buf.setLength(0);
printLabel(label);
text.add(buf.toString());
| public void | visitLdcInsn(java.lang.Object cst)
buf.setLength(0);
printLdcInsn(cst);
text.add(buf.toString());
| public void | visitLineNumber(int line, oracle.toplink.libraries.asm.Label start)
buf.setLength(0);
printLineNumber(line, start);
text.add(buf.toString());
| public void | visitLocalVariable(java.lang.String name, java.lang.String desc, oracle.toplink.libraries.asm.Label start, oracle.toplink.libraries.asm.Label end, int index)
buf.setLength(0);
printLocalVariable(name, desc, start, end, index);
text.add(buf.toString());
| public void | visitLookupSwitchInsn(oracle.toplink.libraries.asm.Label dflt, int[] keys, oracle.toplink.libraries.asm.Label[] labels)
buf.setLength(0);
printLookupSwitchInsn(dflt, keys, labels);
text.add(buf.toString());
| public void | visitMaxs(int maxStack, int maxLocals)
buf.setLength(0);
printMaxs(maxStack, maxLocals);
text.add(buf.toString());
| public void | visitMethodInsn(int opcode, java.lang.String owner, java.lang.String name, java.lang.String desc)
buf.setLength(0);
printMethodInsn(opcode, owner, name, desc);
text.add(buf.toString());
| public void | visitMultiANewArrayInsn(java.lang.String desc, int dims)
buf.setLength(0);
printMultiANewArrayInsn(desc, dims);
text.add(buf.toString());
| public void | visitTableSwitchInsn(int min, int max, oracle.toplink.libraries.asm.Label dflt, oracle.toplink.libraries.asm.Label[] labels)
buf.setLength(0);
printTableSwitchInsn(min, max, dflt, labels);
text.add(buf.toString());
| public void | visitTryCatchBlock(oracle.toplink.libraries.asm.Label start, oracle.toplink.libraries.asm.Label end, oracle.toplink.libraries.asm.Label handler, java.lang.String type)
buf.setLength(0);
printTryCatchBlock(start, end, handler, type);
text.add(buf.toString());
| public void | visitTypeInsn(int opcode, java.lang.String desc)
buf.setLength(0);
printTypeInsn(opcode, desc);
text.add(buf.toString());
| public void | visitVarInsn(int opcode, int var)
buf.setLength(0);
printVarInsn(opcode, var);
text.add(buf.toString());
|
|