author Eric Bruneton
  import { Opcodes } from "./Opcodes" ; import { Handle } from "./Handle" ; import { Label } from "./Label" ; import { AnnotationVisitor } from "./AnnotationVisitor" ; import { TypePath } from "./TypePath" ; import { Attribute } from "./Attribute" ; export abstract class MethodVisitor { /**
     * The ASM API version implemented by this visitor. The value of this field
     * must be one of  Opcodes or  Opcodes .
      api : number ; /**
     * The method visitor to which this visitor must delegate method calls. May
     * be null.
     */ mv : MethodVisitor | null ; /**
     * Constructs a new  MethodVisitor .
     *
     *  param api the ASM API version implemented by this visitor. Must be one
     * of  Opcodes or  Opcodes .
     *  param mv public constructor ( api , mv = null ) { this . api = 0 ; if ( api !== Opcodes . ASM4 && api !== Opcodes . ASM5 ) { throw new Error ( ) ; } this . api = api ; this . mv = mv ; } param name param access the parameter's access flags, only <tt>ACC_FINAL</tt>,
     * <tt>ACC_SYNTHETIC</tt> or/and <tt>ACC_MANDATED</tt> are
     * allowed (see  Opcodes ).
      public visitParameter ( name , access ) { if ( this . api < Opcodes . ASM5 ) { throw new Error ( ) ; } if ( this . mv != null ) { this . mv . visitParameter ( name , access ) ; } } return public visitAnnotationDefault ( ) { if ( this . mv != null ) { return this . mv . visitAnnotationDefault ( ) ; } return null ; } param desc param visible return public visitAnnotation ( desc , visible ) { if ( this . mv != null ) { return this . mv . visitAnnotation ( desc , visible ) ; } return null ; } param typeRef a reference to the annotated type. The sort of this type
     * reference must be  TypeReference * METHOD_TYPE_PARAMETER},
     *  TypeReference * METHOD_TYPE_PARAMETER_BOUND},
     *  TypeReference ,
     *  TypeReference ,
     *  TypeReference * METHOD_FORMAL_PARAMETER} or  TypeReference * THROWS}. See  TypeReference .
     *  param typePath param desc param visible return public visitTypeAnnotation ( typeRef , typePath , desc , visible ) { if ( this . api < Opcodes . ASM5 ) { throw new Error ( ) ; } if ( this . mv != null ) { return this . mv . visitTypeAnnotation ( typeRef , typePath , desc , visible ) ; } return null ; } param parameter param desc param visible return public visitParameterAnnotation ( parameter , desc , visible ) { if ( this . mv != null ) { return this . mv . visitParameterAnnotation ( parameter , desc , visible ) ; } return null ; } param attr public visitAttribute ( attr ) { if ( this . mv != null ) { this . mv . visitAttribute ( attr ) ; } } /**
     * Starts the visit of the method's code, if any (i.e. non abstract method).
     */ public visitCode ( ) { if ( this . mv != null ) { this . mv . visitCode ( ) ; } } /**
     * Visits the current state of the local variables and operand stack
     * elements. This method must(*) be called <i>just before</i> any
     * instruction <b>i</b> that follows an unconditional branch instruction
     * such as GOTO or THROW, that is the target of a jump instruction, or that
     * starts an exception handler block. The visited types must describe the
     * values of the local variables and of the operand stack elements <i>just
     * before</i> <b>i</b> is executed.<br>
     * <br>
     * (*) this is mandatory only for classes whose version is greater than or
     * equal to  Opcodes . <br>
     * <br>
     * The frames of a method must be given either in expanded form, or in
     * compressed form (all frames must use the same format, i.e. you must not
     * mix expanded and compressed frames within a single method):
     * <ul>
     * <li>In expanded form, all frames must have the F_NEW type.</li>
     * <li>In compressed form, frames are basically "deltas" from the state of
     * the previous frame:
     * <ul>
     * <li> Opcodes representing frame with exactly the same
     * locals as the previous frame and with the empty stack.</li>
     * <li> Opcodes representing frame with exactly the same
     * locals as the previous frame and with single value on the stack (
     * <code>nStack</code> is 1 and <code>stack[0]</code> contains value for the
     * type of the stack item).</li>
     * <li> Opcodes representing frame with current locals are
     * the same as the locals in the previous frame, except that additional
     * locals are defined (<code>nLocal</code> is 1, 2 or 3 and
     * <code>local</code> elements contains values representing added types).</li>
     * <li> Opcodes representing frame with current locals are the
     * same as the locals in the previous frame, except that the last 1-3 locals
     * are absent and with the empty stack (<code>nLocals</code> is 1, 2 or 3).</li>
     * <li> Opcodes representing complete frame data.</li>
     * </ul>
     * </li>
     * </ul>
     * <br>
     * In both cases the first frame, corresponding to the method's parameters
     * and access flags, is implicit and must not be visited. Also, it is
     * illegal to visit two or more frames for the same code location (i.e., at
     * least one instruction must be visited between two calls to visitFrame).
     *
     *  param type the type of this stack map frame. Must be
     *  Opcodes for expanded frames, or
     *  Opcodes ,  Opcodes ,
     *  Opcodes ,  Opcodes or
     *  Opcodes ,  Opcodes for
     * compressed frames.
     *  param nLocal param local the local variable types in this frame. This array must not be
     * modified. Primitive types are represented by
     *  Opcodes ,  Opcodes ,
     *  Opcodes ,  Opcodes ,
     *  Opcodes , Opcodes or
     *  Opcodes (long and double are
     * represented by a single element). Reference types are
     * represented by String objects (representing internal names),
     * and uninitialized types by Label objects (this label
     * designates the NEW instruction that created this uninitialized
     * value).
     *  param nStack param stack throws public visitFrame ( type ? , nLocal ? , local ? , nStack ? , stack ? ) { if ( ( ( typeof type === "number" ) || type === null ) && ( ( typeof nLocal === "number" ) || nLocal === null ) && ( ( local != null && local instanceof Array ) || local === null ) && ( ( typeof nStack === "number" ) || nStack === null ) && ( ( stack != null && stack instanceof Array ) || stack === null ) ) { let __args = Array . prototype . slice . call ( arguments ) ; return < any > ( ( ) => { if ( this . mv != null ) { this . mv . visitFrame ( type , nLocal , local , nStack , stack ) ; } } ) ( ) ; } else { throw new Error ( "invalid overload" ) ; } } param opcode public visitInsn ( opcode ) { if ( this . mv != null ) { this . mv . visitInsn ( opcode ) ; } } param opcode param operand the operand of the instruction to be visited.<br>
     * When opcode is BIPUSH, operand value should be between
     * Byte.MIN_VALUE and Byte.MAX_VALUE.<br>
     * When opcode is SIPUSH, operand value should be between
     * Short.MIN_VALUE and Short.MAX_VALUE.<br>
     * When opcode is NEWARRAY, operand value should be one of
     *  Opcodes ,  Opcodes ,
     *  Opcodes ,  Opcodes ,
     *  Opcodes ,  Opcodes ,
     *  Opcodes or  Opcodes .
      public visitIntInsn ( opcode , operand ) { if ( this . mv != null ) { this . mv . visitIntInsn ( opcode , operand ) ; } } param opcode param var public visitVarInsn ( opcode , __var ) { if ( this . mv != null ) { this . mv . visitVarInsn ( opcode , __var ) ; } } param opcode param type the operand of the instruction to be visited. This operand
     * must be the internal name of an object or array class (see
     *  Type ).
      public visitTypeInsn ( opcode , type ) { if ( this . mv != null ) { this . mv . visitTypeInsn ( opcode , type ) ; } } param opcode param owner the internal name of the field's owner class (see
     *  Type ).
     *  param name param desc the field's descriptor (see  Type ).
      public visitFieldInsn ( opcode , owner , name , desc ) { if ( this . mv != null ) { this . mv . visitFieldInsn ( opcode , owner , name , desc ) ; } } param opcode param owner the internal name of the method's owner class (see
     *  Type ).
     *  param name param desc the method's descriptor (see  Type ).
      public visitMethodInsn$int$java_lang_String$java_lang_String$java_lang_String ( opcode , owner , name , desc ) { if ( this . api >= Opcodes . ASM5 ) { let itf = opcode === Opcodes . INVOKEINTERFACE ; this . visitMethodInsn ( opcode , owner , name , desc , itf ) ; return ; } if ( this . mv != null ) { this . mv . visitMethodInsn ( opcode , owner , name , desc ) ; } } param opcode param owner the internal name of the method's owner class (see
     *  Type ).
     *  param name param desc the method's descriptor (see  Type ).
     *  param itf public visitMethodInsn ( opcode ? , owner ? , name ? , desc ? , itf ? ) { if ( ( ( typeof opcode === "number" ) || opcode === null ) && ( ( typeof owner === "string" ) || owner === null ) && ( ( typeof name === "string" ) || name === null ) && ( ( typeof desc === "string" ) || desc === null ) && ( ( typeof itf === "boolean" ) || itf === null ) ) { let __args = Array . prototype . slice . call ( arguments ) ; return < any > ( ( ) => { if ( this . api < Opcodes . ASM5 ) { if ( itf !== ( opcode === Opcodes . INVOKEINTERFACE ) ) { throw new Error ( "INVOKESPECIAL/STATIC on interfaces require ASM 5" ) ; } this . visitMethodInsn ( opcode , owner , name , desc ) ; return ; } if ( this . mv != null ) { this . mv . visitMethodInsn ( opcode , owner , name , desc , itf ) ; } } ) ( ) ; } else if ( ( ( typeof opcode === "number" ) || opcode === null ) && ( ( typeof owner === "string" ) || owner === null ) && ( ( typeof name === "string" ) || name === null ) && ( ( typeof desc === "string" ) || desc === null ) && itf === undefined ) { return < any > this . visitMethodInsn$int$java_lang_String$java_lang_String$java_lang_String ( opcode , owner , name , desc ) ; } else { throw new Error ( "invalid overload" ) ; } } param name param desc the method's descriptor (see  Type ).
     *  param bsm param bsmArgs the bootstrap method constant arguments. Each argument must be
     * an  Integer ,  Float ,  Long ,
     *  Double ,  String ,  Type or  Handle * value. This method is allowed to modify the content of the
     * array so a caller should expect that this array may change.
      public visitInvokeDynamicInsn ( name , desc , bsm , ... bsmArgs ) { if ( this . mv != null ) { this . mv . visitInvokeDynamicInsn ( name , desc , bsm , ... bsmArgs ) ; } } param opcode param label public visitJumpInsn ( opcode , label ) { if ( this . mv != null ) { this . mv . visitJumpInsn ( opcode , label ) ; } } param label a  Label object.
      public visitLabel ( label ) { if ( this . mv != null ) { this . mv . visitLabel ( label ) ; } } param cst the constant to be loaded on the stack. This parameter must be
     * a non null  Integer , a  Float , a  Long , a
     *  Double , a  String , a  Type of OBJECT or
     * ARRAY sort for <tt>.class</tt> constants, for classes whose
     * version is 49.0, a  Type of METHOD sort or a
     *  Handle for MethodType and MethodHandle constants, for
     * classes whose version is 51.0.
      public visitLdcInsn ( cst ) { if ( this . mv != null ) { this . mv . visitLdcInsn ( cst ) ; } } param var param increment public visitIincInsn ( __var , increment ) { if ( this . mv != null ) { this . mv . visitIincInsn ( __var , increment ) ; } } param min param max param dflt param labels public visitTableSwitchInsn ( min , max , dflt , ... labels ) { if ( this . mv != null ) { this . mv . visitTableSwitchInsn ( min , max , dflt , ... labels ) ; } } param dflt param keys param labels public visitLookupSwitchInsn ( dflt , keys , labels ) { if ( this . mv != null ) { this . mv . visitLookupSwitchInsn ( dflt , keys , labels ) ; } } param desc an array type descriptor (see  Type ).
     *  param dims public visitMultiANewArrayInsn ( desc , dims ) { if ( this . mv != null ) { this . mv . visitMultiANewArrayInsn ( desc , dims ) ; } } param typeRef a reference to the annotated type. The sort of this type
     * reference must be  TypeReference ,
     *  TypeReference ,
     *  TypeReference * CONSTRUCTOR_REFERENCE},  TypeReference * METHOD_REFERENCE},  TypeReference ,
     *  TypeReference * CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT},
     *  TypeReference * METHOD_INVOCATION_TYPE_ARGUMENT},
     *  TypeReference * CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT}, or
     *  TypeReference * METHOD_REFERENCE_TYPE_ARGUMENT}. See  TypeReference .
     *  param typePath param desc param visible return public visitInsnAnnotation ( typeRef , typePath , desc , visible ) { if ( this . api < Opcodes . ASM5 ) { throw new Error ( ) ; } if ( this . mv != null ) { return this . mv . visitInsnAnnotation ( typeRef , typePath , desc , visible ) ; } return null ; } param start param end param handler param type throws IllegalArgumentException
     * if one of the labels has already been visited by this visitor
     * (by the  {@link #visitLabel visitLabel} method).
      public visitTryCatchBlock ( start , end , handler , type ) { if ( this . mv != null ) { this . mv . visitTryCatchBlock ( start , end , handler , type ) ; } } /**
     * Visits an annotation on an exception handler type. This method must be
     * called <i>after</i> the  {@link #visitTryCatchBlock} for the annotated
     * exception handler. It can be called several times for the same exception
     * handler.
     *
     *  param typeRef a reference to the annotated type. The sort of this type
     * reference must be  TypeReference * EXCEPTION_PARAMETER}. See  TypeReference .
     *  param typePath param desc param visible return public visitTryCatchAnnotation ( typeRef , typePath , desc , visible ) { if ( this . api < Opcodes . ASM5 ) { throw new Error ( ) ; } if ( this . mv != null ) { return this . mv . visitTryCatchAnnotation ( typeRef , typePath , desc , visible ) ; } return null ; } param name param desc param signature param start param end param index throws IllegalArgumentException
     * if one of the labels has not already been visited by this
     * visitor (by the  {@link #visitLabel visitLabel} method).
      public visitLocalVariable ( name , desc , signature , start , end , index ) { if ( this . mv != null ) { this . mv . visitLocalVariable ( name , desc , signature , start , end , index ) ; } } param typeRef a reference to the annotated type. The sort of this type
     * reference must be  TypeReference * LOCAL_VARIABLE} or  TypeReference * RESOURCE_VARIABLE}. See  TypeReference .
     *  param typePath param start param end param index param desc param visible return public visitLocalVariableAnnotation ( typeRef , typePath , start , end , index , desc , visible ) { if ( this . api < Opcodes . ASM5 ) { throw new Error ( ) ; } if ( this . mv != null ) { return this . mv . visitLocalVariableAnnotation ( typeRef , typePath , start , end , index , desc , visible ) ; } return null ; } param line param start throws IllegalArgumentException
     * if <tt>start</tt> has not already been visited by this
     * visitor (by the  {@link #visitLabel visitLabel} method).
      public visitLineNumber ( line , start ) { if ( this . mv != null ) { this . mv . visitLineNumber ( line , start ) ; } } param maxStack param maxLocals public visitMaxs ( maxStack , maxLocals ) { if ( this . mv != null ) { this . mv . visitMaxs ( maxStack , maxLocals ) ; } } /**
     * Visits the end of the method. This method, which is the last one to be
     * called, is used to inform the visitor that all the annotations and
     * attributes of the method have been visited.
     */ public visitEnd ( ) { if ( this . mv != null ) { this . mv . visitEnd ( ) ; } } }