⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 methodnode.java

📁 jboss规则引擎
💻 JAVA
📖 第 1 页 / 共 2 页
字号:

    public void visitInsn(final int opcode) {
        this.instructions.add( new InsnNode( opcode ) );
    }

    public void visitIntInsn(final int opcode,
                             final int operand) {
        this.instructions.add( new IntInsnNode( opcode,
                                                operand ) );
    }

    public void visitVarInsn(final int opcode,
                             final int var) {
        this.instructions.add( new VarInsnNode( opcode,
                                                var ) );
    }

    public void visitTypeInsn(final int opcode,
                              final String desc) {
        this.instructions.add( new TypeInsnNode( opcode,
                                                 desc ) );
    }

    public void visitFieldInsn(final int opcode,
                               final String owner,
                               final String name,
                               final String desc) {
        this.instructions.add( new FieldInsnNode( opcode,
                                                  owner,
                                                  name,
                                                  desc ) );
    }

    public void visitMethodInsn(final int opcode,
                                final String owner,
                                final String name,
                                final String desc) {
        this.instructions.add( new MethodInsnNode( opcode,
                                                   owner,
                                                   name,
                                                   desc ) );
    }

    public void visitJumpInsn(final int opcode,
                              final Label label) {
        this.instructions.add( new JumpInsnNode( opcode,
                                                 label ) );
    }

    public void visitLabel(final Label label) {
        this.instructions.add( new LabelNode( label ) );
    }

    public void visitLdcInsn(final Object cst) {
        this.instructions.add( new LdcInsnNode( cst ) );
    }

    public void visitIincInsn(final int var,
                              final int increment) {
        this.instructions.add( new IincInsnNode( var,
                                                 increment ) );
    }

    public void visitTableSwitchInsn(final int min,
                                     final int max,
                                     final Label dflt,
                                     final Label[] labels) {
        this.instructions.add( new TableSwitchInsnNode( min,
                                                        max,
                                                        dflt,
                                                        labels ) );
    }

    public void visitLookupSwitchInsn(final Label dflt,
                                      final int[] keys,
                                      final Label[] labels) {
        this.instructions.add( new LookupSwitchInsnNode( dflt,
                                                         keys,
                                                         labels ) );
    }

    public void visitMultiANewArrayInsn(final String desc,
                                        final int dims) {
        this.instructions.add( new MultiANewArrayInsnNode( desc,
                                                           dims ) );
    }

    public void visitTryCatchBlock(final Label start,
                                   final Label end,
                                   final Label handler,
                                   final String type) {
        this.tryCatchBlocks.add( new TryCatchBlockNode( 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.localVariables.add( new LocalVariableNode( name,
                                                        desc,
                                                        signature,
                                                        start,
                                                        end,
                                                        index ) );
    }

    public void visitLineNumber(final int line,
                                final Label start) {
        this.lineNumbers.add( new LineNumberNode( line,
                                                  start ) );
    }

    public void visitMaxs(final int maxStack,
                          final int maxLocals) {
        this.maxStack = maxStack;
        this.maxLocals = maxLocals;
    }

    // ------------------------------------------------------------------------
    // Accept method
    // ------------------------------------------------------------------------

    /**
     * Makes the given class visitor visit this method.
     * 
     * @param cv a class visitor.
     */
    public void accept(final ClassVisitor cv) {
        final String[] exceptions = new String[this.exceptions.size()];
        this.exceptions.toArray( exceptions );
        final MethodVisitor mv = cv.visitMethod( this.access,
                                                 this.name,
                                                 this.desc,
                                                 this.signature,
                                                 exceptions );
        if ( mv != null ) {
            accept( mv );
        }
    }

    /**
     * Makes the given method visitor visit this method.
     * 
     * @param mv a method visitor.
     */
    public void accept(final MethodVisitor mv) {
        // visits the method attributes
        int i, j, n;
        if ( this.annotationDefault != null ) {
            final AnnotationVisitor av = mv.visitAnnotationDefault();
            AnnotationNode.accept( av,
                                   null,
                                   this.annotationDefault );
            av.visitEnd();
        }
        n = this.visibleAnnotations == null ? 0 : this.visibleAnnotations.size();
        for ( i = 0; i < n; ++i ) {
            final AnnotationNode an = (AnnotationNode) this.visibleAnnotations.get( i );
            an.accept( mv.visitAnnotation( an.desc,
                                           true ) );
        }
        n = this.invisibleAnnotations == null ? 0 : this.invisibleAnnotations.size();
        for ( i = 0; i < n; ++i ) {
            final AnnotationNode an = (AnnotationNode) this.invisibleAnnotations.get( i );
            an.accept( mv.visitAnnotation( an.desc,
                                           false ) );
        }
        n = this.visibleParameterAnnotations == null ? 0 : this.visibleParameterAnnotations.length;
        for ( i = 0; i < n; ++i ) {
            final List l = this.visibleParameterAnnotations[i];
            if ( l == null ) {
                continue;
            }
            for ( j = 0; j < l.size(); ++j ) {
                final AnnotationNode an = (AnnotationNode) l.get( j );
                an.accept( mv.visitParameterAnnotation( i,
                                                        an.desc,
                                                        true ) );
            }
        }
        n = this.invisibleParameterAnnotations == null ? 0 : this.invisibleParameterAnnotations.length;
        for ( i = 0; i < n; ++i ) {
            final List l = this.invisibleParameterAnnotations[i];
            if ( l == null ) {
                continue;
            }
            for ( j = 0; j < l.size(); ++j ) {
                final AnnotationNode an = (AnnotationNode) l.get( j );
                an.accept( mv.visitParameterAnnotation( i,
                                                        an.desc,
                                                        false ) );
            }
        }
        n = this.attrs == null ? 0 : this.attrs.size();
        for ( i = 0; i < n; ++i ) {
            mv.visitAttribute( (Attribute) this.attrs.get( i ) );
        }
        // visits the method's code
        if ( this.instructions.size() > 0 ) {
            mv.visitCode();
            // visits try catch blocks
            for ( i = 0; i < this.tryCatchBlocks.size(); ++i ) {
                ((TryCatchBlockNode) this.tryCatchBlocks.get( i )).accept( mv );
            }
            // visits instructions
            for ( i = 0; i < this.instructions.size(); ++i ) {
                ((AbstractInsnNode) this.instructions.get( i )).accept( mv );
            }
            // visits local variables
            n = this.localVariables == null ? 0 : this.localVariables.size();
            for ( i = 0; i < n; ++i ) {
                ((LocalVariableNode) this.localVariables.get( i )).accept( mv );
            }
            // visits line numbers
            n = this.lineNumbers == null ? 0 : this.lineNumbers.size();
            for ( i = 0; i < n; ++i ) {
                ((LineNumberNode) this.lineNumbers.get( i )).accept( mv );
            }
            // visits maxs
            mv.visitMaxs( this.maxStack,
                          this.maxLocals );
        }
        mv.visitEnd();
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -