/**
 * A  ClassVisitor that generates classes in bytecode form. More
 * precisely this visitor generates a byte array conforming to the Java class
 * file format. It can be used alone, to generate a Java class "from scratch",
 * or with one or more  ClassReader and adapter class visitor
 * to generate a modified class from one or more existing Java classes.
 *
 *  author Eric Bruneton
  import { AnnotationWriter } from "./AnnotationWriter" ; import { AnnotationVisitor } from "./AnnotationVisitor" ; import { Attribute } from "./Attribute" ; import { ByteVector } from "./ByteVector" ; import { ClassReader } from "./ClassReader" ; import { ClassVisitor } from "./ClassVisitor" ; import { FieldVisitor } from "./FieldVisitor" ; import { FieldWriter } from "./FieldWriter" ; import { Handle } from "./Handle" ; import { Item } from "./Item" ; import { MethodVisitor } from "./MethodVisitor" ; import { MethodWriter } from "./MethodWriter" ; import { Opcodes } from "./Opcodes" ; import { TypePath } from "./TypePath" ; export class ClassWriter extends ClassVisitor { static __static_initialized : boolean = false ; static __static_initialize ( ) { if ( ! ClassWriter . __static_initialized ) { ClassWriter . __static_initialized = true ; ClassWriter . __static_initializer_0 ( ) ; } } /**
     * Flag to automatically compute the maximum stack size and the maximum
     * number of local variables of methods. If this flag is set, then the
     * arguments of the  MethodVisitor method of the
     *  MethodVisitor returned by the  {@link #visitMethod visitMethod} * method will be ignored, and computed automatically from the signature and
     * the bytecode of each method.
     *
     *  see public static COMPUTE_MAXS : number = 1 ; /**
     * Flag to automatically compute the stack map frames of methods from
     * scratch. If this flag is set, then the calls to the
     *  MethodVisitor method are ignored, and the stack map
     * frames are recomputed from the methods bytecode. The arguments of the
     *  MethodVisitor method are also ignored and
     * recomputed from the bytecode. In other words, COMPUTE_FRAMES implies
     * COMPUTE_MAXS.
     *
     *  see public static COMPUTE_FRAMES : number = 2 ; /**
     * Pseudo access flag to distinguish between the synthetic attribute and the
     * synthetic access flag.
     */ static ACC_SYNTHETIC_ATTRIBUTE : number = 262144 ; /**
     * Factor to convert from ACC_SYNTHETIC_ATTRIBUTE to Opcode.ACC_SYNTHETIC.
     */ static TO_ACC_SYNTHETIC : number ; public static TO_ACC_SYNTHETIC_$LI$ ( ) { ClassWriter . __static_initialize ( ) ; if ( ClassWriter . TO_ACC_SYNTHETIC == null ) { ClassWriter . TO_ACC_SYNTHETIC = ( ClassWriter . ACC_SYNTHETIC_ATTRIBUTE / Opcodes . ACC_SYNTHETIC | 0 ) ; } return ClassWriter . TO_ACC_SYNTHETIC ; } ; /**
     * The type of instructions without any argument.
     */ static NOARG_INSN : number = 0 ; /**
     * The type of instructions with an signed byte argument.
     */ static SBYTE_INSN : number = 1 ; /**
     * The type of instructions with an signed short argument.
     */ static SHORT_INSN : number = 2 ; /**
     * The type of instructions with a local variable index argument.
     */ static VAR_INSN : number = 3 ; /**
     * The type of instructions with an implicit local variable index argument.
     */ static IMPLVAR_INSN : number = 4 ; /**
     * The type of instructions with a type descriptor argument.
     */ static TYPE_INSN : number = 5 ; /**
     * The type of field and method invocations instructions.
     */ static FIELDORMETH_INSN : number = 6 ; /**
     * The type of the INVOKEINTERFACE/INVOKEDYNAMIC instruction.
     */ static ITFMETH_INSN : number = 7 ; /**
     * The type of the INVOKEDYNAMIC instruction.
     */ static INDYMETH_INSN : number = 8 ; /**
     * The type of instructions with a 2 bytes bytecode offset label.
     */ static LABEL_INSN : number = 9 ; /**
     * The type of instructions with a 4 bytes bytecode offset label.
     */ static LABELW_INSN : number = 10 ; /**
     * The type of the LDC instruction.
     */ static LDC_INSN : number = 11 ; /**
     * The type of the LDC_W and LDC2_W instructions.
     */ static LDCW_INSN : number = 12 ; /**
     * The type of the IINC instruction.
     */ static IINC_INSN : number = 13 ; /**
     * The type of the TABLESWITCH instruction.
     */ static TABL_INSN : number = 14 ; /**
     * The type of the LOOKUPSWITCH instruction.
     */ static LOOK_INSN : number = 15 ; /**
     * The type of the MULTIANEWARRAY instruction.
     */ static MANA_INSN : number = 16 ; /**
     * The type of the WIDE instruction.
     */ static WIDE_INSN : number = 17 ; /**
     * The type of the ASM pseudo instructions with an unsigned 2 bytes offset
     * label (see Label#resolve).
     */ static ASM_LABEL_INSN : number = 18 ; /**
     * Represents a frame inserted between already existing frames. This kind of
     * frame can only be used if the frame content can be computed from the
     * previous existing frame and from the instructions between this existing
     * frame and the inserted one, without any knowledge of the type hierarchy.
     * This kind of frame is only used when an unconditional jump is inserted in
     * a method while expanding an ASM pseudo instruction (see ClassReader).
     */ static F_INSERT : number = 256 ; /**
     * The instruction types of all JVM opcodes.
     */ static TYPE : number [ ] ; public static TYPE_$LI$ ( ) { ClassWriter . __static_initialize ( ) ; return ClassWriter . TYPE ; } ; /**
     * The type of CONSTANT_Class constant pool items.
     */ static CLASS : number = 7 ; /**
     * The type of CONSTANT_Fieldref constant pool items.
     */ static FIELD : number = 9 ; /**
     * The type of CONSTANT_Methodref constant pool items.
     */ static METH : number = 10 ; /**
     * The type of CONSTANT_InterfaceMethodref constant pool items.
     */ static IMETH : number = 11 ; /**
     * The type of CONSTANT_String constant pool items.
     */ static STR : number = 8 ; /**
     * The type of CONSTANT_Integer constant pool items.
     */ static INT : number = 3 ; /**
     * The type of CONSTANT_Float constant pool items.
     */ static FLOAT : number = 4 ; /**
     * The type of CONSTANT_Long constant pool items.
     */ static LONG : number = 5 ; /**
     * The type of CONSTANT_Double constant pool items.
     */ static DOUBLE : number = 6 ; /**
     * The type of CONSTANT_NameAndType constant pool items.
     */ static NAME_TYPE : number = 12 ; /**
     * The type of CONSTANT_Utf8 constant pool items.
     */ static UTF8 : number = 1 ; /**
     * The type of CONSTANT_MethodType constant pool items.
     */ static MTYPE : number = 16 ; /**
     * The type of CONSTANT_MethodHandle constant pool items.
     */ static HANDLE : number = 15 ; /**
     * The type of CONSTANT_InvokeDynamic constant pool items.
     */ static INDY : number = 18 ; /**
     * The base value for all CONSTANT_MethodHandle constant pool items.
     * Internally, ASM store the 9 variations of CONSTANT_MethodHandle into 9
     * different items.
     */ static HANDLE_BASE : number = 20 ; /**
     * Normal type Item stored in the ClassWriter  ClassWriter ,
     * instead of the constant pool, in order to avoid clashes with normal
     * constant pool items in the ClassWriter constant pool's hash table.
      static TYPE_NORMAL : number = 30 ; /**
     * Uninitialized type Item stored in the ClassWriter
     *  ClassWriter , instead of the constant pool, in order to
     * avoid clashes with normal constant pool items in the ClassWriter constant
     * pool's hash table.
      static TYPE_UNINIT : number = 31 ; /**
     * Merged type Item stored in the ClassWriter  ClassWriter ,
     * instead of the constant pool, in order to avoid clashes with normal
     * constant pool items in the ClassWriter constant pool's hash table.
      static TYPE_MERGED : number = 32 ; /**
     * The type of BootstrapMethods items. These items are stored in a special
     * class attribute named BootstrapMethods and not in the constant pool.
     */ static BSM : number = 33 ; /**
     * The class reader from which this class writer was constructed, if any.
     */ cr : ClassReader ; /**
     * Minor and major version numbers of the class to be generated.
     */ version : number ; /**
     * Index of the next item to be added in the constant pool.
     */ index : number ; /**
     * The constant pool of this class.
     */ pool : ByteVector ; /**
     * The constant pool's hash table data.
     */ items : Item [ ] ; /**
     * The threshold of the constant pool's hash table.
     */ threshold : number ; /**
     * A reusable key used to look for items in the  {@link #items} hash table.
      key : Item ; /**
     * A reusable key used to look for items in the  {@link #items} hash table.
      key2 : Item ; /**
     * A reusable key used to look for items in the  {@link #items} hash table.
      key3 : Item ; /**
     * A reusable key used to look for items in the  {@link #items} hash table.
      key4 : Item ; /**
     * A type table used to temporarily store internal names that will not
     * necessarily be stored in the constant pool. This type table is used by
     * the control flow and data flow analysis algorithm used to compute stack
     * map frames from scratch. This array associates to each index <tt>i</tt>
     * the Item whose index is <tt>i</tt>. All Item objects stored in this array
     * are also stored in the  {@link #items} hash table. These two arrays allow
     * to retrieve an Item from its index or, conversely, to get the index of an
     * Item from its value. Each Item stores an internal name in its
     *  Item field.
      typeTable : Item [ ] ; /**
     * Number of elements in the  {@link #typeTable} array.
      private typeCount : number ; /**
     * The access flags of this class.
     */ private access : number ; /**
     * The constant pool item that contains the internal name of this class.
     */ private name : number ; /**
     * The internal name of this class.
     */ thisName : string ; /**
     * The constant pool item that contains the signature of this class.
     */ private signature : number ; /**
     * The constant pool item that contains the internal name of the super class
     * of this class.
     */ private superName : number ; /**
     * Number of interfaces implemented or extended by this class or interface.
     */ private interfaceCount : number ; /**
     * The interfaces implemented or extended by this class or interface. More
     * precisely, this array contains the indexes of the constant pool items
     * that contain the internal names of these interfaces.
     */ private interfaces : number [ ] ; /**
     * The index of the constant pool item that contains the name of the source
     * file from which this class was compiled.
     */ private sourceFile : number ; /**
     * The SourceDebug attribute of this class.
     */ private sourceDebug : ByteVector ; /**
     * The constant pool item that contains the name of the enclosing class of
     * this class.
     */ private enclosingMethodOwner : number ; /**
     * The constant pool item that contains the name and descriptor of the
     * enclosing method of this class.
     */ private enclosingMethod : number ; /**
     * The runtime visible annotations of this class.
     */ private anns : AnnotationWriter ; /**
     * The runtime invisible annotations of this class.
     */ private ianns : AnnotationWriter ; /**
     * The runtime visible type annotations of this class.
     */ private tanns : AnnotationWriter ; /**
     * The runtime invisible type annotations of this class.
     */ private itanns : AnnotationWriter ; /**
     * The non standard attributes of this class.
     */ private attrs : Attribute ; /**
     * The number of entries in the InnerClasses attribute.
     */ private innerClassesCount : number ; /**
     * The InnerClasses attribute.
     */ private innerClasses : ByteVector ; /**
     * The number of entries in the BootstrapMethods attribute.
     */ bootstrapMethodsCount : number ; /**
     * The BootstrapMethods attribute.
     */ bootstrapMethods : ByteVector ; /**
     * The fields of this class. These fields are stored in a linked list of
     *  FieldWriter objects, linked to each other by their
     *  FieldWriter field. This field stores the first element of this
     * list.
      firstField : FieldWriter ; /**
     * The fields of this class. These fields are stored in a linked list of
     *  FieldWriter objects, linked to each other by their
     *  FieldWriter field. This field stores the last element of this
     * list.
      lastField : FieldWriter ; /**
     * The methods of this class. These methods are stored in a linked list of
     *  MethodWriter objects, linked to each other by their
     *  MethodWriter field. This field stores the first element of
     * this list.
      firstMethod : MethodWriter ; /**
     * The methods of this class. These methods are stored in a linked list of
     *  MethodWriter objects, linked to each other by their
     *  MethodWriter field. This field stores the last element of this
     * list.
      lastMethod : MethodWriter ; see MethodWriter private compute : number ; /**
     * <tt>true</tt> if some methods have wide forward jumps using ASM pseudo
     * instructions, which need to be expanded into sequences of standard
     * bytecode instructions. In this case the class is re-read and re-written
     * with a ClassReader -> ClassWriter chain to perform this transformation.
     */ hasAsmInsns : boolean ; static __static_initializer_0 ( ) { let i ; let b = new Array ( 220 ) ; let s = "AAAAAAAAAAAAAAAABCLMMDDDDDEEEEEEEEEEEEEEEEEEEEAAAAAAAADDDDDEEEEEEEEEEEEEEEEEEEEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAANAAAAAAAAAAAAAAAAAAAAJJJJJJJJJJJJJJJJDOPAAAAAAGGGGGGGHIFBFAAFFAARQJJKKSSSSSSSSSSSSSSSSSS" ; for ( i = 0 ; i < b . length ; ++ i ) { b [ i ] = ( ( ( s . charAt ( i ) ) . charCodeAt ( 0 ) - ( "A" ) . charCodeAt ( 0 ) ) | 0 ) ; } ClassWriter . TYPE = b ; } /**
     * Constructs a new  ClassWriter object and enables optimizations for
     * "mostly add" bytecode transformations. These optimizations are the
     * following:
     *
     * <ul>
     * <li>The constant pool from the original class is copied as is in the new
     * class, which saves time. New constant pool entries will be added at the
     * end if necessary, but unused constant pool entries <i>won't be
     * removed</i>.</li>
     * <li>Methods that are not transformed are copied as is in the new class,
     * directly from the original class bytecode (i.e. without emitting visit
     * events for all the method instructions), which saves a <i>lot</i> of
     * time. Untransformed methods are detected by the fact that the
     *  ClassReader receives  MethodVisitor objects that come from
     * a  ClassWriter (and not from any other  ClassVisitor * instance).</li>
     * </ul>
     *
     *  param classReader the  ClassReader used to read the original class. It
     * will be used to copy the entire constant pool from the
     * original class and also to copy other fragments of original
     * bytecode where applicable.
     *  param flags option flags that can be used to modify the default behavior
     * of this class. <i>These option flags do not affect methods
     * that are copied as is in the new class. This means that
     * neither the maximum stack size nor the stack frames will be
     * computed for these methods</i>. See  {@link #COMPUTE_MAXS} ,
     *  {@link #COMPUTE_FRAMES} .
      public constructor ( classReader ? , flags ? ) { if ( ( ( classReader != null && classReader instanceof ClassReader ) || classReader === null ) && ( ( typeof flags === "number" ) || flags === null ) ) { let __args = Array . prototype . slice . call ( arguments ) ; { throw new Error ( "not supported" ) ; } } else if ( ( ( typeof classReader === "number" ) || classReader === null ) && flags === undefined ) { let __args = Array . prototype . slice . call ( arguments ) ; let flags = __args [ 0 ] ; super ( Opcodes . ASM5 ) ; this . version = 0 ; this . index = 0 ; this . threshold = 0 ; this . typeCount = 0 ; this . access = 0 ; this . name = 0 ; this . signature = 0 ; this . superName = 0 ; this . interfaceCount = 0 ; this . sourceFile = 0 ; this . enclosingMethodOwner = 0 ; this . enclosingMethod = 0 ; this . innerClassesCount = 0 ; this . bootstrapMethodsCount = 0 ; this . compute = 0 ; this . hasAsmInsns = false ; ( ( ) => { this . index = 1 ; this . pool = new ByteVector ( ) ; this . items = new Array ( 256 ) ; this . threshold = ( ( 0.75 * this . items . length ) | 0 ) ; this . compute = ( flags & ClassWriter . COMPUTE_FRAMES ) !== 0 ? MethodWriter . FRAMES : ( ( flags & ClassWriter . COMPUTE_MAXS ) !== 0 ? MethodWriter . MAXS : MethodWriter . NOTHING ) ; } ) ( ) ; } else { throw new Error ( "invalid overload" ) ; } } public visit ( version , access , name , signature , superName , interfaces ) { this . version = version ; this . access = access ; this . name = this . newClass ( name ) ; this . thisName = name ; if ( ClassReader . SIGNATURES && signature != null ) { this . signature = this . newUTF8 ( signature ) ; } this . superName = superName == null ? 0 : this . newClass ( superName ) ; if ( interfaces != null && interfaces . length > 0 ) { this . interfaceCount = interfaces . length ; this . interfaces = new Array ( this . interfaceCount ) ; for ( let i = 0 ; i < this . interfaceCount ; ++ i ) { this . interfaces [ i ] = this . newClass ( interfaces [ i ] ) ; } } } public visitSource ( file , debug ) { throw new Error ( "not supported" ) ; } public visitOuterClass ( owner , name , desc ) { this . enclosingMethodOwner = this . newClass ( owner ) ; if ( name != null && desc != null ) { this . enclosingMethod = this . newNameType ( name , desc ) ; } } public visitAnnotation ( desc , visible ) { if ( ! ClassReader . ANNOTATIONS ) { return null ; } let bv = new ByteVector ( ) ; bv . putShort ( this . newUTF8 ( desc ) ) . putShort ( 0 ) ; let aw = new AnnotationWriter ( this , true , bv , bv , 2 ) ; if ( visible ) { aw . next = this . anns ; this . anns = aw ; } else { aw . next = this . ianns ; this . ianns = aw ; } return aw ; } public visitTypeAnnotation ( typeRef , typePath , desc , visible ) { if ( ! ClassReader . ANNOTATIONS ) { return null ; } let bv = new ByteVector ( ) ; AnnotationWriter . putTarget ( typeRef , typePath , bv ) ; bv . putShort ( this . newUTF8 ( desc ) ) . putShort ( 0 ) ; let aw = new AnnotationWriter ( this , true , bv , bv , bv . length - 2 ) ; if ( visible ) { aw . next = this . tanns ; this . tanns = aw ; } else { aw . next = this . itanns ; this . itanns = aw ; } return aw ; } public visitAttribute ( attr ) { attr . next = this . attrs ; this . attrs = attr ; } public visitInnerClass ( name , outerName , innerName , access ) { if ( this . innerClasses == null ) { this . innerClasses = new ByteVector ( ) ; } let nameItem = this . newClassItem ( name ) ; if ( nameItem . intVal === 0 ) { ++ this . innerClassesCount ; this . innerClasses . putShort ( nameItem . index ) ; this . innerClasses . putShort ( outerName == null ? 0 : this . newClass ( outerName ) ) ; this . innerClasses . putShort ( innerName == null ? 0 : this . newUTF8 ( innerName ) ) ; this . innerClasses . putShort ( access ) ; nameItem . intVal = this . innerClassesCount ; } else { } } public visitField ( access , name , desc , signature , value ) { return new FieldWriter ( this , access , name , desc , signature , value ) ; } public visitMethod ( access , name , desc , signature , exceptions ) { return new MethodWriter ( this , access , name , desc , signature , exceptions , this . compute ) ; } public visitEnd ( ) { } return public toByteArray ( ) { throw new Error ( "not supported" ) ; } param cst the value of the constant to be added to the constant pool.
     * This parameter must be an  Integer , a  Float , a
     *  Long , a  Double , a  String or a
     *  Type .
     *  return newConstItem ( cst ) { throw new Error ( "unsupported" ) ; } /**
     * Adds a number or string constant to the constant pool of the class being
     * build. Does nothing if the constant pool already contains a similar item.
     * <i>This method is intended for  Attribute sub classes, and is
     * normally not needed by class generators or adapters.</i>
     *
     *  param cst the value of the constant to be added to the constant pool.
     * This parameter must be an  Integer , a  Float , a
     *  Long , a  Double or a  String .
     *  return public newConst ( cst ) { return this . newConstItem ( cst ) . index ; } /**
     * Adds an UTF8 string to the constant pool of the class being build. Does
     * nothing if the constant pool already contains a similar item. <i>This
     * method is intended for  Attribute sub classes, and is normally not
     * needed by class generators or adapters.</i>
     *
     *  param value return public newUTF8 ( value ) { this . key . set ( ClassWriter . UTF8 , value , null , null ) ; let result = this . get ( this . key ) ; if ( result == null ) { this . pool . putByte ( ClassWriter . UTF8 ) . putUTF8 ( value ) ; result = new Item ( this . index ++ , this . key ) ; this . put ( result ) ; } return result . index ; } /**
     * Adds a class reference to the constant pool of the class being build.
     * Does nothing if the constant pool already contains a similar item.
     * <i>This method is intended for  Attribute sub classes, and is
     * normally not needed by class generators or adapters.</i>
     *
     *  param value return newClassItem ( value ) { this . key2 . set ( ClassWriter . CLASS , value , null , null ) ; let result = this . get ( this . key2 ) ; if ( result == null ) { this . pool . put12 ( ClassWriter . CLASS , this . newUTF8 ( value ) ) ; result = new Item ( this . index ++ , this . key2 ) ; this . put ( result ) ; } return result ; } /**
     * Adds a class reference to the constant pool of the class being build.
     * Does nothing if the constant pool already contains a similar item.
     * <i>This method is intended for  Attribute sub classes, and is
     * normally not needed by class generators or adapters.</i>
     *
     *  param value return public newClass ( value ) { return this . newClassItem ( value ) . index ; } /**
     * Adds a method type reference to the constant pool of the class being
     * build. Does nothing if the constant pool already contains a similar item.
     * <i>This method is intended for  Attribute sub classes, and is
     * normally not needed by class generators or adapters.</i>
     *
     *  param methodDesc return newMethodTypeItem ( methodDesc ) { this . key2 . set ( ClassWriter . MTYPE , methodDesc , null , null ) ; let result = this . get ( this . key2 ) ; if ( result == null ) { this . pool . put12 ( ClassWriter . MTYPE , this . newUTF8 ( methodDesc ) ) ; result = new Item ( this . index ++ , this . key2 ) ; this . put ( result ) ; } return result ; } /**
     * Adds a method type reference to the constant pool of the class being
     * build. Does nothing if the constant pool already contains a similar item.
     * <i>This method is intended for  Attribute sub classes, and is
     * normally not needed by class generators or adapters.</i>
     *
     *  param methodDesc return public newMethodType ( methodDesc ) { return this . newMethodTypeItem ( methodDesc ) . index ; } /**
     * Adds a handle to the constant pool of the class being build. Does nothing
     * if the constant pool already contains a similar item. <i>This method is
     * intended for  Attribute sub classes, and is normally not needed by
     * class generators or adapters.</i>
     *
     *  param tag the kind of this handle. Must be  Opcodes ,
     *  Opcodes ,  Opcodes ,
     *  Opcodes ,  Opcodes ,
     *  Opcodes ,
     *  Opcodes ,
     *  Opcodes or
     *  Opcodes .
     *  param owner param name param desc param itf return newHandleItem ( tag , owner , name , desc , itf ) { this . key4 . set ( ClassWriter . HANDLE_BASE + tag , owner , name , desc ) ; let result = this . get ( this . key4 ) ; if ( result == null ) { if ( tag <= Opcodes . H_PUTSTATIC ) { this . put112 ( ClassWriter . HANDLE , tag , this . newField ( owner , name , desc ) ) ; } else { this . put112 ( ClassWriter . HANDLE , tag , this . newMethod ( owner , name , desc , itf ) ) ; } result = new Item ( this . index ++ , this . key4 ) ; this . put ( result ) ; } return result ; } /**
     * Adds a handle to the constant pool of the class being build. Does nothing
     * if the constant pool already contains a similar item. <i>This method is
     * intended for  Attribute sub classes, and is normally not needed by
     * class generators or adapters.</i>
     *
     *  param tag the kind of this handle. Must be  Opcodes ,
     *  Opcodes ,  Opcodes ,
     *  Opcodes ,  Opcodes ,
     *  Opcodes ,
     *  Opcodes ,
     *  Opcodes or
     *  Opcodes .
     *  param owner param name param desc return deprecated this method is superseded by
     *  {@link #newHandle(int, String, String, String, boolean)} .
      public newHandle$int$java_lang_String$java_lang_String$java_lang_String ( tag , owner , name , desc ) { return this . newHandle ( tag , owner , name , desc , tag === Opcodes . H_INVOKEINTERFACE ) ; } /**
     * Adds a handle to the constant pool of the class being build. Does nothing
     * if the constant pool already contains a similar item. <i>This method is
     * intended for  Attribute sub classes, and is normally not needed by
     * class generators or adapters.</i>
     *
     *  param tag the kind of this handle. Must be  Opcodes ,
     *  Opcodes ,  Opcodes ,
     *  Opcodes ,  Opcodes ,
     *  Opcodes ,
     *  Opcodes ,
     *  Opcodes or
     *  Opcodes .
     *  param owner param name param desc param itf return public newHandle ( tag ? , owner ? , name ? , desc ? , itf ? ) { if ( ( ( typeof tag === "number" ) || tag === 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 > ( ( ) => { return this . newHandleItem ( tag , owner , name , desc , itf ) . index ; } ) ( ) ; } else if ( ( ( typeof tag === "number" ) || tag === null ) && ( ( typeof owner === "string" ) || owner === null ) && ( ( typeof name === "string" ) || name === null ) && ( ( typeof desc === "string" ) || desc === null ) && itf === undefined ) { return < any > this . newHandle$int$java_lang_String$java_lang_String$java_lang_String ( tag , owner , name , desc ) ; } else { throw new Error ( "invalid overload" ) ; } } /**
     * Adds an invokedynamic reference to the constant pool of the class being
     * build. Does nothing if the constant pool already contains a similar item.
     * <i>This method is intended for  Attribute sub classes, and is
     * normally not needed by class generators or adapters.</i>
     *
     *  param name param desc param bsm param bsmArgs return newInvokeDynamicItem ( name , desc , bsm , ... bsmArgs ) { let bootstrapMethods = this . bootstrapMethods ; if ( bootstrapMethods == null ) { bootstrapMethods = this . bootstrapMethods = new ByteVector ( ) ; } let position = bootstrapMethods . length ; let hashCode = bsm . hashCode ( ) ; bootstrapMethods . putShort ( this . newHandle ( bsm . tag , bsm . owner , bsm . name , bsm . descriptor , bsm . isInterface ) ) ; let argsLength = bsmArgs . length ; bootstrapMethods . putShort ( argsLength ) ; for ( let i = 0 ; i < argsLength ; i ++ ) { let bsmArg = bsmArgs [ i ] ; hashCode ^= ( bsmArg . toString ( ) ) ; bootstrapMethods . putShort ( this . newConst ( bsmArg ) ) ; } let data = bootstrapMethods . data ; let length = ( 1 + 1 + argsLength ) << 1 ; hashCode &= 2147483647 ; let result = this . items [ hashCode % this . items . length ] ; loop : while ( ( result != null ) ) { if ( result . type !== ClassWriter . BSM || result . __hashCode !== hashCode ) { result = result . next ; continue ; } let resultPosition = result . intVal ; for ( let p = 0 ; p < length ; p ++ ) { if ( data [ position + p ] !== data [ resultPosition + p ] ) { result = result . next ; continue loop ; } } break ; } ; let bootstrapMethodIndex ; if ( result != null ) { bootstrapMethodIndex = result . index ; bootstrapMethods . length = position ; } else { bootstrapMethodIndex = this . bootstrapMethodsCount ++ ; result = new Item ( bootstrapMethodIndex ) ; result . setPosHash ( position , hashCode ) ; this . put ( result ) ; } this . key3 . setInvkDynItem ( name , desc , bootstrapMethodIndex ) ; result = this . get ( this . key3 ) ; if ( result == null ) { this . put122 ( ClassWriter . INDY , bootstrapMethodIndex , this . newNameType ( name , desc ) ) ; result = new Item ( this . index ++ , this . key3 ) ; this . put ( result ) ; } return result ; } /**
     * Adds an invokedynamic reference to the constant pool of the class being
     * build. Does nothing if the constant pool already contains a similar item.
     * <i>This method is intended for  Attribute sub classes, and is
     * normally not needed by class generators or adapters.</i>
     *
     *  param name param desc param bsm param bsmArgs return public newInvokeDynamic ( name , desc , bsm , ... bsmArgs ) { return this . newInvokeDynamicItem . apply ( this , [ name , desc , bsm ] . concat ( bsmArgs ) ) . index ; } param owner param name param desc return newFieldItem ( owner , name , desc ) { this . key3 . set ( ClassWriter . FIELD , owner , name , desc ) ; let result = this . get ( this . key3 ) ; if ( result == null ) { this . put122 ( ClassWriter . FIELD , this . newClass ( owner ) , this . newNameType ( name , desc ) ) ; result = new Item ( this . index ++ , this . key3 ) ; this . put ( result ) ; } return result ; } /**
     * Adds a field reference to the constant pool of the class being build.
     * Does nothing if the constant pool already contains a similar item.
     * <i>This method is intended for  Attribute sub classes, and is
     * normally not needed by class generators or adapters.</i>
     *
     *  param owner param name param desc return public newField ( owner , name , desc ) { return this . newFieldItem ( owner , name , desc ) . index ; } param owner param name param desc param itf return newMethodItem ( owner , name , desc , itf ) { let type = itf ? ClassWriter . IMETH : ClassWriter . METH ; this . key3 . set ( type , owner , name , desc ) ; let result = this . get ( this . key3 ) ; if ( result == null ) { this . put122 ( type , this . newClass ( owner ) , this . newNameType ( name , desc ) ) ; result = new Item ( this . index ++ , this . key3 ) ; this . put ( result ) ; } return result ; } /**
     * Adds a method reference to the constant pool of the class being build.
     * Does nothing if the constant pool already contains a similar item.
     * <i>This method is intended for  Attribute sub classes, and is
     * normally not needed by class generators or adapters.</i>
     *
     *  param owner param name param desc param itf return public newMethod ( owner , name , desc , itf ) { return this . newMethodItem ( owner , name , desc , itf ) . index ; } param value return newInteger ( value ) { this . key . set$int ( value ) ; let result = this . get ( this . key ) ; if ( result == null ) { this . pool . putByte ( ClassWriter . INT ) . putInt ( value ) ; result = new Item ( this . index ++ , this . key ) ; this . put ( result ) ; } return result ; } param value return newFloat ( value ) { this . key . set$float ( value ) ; let result = this . get ( this . key ) ; if ( result == null ) { this . pool . putByte ( ClassWriter . FLOAT ) . putInt ( this . key . intVal ) ; result = new Item ( this . index ++ , this . key ) ; this . put ( result ) ; } return result ; } param value return newLong ( value ) { this . key . set$long ( value ) ; let result = this . get ( this . key ) ; if ( result == null ) { this . pool . putByte ( ClassWriter . LONG ) . putLong ( value ) ; result = new Item ( this . index , this . key ) ; this . index += 2 ; this . put ( result ) ; } return result ; } param value return newDouble ( value ) { this . key . set$double ( value ) ; let result = this . get ( this . key ) ; if ( result == null ) { this . pool . putByte ( ClassWriter . DOUBLE ) . putLong ( this . key . longVal ) ; result = new Item ( this . index , this . key ) ; this . index += 2 ; this . put ( result ) ; } return result ; } param value return private newString ( value ) { this . key2 . set ( ClassWriter . STR , value , null , null ) ; let result = this . get ( this . key2 ) ; if ( result == null ) { this . pool . put12 ( ClassWriter . STR , this . newUTF8 ( value ) ) ; result = new Item ( this . index ++ , this . key2 ) ; this . put ( result ) ; } return result ; } /**
     * Adds a name and type to the constant pool of the class being build. Does
     * nothing if the constant pool already contains a similar item. <i>This
     * method is intended for  Attribute sub classes, and is normally not
     * needed by class generators or adapters.</i>
     *
     *  param name param desc return public newNameType ( name , desc ) { return this . newNameTypeItem ( name , desc ) . index ; } param name param desc return newNameTypeItem ( name , desc ) { this . key2 . set ( ClassWriter . NAME_TYPE , name , desc , null ) ; let result = this . get ( this . key2 ) ; if ( result == null ) { this . put122 ( ClassWriter . NAME_TYPE , this . newUTF8 ( name ) , this . newUTF8 ( desc ) ) ; result = new Item ( this . index ++ , this . key2 ) ; this . put ( result ) ; } return result ; } /**
     * Adds the given internal name to  {@link #typeTable} and returns its index.
     * Does nothing if the type table already contains this internal name.
     *
     *  param type return public addType ( type ? ) { if ( ( ( typeof type === "string" ) || type === null ) ) { let __args = Array . prototype . slice . call ( arguments ) ; return < any > ( ( ) => { this . key . set ( ClassWriter . TYPE_NORMAL , type , null , null ) ; let result = this . get ( this . key ) ; if ( result == null ) { result = this . addType ( this . key ) ; } return result . index ; } ) ( ) ; } else if ( ( ( type != null && type instanceof Item ) || type === null ) ) { return < any > this . addType$Item ( type ) ; } else { throw new Error ( "invalid overload" ) ; } } /**
     * Adds the given "uninitialized" type to  {@link #typeTable} and returns its
     * index. This method is used for UNINITIALIZED types, made of an internal
     * name and a bytecode offset.
     *
     *  param type param offset return addUninitializedType ( type , offset ) { this . key . type = ClassWriter . TYPE_UNINIT ; this . key . intVal = offset ; this . key . strVal1 = type ; this . key . __hashCode = 2147483647 & ( ClassWriter . TYPE_UNINIT + ( < any > type . toString ( ) ) + offset ) ; let result = this . get ( this . key ) ; if ( result == null ) { result = this . addType ( this . key ) ; } return result . index ; } /**
     * Adds the given Item to  {@link #typeTable} .
     *
     *  param item return private addType$Item ( item ) { throw new Error ( "not supported" ) ; } /**
     * Returns the index of the common super type of the two given types. This
     * method calls  {@link #getCommonSuperClass} and caches the result in the
     *  {@link #items} hash table to speedup future calls with the same
     * parameters.
     *
     *  param type1 index of an internal name in  {@link #typeTable} .
     *  param type2 index of an internal name in  {@link #typeTable} .
     *  return getMergedType ( type1 , type2 ) { throw new Error ( "not supported" ) ; } param type1 param type2 return getCommonSuperClass ( type1 , type2 ) { return "java/lang/Object" ; } param key return private get ( key ) { let i = this . items [ key . __hashCode % this . items . length ] ; while ( ( i != null && ( i . type !== key . type || ! key . isEqualTo ( i ) ) ) ) { i = i . next ; } ; return i ; } param i private put ( i ) { if ( this . index + this . typeCount > this . threshold ) { let ll = this . items . length ; let nl = ll * 2 + 1 ; let newItems = new Array ( nl ) ; for ( let l = ll - 1 ; l >= 0 ; -- l ) { let j = this . items [ l ] ; while ( ( j != null ) ) { let index = j . __hashCode % newItems . length ; let k = j . next ; j . next = newItems [ index ] ; newItems [ index ] = j ; j = k ; } ; } this . items = newItems ; this . threshold = ( ( nl * 0.75 ) | 0 ) ; } let index = i . __hashCode % this . items . length ; i . next = this . items [ index ] ; this . items [ index ] = i ; } param b param s1 param s2 private put122 ( b , s1 , s2 ) { this . pool . put12 ( b , s1 ) . putShort ( s2 ) ; } param b1 param b2 param s private put112 ( b1 , b2 , s ) { this . pool . put11 ( b1 , b2 ) . putShort ( s ) ; } } ClassWriter . TYPE_$LI$ ( ) ; ClassWriter . TO_ACC_SYNTHETIC_$LI$ ( ) ; ClassWriter . __static_initialize ( ) ;