src/share/classes/jdk/internal/org/objectweb/asm/tree/InsnList.java
Print this page
*** 100,111 ****
}
/**
* Returns the first instruction in this list.
*
! * @return the first instruction in this list, or <tt>null</tt> if the
! * list is empty.
*/
public AbstractInsnNode getFirst() {
return first;
}
--- 100,111 ----
}
/**
* Returns the first instruction in this list.
*
! * @return the first instruction in this list, or <tt>null</tt> if the list
! * is empty.
*/
public AbstractInsnNode getFirst() {
return first;
}
*** 123,135 ****
* Returns the instruction whose index is given. This method builds a cache
* of the instructions in this list to avoid scanning the whole list each
* time it is called. Once the cache is built, this method run in constant
* time. This cache is invalidated by all the methods that modify the list.
*
! * @param index the index of the instruction that must be returned.
* @return the instruction whose index is given.
! * @throws IndexOutOfBoundsException if (index < 0 || index >= size()).
*/
public AbstractInsnNode get(final int index) {
if (index < 0 || index >= size) {
throw new IndexOutOfBoundsException();
}
--- 123,137 ----
* Returns the instruction whose index is given. This method builds a cache
* of the instructions in this list to avoid scanning the whole list each
* time it is called. Once the cache is built, this method run in constant
* time. This cache is invalidated by all the methods that modify the list.
*
! * @param index
! * the index of the instruction that must be returned.
* @return the instruction whose index is given.
! * @throws IndexOutOfBoundsException
! * if (index < 0 || index >= size()).
*/
public AbstractInsnNode get(final int index) {
if (index < 0 || index >= size) {
throw new IndexOutOfBoundsException();
}
*** 138,152 ****
}
return cache[index];
}
/**
! * Returns <tt>true</tt> if the given instruction belongs to this list.
! * This method always scans the instructions of this list until it finds the
* given instruction or reaches the end of the list.
*
! * @param insn an instruction.
* @return <tt>true</tt> if the given instruction belongs to this list.
*/
public boolean contains(final AbstractInsnNode insn) {
AbstractInsnNode i = first;
while (i != null && i != insn) {
--- 140,155 ----
}
return cache[index];
}
/**
! * Returns <tt>true</tt> if the given instruction belongs to this list. This
! * method always scans the instructions of this list until it finds the
* given instruction or reaches the end of the list.
*
! * @param insn
! * an instruction.
* @return <tt>true</tt> if the given instruction belongs to this list.
*/
public boolean contains(final AbstractInsnNode insn) {
AbstractInsnNode i = first;
while (i != null && i != insn) {
*** 160,170 ****
* builds a cache of the instruction indexes to avoid scanning the whole
* list each time it is called. Once the cache is built, this method run in
* constant time. The cache is invalidated by all the methods that modify
* the list.
*
! * @param insn an instruction <i>of this list</i>.
* @return the index of the given instruction in this list. <i>The result of
* this method is undefined if the given instruction does not belong
* to this list</i>. Use {@link #contains contains} to test if an
* instruction belongs to an instruction list or not.
*/
--- 163,174 ----
* builds a cache of the instruction indexes to avoid scanning the whole
* list each time it is called. Once the cache is built, this method run in
* constant time. The cache is invalidated by all the methods that modify
* the list.
*
! * @param insn
! * an instruction <i>of this list</i>.
* @return the index of the given instruction in this list. <i>The result of
* this method is undefined if the given instruction does not belong
* to this list</i>. Use {@link #contains contains} to test if an
* instruction belongs to an instruction list or not.
*/
*** 176,186 ****
}
/**
* Makes the given visitor visit all of the instructions in this list.
*
! * @param mv the method visitor that must visit the instructions.
*/
public void accept(final MethodVisitor mv) {
AbstractInsnNode insn = first;
while (insn != null) {
insn.accept(mv);
--- 180,191 ----
}
/**
* Makes the given visitor visit all of the instructions in this list.
*
! * @param mv
! * the method visitor that must visit the instructions.
*/
public void accept(final MethodVisitor mv) {
AbstractInsnNode insn = first;
while (insn != null) {
insn.accept(mv);
*** 225,236 ****
}
/**
* Replaces an instruction of this list with another instruction.
*
! * @param location an instruction <i>of this list</i>.
! * @param insn another instruction, <i>which must not belong to any
* {@link InsnList}</i>.
*/
public void set(final AbstractInsnNode location, final AbstractInsnNode insn) {
AbstractInsnNode next = location.next;
insn.next = next;
--- 230,243 ----
}
/**
* Replaces an instruction of this list with another instruction.
*
! * @param location
! * an instruction <i>of this list</i>.
! * @param insn
! * another instruction, <i>which must not belong to any
* {@link InsnList}</i>.
*/
public void set(final AbstractInsnNode location, final AbstractInsnNode insn) {
AbstractInsnNode next = location.next;
insn.next = next;
*** 259,269 ****
}
/**
* Adds the given instruction to the end of this list.
*
! * @param insn an instruction, <i>which must not belong to any
* {@link InsnList}</i>.
*/
public void add(final AbstractInsnNode insn) {
++size;
if (last == null) {
--- 266,277 ----
}
/**
* Adds the given instruction to the end of this list.
*
! * @param insn
! * an instruction, <i>which must not belong to any
* {@link InsnList}</i>.
*/
public void add(final AbstractInsnNode insn) {
++size;
if (last == null) {
*** 279,290 ****
}
/**
* 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;
}
--- 287,299 ----
}
/**
* 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;
}
*** 303,313 ****
}
/**
* Inserts the given instruction at the begining of this list.
*
! * @param insn an instruction, <i>which must not belong to any
* {@link InsnList}</i>.
*/
public void insert(final AbstractInsnNode insn) {
++size;
if (first == null) {
--- 312,323 ----
}
/**
* Inserts the given instruction at the begining of this list.
*
! * @param insn
! * an instruction, <i>which must not belong to any
* {@link InsnList}</i>.
*/
public void insert(final AbstractInsnNode insn) {
++size;
if (first == null) {
*** 323,334 ****
}
/**
* 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;
}
--- 333,345 ----
}
/**
* 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;
}
*** 347,362 ****
}
/**
* Inserts the given instruction after the specified instruction.
*
! * @param location an instruction <i>of this list</i> after which insn must be
* inserted.
! * @param insn the instruction to be inserted, <i>which must not belong to
* any {@link InsnList}</i>.
*/
! public void insert(final AbstractInsnNode location, final AbstractInsnNode insn) {
++size;
AbstractInsnNode next = location.next;
if (next == null) {
last = insn;
} else {
--- 358,376 ----
}
/**
* Inserts the given instruction after the specified instruction.
*
! * @param location
! * an instruction <i>of this list</i> after which insn must be
* inserted.
! * @param insn
! * the instruction to be inserted, <i>which must not belong to
* any {@link InsnList}</i>.
*/
! public void insert(final AbstractInsnNode location,
! final AbstractInsnNode insn) {
++size;
AbstractInsnNode next = location.next;
if (next == null) {
last = insn;
} else {
*** 370,382 ****
}
/**
* 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;
--- 384,398 ----
}
/**
* 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;
*** 398,413 ****
}
/**
* Inserts the given instruction before the specified instruction.
*
! * @param location an instruction <i>of this list</i> before which insn must be
* inserted.
! * @param insn the instruction to be inserted, <i>which must not belong to
* any {@link InsnList}</i>.
*/
! public void insertBefore(final AbstractInsnNode location, final AbstractInsnNode insn) {
++size;
AbstractInsnNode prev = location.prev;
if (prev == null) {
first = insn;
} else {
--- 414,432 ----
}
/**
* Inserts the given instruction before the specified instruction.
*
! * @param location
! * an instruction <i>of this list</i> before which insn must be
* inserted.
! * @param insn
! * the instruction to be inserted, <i>which must not belong to
* any {@link InsnList}</i>.
*/
! public void insertBefore(final AbstractInsnNode location,
! final AbstractInsnNode insn) {
++size;
AbstractInsnNode prev = location.prev;
if (prev == null) {
first = insn;
} else {
*** 421,461 ****
}
/**
* 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);
}
-
-
/**
* Removes the given instruction from this list.
*
! * @param insn the instruction <i>of this list</i> that must be removed.
*/
public void remove(final AbstractInsnNode insn) {
--size;
AbstractInsnNode next = insn.next;
AbstractInsnNode prev = insn.prev;
--- 440,482 ----
}
/**
* 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);
}
/**
* Removes the given instruction from this list.
*
! * @param insn
! * the instruction <i>of this list</i> that must be removed.
*/
public void remove(final AbstractInsnNode insn) {
--size;
AbstractInsnNode next = insn.next;
AbstractInsnNode prev = insn.prev;
*** 483,493 ****
}
/**
* Removes all of the instructions of this list.
*
! * @param mark if the instructions must be marked as no longer belonging to
* any {@link InsnList}.
*/
void removeAll(final boolean mark) {
if (mark) {
AbstractInsnNode insn = first;
--- 504,515 ----
}
/**
* Removes all of the instructions of this list.
*
! * @param mark
! * if the instructions must be marked as no longer belonging to
* any {@link InsnList}.
*/
void removeAll(final boolean mark) {
if (mark) {
AbstractInsnNode insn = first;
*** 526,543 ****
insn = insn.next;
}
}
// this class is not generified because it will create bridges
! private final class InsnListIterator implements ListIterator/*<AbstractInsnNode>*/ {
AbstractInsnNode next;
AbstractInsnNode prev;
InsnListIterator(int index) {
! if(index==size()) {
next = null;
prev = getLast();
} else {
next = get(index);
prev = next.prev;
--- 548,565 ----
insn = insn.next;
}
}
// this class is not generified because it will create bridges
! private final class InsnListIterator implements ListIterator {
AbstractInsnNode next;
AbstractInsnNode prev;
InsnListIterator(int index) {
! if (index == size()) {
next = null;
prev = getLast();
} else {
next = get(index);
prev = next.prev;