📄 tracemethodvisitor.java
字号:
appendDescriptor( TraceAbstractVisitor.METHOD_DESCRIPTOR,
desc );
this.buf.append( '\n' );
this.text.add( this.buf.toString() );
if ( this.mv != null ) {
this.mv.visitMethodInsn( opcode,
owner,
name,
desc );
}
}
public void visitJumpInsn(final int opcode,
final Label label) {
this.buf.setLength( 0 );
this.buf.append( this.tab2 ).append( AbstractVisitor.OPCODES[opcode] ).append( ' ' );
appendLabel( label );
this.buf.append( '\n' );
this.text.add( this.buf.toString() );
if ( this.mv != null ) {
this.mv.visitJumpInsn( opcode,
label );
}
}
public void visitLabel(final Label label) {
this.buf.setLength( 0 );
this.buf.append( this.ltab );
appendLabel( label );
this.buf.append( '\n' );
this.text.add( this.buf.toString() );
if ( this.mv != null ) {
this.mv.visitLabel( label );
}
}
public void visitLdcInsn(final Object cst) {
this.buf.setLength( 0 );
this.buf.append( this.tab2 ).append( "LDC " );
if ( cst instanceof String ) {
AbstractVisitor.appendString( this.buf,
(String) cst );
} else if ( cst instanceof Type ) {
this.buf.append( ((Type) cst).getDescriptor() + ".class" );
} else {
this.buf.append( cst );
}
this.buf.append( '\n' );
this.text.add( this.buf.toString() );
if ( this.mv != null ) {
this.mv.visitLdcInsn( cst );
}
}
public void visitIincInsn(final int var,
final int increment) {
this.buf.setLength( 0 );
this.buf.append( this.tab2 ).append( "IINC " ).append( var ).append( ' ' ).append( increment ).append( '\n' );
this.text.add( this.buf.toString() );
if ( this.mv != null ) {
this.mv.visitIincInsn( var,
increment );
}
}
public void visitTableSwitchInsn(final int min,
final int max,
final Label dflt,
final Label labels[]) {
this.buf.setLength( 0 );
this.buf.append( this.tab2 ).append( "TABLESWITCH\n" );
for ( int i = 0; i < labels.length; ++i ) {
this.buf.append( this.tab3 ).append( min + i ).append( ": " );
appendLabel( labels[i] );
this.buf.append( '\n' );
}
this.buf.append( this.tab3 ).append( "default: " );
appendLabel( dflt );
this.buf.append( '\n' );
this.text.add( this.buf.toString() );
if ( this.mv != null ) {
this.mv.visitTableSwitchInsn( min,
max,
dflt,
labels );
}
}
public void visitLookupSwitchInsn(final Label dflt,
final int keys[],
final Label labels[]) {
this.buf.setLength( 0 );
this.buf.append( this.tab2 ).append( "LOOKUPSWITCH\n" );
for ( int i = 0; i < labels.length; ++i ) {
this.buf.append( this.tab3 ).append( keys[i] ).append( ": " );
appendLabel( labels[i] );
this.buf.append( '\n' );
}
this.buf.append( this.tab3 ).append( "default: " );
appendLabel( dflt );
this.buf.append( '\n' );
this.text.add( this.buf.toString() );
if ( this.mv != null ) {
this.mv.visitLookupSwitchInsn( dflt,
keys,
labels );
}
}
public void visitMultiANewArrayInsn(final String desc,
final int dims) {
this.buf.setLength( 0 );
this.buf.append( this.tab2 ).append( "MULTIANEWARRAY " );
appendDescriptor( TraceAbstractVisitor.FIELD_DESCRIPTOR,
desc );
this.buf.append( ' ' ).append( dims ).append( '\n' );
this.text.add( this.buf.toString() );
if ( this.mv != null ) {
this.mv.visitMultiANewArrayInsn( desc,
dims );
}
}
public void visitTryCatchBlock(final Label start,
final Label end,
final Label handler,
final String type) {
this.buf.setLength( 0 );
this.buf.append( this.tab2 ).append( "TRYCATCHBLOCK " );
appendLabel( start );
this.buf.append( ' ' );
appendLabel( end );
this.buf.append( ' ' );
appendLabel( handler );
this.buf.append( ' ' );
appendDescriptor( TraceAbstractVisitor.INTERNAL_NAME,
type );
this.buf.append( '\n' );
this.text.add( this.buf.toString() );
if ( this.mv != null ) {
this.mv.visitTryCatchBlock( start,
end,
handler,
type );
}
}
public void visitLocalVariable(final String name,
final String desc,
final String signature,
final Label start,
final Label end,
final int index) {
this.buf.setLength( 0 );
this.buf.append( this.tab2 ).append( "LOCALVARIABLE " ).append( name ).append( ' ' );
appendDescriptor( TraceAbstractVisitor.FIELD_DESCRIPTOR,
desc );
this.buf.append( ' ' );
appendLabel( start );
this.buf.append( ' ' );
appendLabel( end );
this.buf.append( ' ' ).append( index ).append( '\n' );
if ( signature != null ) {
this.buf.append( this.tab2 );
appendDescriptor( TraceAbstractVisitor.FIELD_SIGNATURE,
signature );
final TraceSignatureVisitor sv = new TraceSignatureVisitor( 0 );
final SignatureReader r = new SignatureReader( signature );
r.acceptType( sv );
this.buf.append( this.tab2 ).append( "// declaration: " ).append( sv.getDeclaration() ).append( '\n' );
}
this.text.add( this.buf.toString() );
if ( this.mv != null ) {
this.mv.visitLocalVariable( name,
desc,
signature,
start,
end,
index );
}
}
public void visitLineNumber(final int line,
final Label start) {
this.buf.setLength( 0 );
this.buf.append( this.tab2 ).append( "LINENUMBER " ).append( line ).append( ' ' );
appendLabel( start );
this.buf.append( '\n' );
this.text.add( this.buf.toString() );
if ( this.mv != null ) {
this.mv.visitLineNumber( line,
start );
}
}
public void visitMaxs(final int maxStack,
final int maxLocals) {
this.buf.setLength( 0 );
this.buf.append( this.tab2 ).append( "MAXSTACK = " ).append( maxStack ).append( '\n' );
this.text.add( this.buf.toString() );
this.buf.setLength( 0 );
this.buf.append( this.tab2 ).append( "MAXLOCALS = " ).append( maxLocals ).append( '\n' );
this.text.add( this.buf.toString() );
if ( this.mv != null ) {
this.mv.visitMaxs( maxStack,
maxLocals );
}
}
public void visitEnd() {
super.visitEnd();
if ( this.mv != null ) {
this.mv.visitEnd();
}
}
// ------------------------------------------------------------------------
// Utility methods
// ------------------------------------------------------------------------
/**
* 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.
*/
public void appendLabel(final Label l) {
String name = (String) this.labelNames.get( l );
if ( name == null ) {
name = "L" + this.labelNames.size();
this.labelNames.put( l,
name );
}
this.buf.append( name );
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -