/** * Removes all of the instructions of this list. */ public void clear() { removeAll(false); }
/** * Adds the given instructions to the end of this list. * * @param insns * an instruction list, which is cleared during the process. This * list must be different from 'this'. */ public void add(final InsnList insns) { if (insns.size == 0) { return; } size += insns.size; if (last == null) { first = insns.first; last = insns.last; } else { AbstractInsnNode elem = insns.first; last.next = elem; elem.prev = last; last = insns.last; } cache = null; insns.removeAll(false); }
/** * Inserts the given instructions at the begining of this list. * * @param insns * an instruction list, which is cleared during the process. This * list must be different from 'this'. */ public void insert(final InsnList insns) { if (insns.size == 0) { return; } size += insns.size; if (first == null) { first = insns.first; last = insns.last; } else { AbstractInsnNode elem = insns.last; first.prev = elem; elem.next = first; first = insns.first; } cache = null; insns.removeAll(false); }
/** * Inserts the given instructions after the specified instruction. * * @param location * an instruction <i>of this list</i> after which the * instructions must be inserted. * @param insns * the instruction list to be inserted, which is cleared during * the process. This list must be different from 'this'. */ public void insert(final AbstractInsnNode location, final InsnList insns) { if (insns.size == 0) { return; } size += insns.size; AbstractInsnNode ifirst = insns.first; AbstractInsnNode ilast = insns.last; AbstractInsnNode next = location.next; if (next == null) { last = ilast; } else { next.prev = ilast; } location.next = ifirst; ilast.next = next; ifirst.prev = location; cache = null; insns.removeAll(false); }
/** * Inserts the given instructions before the specified instruction. * * @param location * an instruction <i>of this list</i> before which the * instructions must be inserted. * @param insns * the instruction list to be inserted, which is cleared during * the process. This list must be different from 'this'. */ public void insertBefore(final AbstractInsnNode location, final InsnList insns) { if (insns.size == 0) { return; } size += insns.size; AbstractInsnNode ifirst = insns.first; AbstractInsnNode ilast = insns.last; AbstractInsnNode prev = location.prev; if (prev == null) { first = ifirst; } else { prev.next = ifirst; } location.prev = ilast; ilast.next = location; ifirst.prev = prev; cache = null; insns.removeAll(false); }