Ejemplo n.º 1
0
        // insnNode now belongs to an InsnList.
        /// <summary>Inserts the given instructions before the specified instruction.</summary>
        /// <param name="nextInsn">
        ///     an instruction <i>of this list</i> before which the instructions must be
        ///     inserted.
        /// </param>
        /// <param name="insnList">
        ///     the instruction list to be inserted, which is cleared during the process. This
        ///     list must be different from 'this'.
        /// </param>
        public virtual void InsertBefore(AbstractInsnNode nextInsn, InsnList insnList)
        {
            if (insnList.size == 0)
            {
                return;
            }
            size__ += insnList.size;
            var firstInsnListElement = insnList.firstInsn;
            var lastInsnListElement  = insnList.lastInsn;
            var previousInsn         = nextInsn.previousInsn;

            if (previousInsn == null)
            {
                firstInsn = firstInsnListElement;
            }
            else
            {
                previousInsn.nextInsn = firstInsnListElement;
            }
            nextInsn.previousInsn             = lastInsnListElement;
            lastInsnListElement.nextInsn      = nextInsn;
            firstInsnListElement.previousInsn = previousInsn;
            cache = null;
            insnList.RemoveAll(false);
        }
Ejemplo n.º 2
0
 /// <summary>
 ///     Constructs a new
 ///     <see cref="MethodNode" />
 ///     .
 /// </summary>
 /// <param name="api">
 ///     the ASM API version implemented by this visitor. Must be one of
 ///     <see cref="Org.Objectweb.Asm.Opcodes.Asm4" />
 ///     ,
 ///     <see cref="Org.Objectweb.Asm.Opcodes.Asm5" />
 ///     ,
 ///     <see cref="Org.Objectweb.Asm.Opcodes.Asm6" />
 ///     or
 ///     <see cref="Org.Objectweb.Asm.Opcodes.Asm7" />
 ///     .
 /// </param>
 /// <param name="access">
 ///     the method's access flags (see
 ///     <see cref="Org.Objectweb.Asm.Opcodes" />
 ///     ). This parameter also indicates if
 ///     the method is synthetic and/or deprecated.
 /// </param>
 /// <param name="name">the method's name.</param>
 /// <param name="descriptor">
 ///     the method's descriptor (see
 ///     <see cref="Org.Objectweb.Asm.Type" />
 ///     ).
 /// </param>
 /// <param name="signature">
 ///     the method's signature. May be
 ///     <literal>null</literal>
 ///     .
 /// </param>
 /// <param name="exceptions">
 ///     the internal names of the method's exception classes (see
 ///     <see cref="Org.Objectweb.Asm.Type.GetInternalName()" />
 ///     ). May be
 ///     <literal>null</literal>
 ///     .
 /// </param>
 public MethodNode(VisitorAsmApiVersion api, AccessFlags access, string name, string descriptor, string signature
                   , string[] exceptions)
     : base(api)
 {
     this.access     = access;
     this.name       = name;
     desc            = descriptor;
     this.signature  = signature;
     this.exceptions = Util.AsArrayList(exceptions);
     if (access.HasNotFlagFast(AccessFlags.Abstract))
     {
         localVariables = new List <LocalVariableNode>(5);
     }
     tryCatchBlocks = new List <TryCatchBlockNode>();
     instructions   = new InsnList();
 }
Ejemplo n.º 3
0
        // insnNode now belongs to an InsnList.
        /// <summary>Inserts the given instructions at the beginning of this list.</summary>
        /// <param name="insnList">
        ///     an instruction list, which is cleared during the process. This list must be
        ///     different from 'this'.
        /// </param>
        public virtual void Insert(InsnList insnList)
        {
            if (insnList.size == 0)
            {
                return;
            }
            size__ += insnList.size;
            if (firstInsn == null)
            {
                firstInsn = insnList.firstInsn;
                lastInsn  = insnList.lastInsn;
            }
            else
            {
                var lastInsnListElement = insnList.lastInsn;
                firstInsn.previousInsn       = lastInsnListElement;
                lastInsnListElement.nextInsn = firstInsn;
                firstInsn = insnList.firstInsn;
            }

            cache = null;
            insnList.RemoveAll(false);
        }
Ejemplo n.º 4
0
        // insnNode now belongs to an InsnList.
        /// <summary>Adds the given instructions to the end of this list.</summary>
        /// <param name="insnList">
        ///     an instruction list, which is cleared during the process. This list must be
        ///     different from 'this'.
        /// </param>
        public virtual void Add(InsnList insnList)
        {
            if (insnList.Size() == 0)
            {
                return;
            }
            size__ += insnList.Size();
            if (lastInsn == null)
            {
                firstInsn = insnList.firstInsn;
                lastInsn  = insnList.lastInsn;
            }
            else
            {
                var firstInsnListElement = insnList.firstInsn;
                lastInsn.nextInsn = firstInsnListElement;
                firstInsnListElement.previousInsn = lastInsn;
                lastInsn = insnList.lastInsn;
            }

            cache = null;
            insnList.RemoveAll(false);
        }
Ejemplo n.º 5
0
 /// <summary>
 ///     Constructs an uninitialized
 ///     <see cref="MethodNode" />
 ///     .
 /// </summary>
 /// <param name="api">
 ///     the ASM API version implemented by this visitor. Must be one of
 ///     <see cref="Org.Objectweb.Asm.Opcodes.Asm4" />
 ///     ,
 ///     <see cref="Org.Objectweb.Asm.Opcodes.Asm5" />
 ///     ,
 ///     <see cref="Org.Objectweb.Asm.Opcodes.Asm6" />
 ///     or
 ///     <see cref="Org.Objectweb.Asm.Opcodes.Asm7" />
 ///     .
 /// </param>
 public MethodNode(VisitorAsmApiVersion api)
     : base(api)
 {
     instructions = new InsnList();
 }