< prev index next >

src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/InstructionList.java

Print this page

        

*** 1,7 **** /* ! * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. --- 1,7 ---- /* ! * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership.
*** 42,56 **** * controlled way. * * A list is finally dumped to a byte code array with <a * href="#getByteCode()">getByteCode</a>. * - * @version $Id$ * @see Instruction * @see InstructionHandle * @see BranchHandle ! * @LastModified: Jun 2019 */ public class InstructionList implements Iterable<InstructionHandle> { private InstructionHandle start = null; private InstructionHandle end = null; --- 42,55 ---- * controlled way. * * A list is finally dumped to a byte code array with <a * href="#getByteCode()">getByteCode</a>. * * @see Instruction * @see InstructionHandle * @see BranchHandle ! * @LastModified: Jan 2020 */ public class InstructionList implements Iterable<InstructionHandle> { private InstructionHandle start = null; private InstructionHandle end = null;
*** 64,93 **** } /** * Create instruction list containing one instruction. * ! * @param i initial instruction */ public InstructionList(final Instruction i) { append(i); } /** * Create instruction list containing one instruction. * ! * @param i initial instruction */ public InstructionList(final BranchInstruction i) { append(i); } /** * Initialize list with (nonnull) compound instruction. Consumes argument * list, i.e., it becomes empty. * ! * @param c compound instruction (list) */ public InstructionList(final CompoundInstruction c) { append(c.getInstructionList()); } --- 63,95 ---- } /** * Create instruction list containing one instruction. * ! * @param i ! * initial instruction */ public InstructionList(final Instruction i) { append(i); } /** * Create instruction list containing one instruction. * ! * @param i ! * initial instruction */ public InstructionList(final BranchInstruction i) { append(i); } /** * Initialize list with (nonnull) compound instruction. Consumes argument * list, i.e., it becomes empty. * ! * @param c ! * compound instruction (list) */ public InstructionList(final CompoundInstruction c) { append(c.getInstructionList()); }
*** 100,124 **** /** * Find the target instruction (handle) that corresponds to the given target * position (byte code offset). * ! * @param ihs array of instruction handles, i.e. il.getInstructionHandles() ! * @param pos array of positions corresponding to ihs, i.e. ! * il.getInstructionPositions() ! * @param count length of arrays ! * @param target target position to search for * @return target position's instruction handle if available */ ! public static InstructionHandle findHandle(final InstructionHandle[] ihs, final int[] pos, final int count, final int target) { int l = 0; int r = count - 1; /* * Do a binary search since the pos array is orderd. */ do { ! final int i = (l + r) / 2; final int j = pos[i]; if (j == target) { return ihs[i]; } else if (target < j) { r = i - 1; --- 102,130 ---- /** * Find the target instruction (handle) that corresponds to the given target * position (byte code offset). * ! * @param ihs ! * array of instruction handles, i.e. il.getInstructionHandles() ! * @param pos ! * array of positions corresponding to ihs, i.e. il.getInstructionPositions() ! * @param count ! * length of arrays ! * @param target ! * target position to search for * @return target position's instruction handle if available */ ! public static InstructionHandle findHandle(final InstructionHandle[] ihs, ! final int[] pos, final int count, final int target) { int l = 0; int r = count - 1; /* * Do a binary search since the pos array is orderd. */ do { ! final int i = (l + r) >>> 1; final int j = pos[i]; if (j == target) { return ihs[i]; } else if (target < j) { r = i - 1;
*** 132,142 **** /** * Get instruction handle for instruction at byte code position pos. This * only works properly, if the list is freshly initialized from a byte array * or setPositions() has been called before this method. * ! * @param pos byte code position to search for * @return target position's instruction handle if available */ public InstructionHandle findHandle(final int pos) { final int[] positions = byte_positions; InstructionHandle ih = start; --- 138,149 ---- /** * Get instruction handle for instruction at byte code position pos. This * only works properly, if the list is freshly initialized from a byte array * or setPositions() has been called before this method. * ! * @param pos ! * byte code position to search for * @return target position's instruction handle if available */ public InstructionHandle findHandle(final int pos) { final int[] positions = byte_positions; InstructionHandle ih = start;
*** 150,160 **** } /** * Initialize instruction list from byte array. * ! * @param code byte array containing the instructions */ public InstructionList(final byte[] code) { int count = 0; // Contains actual length int[] pos; InstructionHandle[] ihs; --- 157,168 ---- } /** * Initialize instruction list from byte array. * ! * @param code ! * byte array containing the instructions */ public InstructionList(final byte[] code) { int count = 0; // Contains actual length int[] pos; InstructionHandle[] ihs;
*** 222,235 **** /** * Append another list after instruction (handle) ih contained in this list. * Consumes argument list, i.e., it becomes empty. * ! * @param ih where to append the instruction list ! * @param il Instruction list to append to this one ! * @return instruction handle pointing to the <B>first</B> appended ! * instruction */ public InstructionHandle append(final InstructionHandle ih, final InstructionList il) { if (il == null) { throw new ClassGenException("Appending null InstructionList"); } --- 230,244 ---- /** * Append another list after instruction (handle) ih contained in this list. * Consumes argument list, i.e., it becomes empty. * ! * @param ih ! * where to append the instruction list ! * @param il ! * Instruction list to append to this one ! * @return instruction handle pointing to the <B>first</B> appended instruction */ public InstructionHandle append(final InstructionHandle ih, final InstructionList il) { if (il == null) { throw new ClassGenException("Appending null InstructionList"); }
*** 253,266 **** /** * Append another list after instruction i contained in this list. Consumes * argument list, i.e., it becomes empty. * ! * @param i where to append the instruction list ! * @param il Instruction list to append to this one ! * @return instruction handle pointing to the <B>first</B> appended ! * instruction */ public InstructionHandle append(final Instruction i, final InstructionList il) { InstructionHandle ih; if ((ih = findInstruction2(i)) == null) { throw new ClassGenException("Instruction " + i + " is not contained in this list."); --- 262,276 ---- /** * Append another list after instruction i contained in this list. Consumes * argument list, i.e., it becomes empty. * ! * @param i ! * where to append the instruction list ! * @param il ! * Instruction list to append to this one ! * @return instruction handle pointing to the <B>first</B> appended instruction */ public InstructionHandle append(final Instruction i, final InstructionList il) { InstructionHandle ih; if ((ih = findInstruction2(i)) == null) { throw new ClassGenException("Instruction " + i + " is not contained in this list.");
*** 270,280 **** /** * Append another list to this one. Consumes argument list, i.e., it becomes * empty. * ! * @param il list to append to end of this list * @return instruction handle of the <B>first</B> appended instruction */ public InstructionHandle append(final InstructionList il) { if (il == null) { throw new ClassGenException("Appending null InstructionList"); --- 280,291 ---- /** * Append another list to this one. Consumes argument list, i.e., it becomes * empty. * ! * @param il ! * list to append to end of this list * @return instruction handle of the <B>first</B> appended instruction */ public InstructionHandle append(final InstructionList il) { if (il == null) { throw new ClassGenException("Appending null InstructionList");
*** 293,303 **** } /** * Append an instruction to the end of this list. * ! * @param ih instruction to append */ private void append(final InstructionHandle ih) { if (isEmpty()) { start = end = ih; ih.setNext(ih.setPrev(null)); --- 304,315 ---- } /** * Append an instruction to the end of this list. * ! * @param ih ! * instruction to append */ private void append(final InstructionHandle ih) { if (isEmpty()) { start = end = ih; ih.setNext(ih.setPrev(null));
*** 305,322 **** end.setNext(ih); ih.setPrev(end); ih.setNext(null); end = ih; } - length++; // Update length } /** * Append an instruction to the end of this list. * ! * @param i instruction to append * @return instruction handle of the appended instruction */ public InstructionHandle append(final Instruction i) { final InstructionHandle ih = InstructionHandle.getInstructionHandle(i); append(ih); --- 317,334 ---- end.setNext(ih); ih.setPrev(end); ih.setNext(null); end = ih; } length++; // Update length } /** * Append an instruction to the end of this list. * ! * @param i ! * instruction to append * @return instruction handle of the appended instruction */ public InstructionHandle append(final Instruction i) { final InstructionHandle ih = InstructionHandle.getInstructionHandle(i); append(ih);
*** 324,334 **** } /** * Append a branch instruction to the end of this list. * ! * @param i branch instruction to append * @return branch instruction handle of the appended instruction */ public BranchHandle append(final BranchInstruction i) { final BranchHandle ih = BranchHandle.getBranchHandle(i); append(ih); --- 336,347 ---- } /** * Append a branch instruction to the end of this list. * ! * @param i ! * branch instruction to append * @return branch instruction handle of the appended instruction */ public BranchHandle append(final BranchInstruction i) { final BranchHandle ih = BranchHandle.getBranchHandle(i); append(ih);
*** 337,407 **** /** * Append a single instruction j after another instruction i, which must be * in this list of course! * ! * @param i Instruction in list ! * @param j Instruction to append after i in list * @return instruction handle of the first appended instruction */ public InstructionHandle append(final Instruction i, final Instruction j) { return append(i, new InstructionList(j)); } /** * Append a compound instruction, after instruction i. * ! * @param i Instruction in list ! * @param c The composite instruction (containing an InstructionList) * @return instruction handle of the first appended instruction */ public InstructionHandle append(final Instruction i, final CompoundInstruction c) { return append(i, c.getInstructionList()); } /** * Append a compound instruction. * ! * @param c The composite instruction (containing an InstructionList) * @return instruction handle of the first appended instruction */ public InstructionHandle append(final CompoundInstruction c) { return append(c.getInstructionList()); } /** * Append a compound instruction. * ! * @param ih where to append the instruction list ! * @param c The composite instruction (containing an InstructionList) * @return instruction handle of the first appended instruction */ public InstructionHandle append(final InstructionHandle ih, final CompoundInstruction c) { return append(ih, c.getInstructionList()); } /** ! * Append an instruction after instruction (handle) ih contained in this ! * list. * ! * @param ih where to append the instruction list ! * @param i Instruction to append ! * @return instruction handle pointing to the <B>first</B> appended ! * instruction */ public InstructionHandle append(final InstructionHandle ih, final Instruction i) { return append(ih, new InstructionList(i)); } /** ! * Append an instruction after instruction (handle) ih contained in this ! * list. * ! * @param ih where to append the instruction list ! * @param i Instruction to append ! * @return instruction handle pointing to the <B>first</B> appended ! * instruction */ public BranchHandle append(final InstructionHandle ih, final BranchInstruction i) { final BranchHandle bh = BranchHandle.getBranchHandle(i); final InstructionList il = new InstructionList(); il.append(bh); --- 350,427 ---- /** * Append a single instruction j after another instruction i, which must be * in this list of course! * ! * @param i ! * Instruction in list ! * @param j ! * Instruction to append after i in list * @return instruction handle of the first appended instruction */ public InstructionHandle append(final Instruction i, final Instruction j) { return append(i, new InstructionList(j)); } /** * Append a compound instruction, after instruction i. * ! * @param i ! * Instruction in list ! * @param c ! * The composite instruction (containing an InstructionList) * @return instruction handle of the first appended instruction */ public InstructionHandle append(final Instruction i, final CompoundInstruction c) { return append(i, c.getInstructionList()); } /** * Append a compound instruction. * ! * @param c ! * The composite instruction (containing an InstructionList) * @return instruction handle of the first appended instruction */ public InstructionHandle append(final CompoundInstruction c) { return append(c.getInstructionList()); } /** * Append a compound instruction. * ! * @param ih ! * where to append the instruction list ! * @param c ! * The composite instruction (containing an InstructionList) * @return instruction handle of the first appended instruction */ public InstructionHandle append(final InstructionHandle ih, final CompoundInstruction c) { return append(ih, c.getInstructionList()); } /** ! * Append an instruction after instruction (handle) ih contained in this list. * ! * @param ih ! * where to append the instruction list ! * @param i ! * Instruction to append ! * @return instruction handle pointing to the <B>first</B> appended instruction */ public InstructionHandle append(final InstructionHandle ih, final Instruction i) { return append(ih, new InstructionList(i)); } /** ! * Append an instruction after instruction (handle) ih contained in this list. * ! * @param ih ! * where to append the instruction list ! * @param i ! * Instruction to append ! * @return instruction handle pointing to the <B>first</B> appended instruction */ public BranchHandle append(final InstructionHandle ih, final BranchInstruction i) { final BranchHandle bh = BranchHandle.getBranchHandle(i); final InstructionList il = new InstructionList(); il.append(bh);
*** 411,422 **** /** * Insert another list before Instruction handle ih contained in this list. * Consumes argument list, i.e., it becomes empty. * ! * @param ih where to append the instruction list ! * @param il Instruction list to insert * @return instruction handle of the first inserted instruction */ public InstructionHandle insert(final InstructionHandle ih, final InstructionList il) { if (il == null) { throw new ClassGenException("Inserting null InstructionList"); --- 431,444 ---- /** * Insert another list before Instruction handle ih contained in this list. * Consumes argument list, i.e., it becomes empty. * ! * @param ih ! * where to append the instruction list ! * @param il ! * Instruction list to insert * @return instruction handle of the first inserted instruction */ public InstructionHandle insert(final InstructionHandle ih, final InstructionList il) { if (il == null) { throw new ClassGenException("Inserting null InstructionList");
*** 440,450 **** } /** * Insert another list. * ! * @param il list to insert before start of this list * @return instruction handle of the first inserted instruction */ public InstructionHandle insert(final InstructionList il) { if (isEmpty()) { append(il); // Code is identical for this case --- 462,473 ---- } /** * Insert another list. * ! * @param il ! * list to insert before start of this list * @return instruction handle of the first inserted instruction */ public InstructionHandle insert(final InstructionList il) { if (isEmpty()) { append(il); // Code is identical for this case
*** 454,464 **** } /** * Insert an instruction at start of this list. * ! * @param ih instruction to insert */ private void insert(final InstructionHandle ih) { if (isEmpty()) { start = end = ih; ih.setNext(ih.setPrev(null)); --- 477,488 ---- } /** * Insert an instruction at start of this list. * ! * @param ih ! * instruction to insert */ private void insert(final InstructionHandle ih) { if (isEmpty()) { start = end = ih; ih.setNext(ih.setPrev(null));
*** 473,486 **** /** * Insert another list before Instruction i contained in this list. Consumes * argument list, i.e., it becomes empty. * ! * @param i where to append the instruction list ! * @param il Instruction list to insert ! * @return instruction handle pointing to the first inserted instruction, ! * i.e., il.getStart() */ public InstructionHandle insert(final Instruction i, final InstructionList il) { InstructionHandle ih; if ((ih = findInstruction1(i)) == null) { throw new ClassGenException("Instruction " + i + " is not contained in this list."); --- 497,511 ---- /** * Insert another list before Instruction i contained in this list. Consumes * argument list, i.e., it becomes empty. * ! * @param i ! * where to append the instruction list ! * @param il ! * Instruction list to insert ! * @return instruction handle pointing to the first inserted instruction, i.e., il.getStart() */ public InstructionHandle insert(final Instruction i, final InstructionList il) { InstructionHandle ih; if ((ih = findInstruction1(i)) == null) { throw new ClassGenException("Instruction " + i + " is not contained in this list.");
*** 489,499 **** } /** * Insert an instruction at start of this list. * ! * @param i instruction to insert * @return instruction handle of the inserted instruction */ public InstructionHandle insert(final Instruction i) { final InstructionHandle ih = InstructionHandle.getInstructionHandle(i); insert(ih); --- 514,525 ---- } /** * Insert an instruction at start of this list. * ! * @param i ! * instruction to insert * @return instruction handle of the inserted instruction */ public InstructionHandle insert(final Instruction i) { final InstructionHandle ih = InstructionHandle.getInstructionHandle(i); insert(ih);
*** 501,511 **** } /** * Insert a branch instruction at start of this list. * ! * @param i branch instruction to insert * @return branch instruction handle of the appended instruction */ public BranchHandle insert(final BranchInstruction i) { final BranchHandle ih = BranchHandle.getBranchHandle(i); insert(ih); --- 527,538 ---- } /** * Insert a branch instruction at start of this list. * ! * @param i ! * branch instruction to insert * @return branch instruction handle of the appended instruction */ public BranchHandle insert(final BranchInstruction i) { final BranchHandle ih = BranchHandle.getBranchHandle(i); insert(ih);
*** 514,581 **** /** * Insert a single instruction j before another instruction i, which must be * in this list of course! * ! * @param i Instruction in list ! * @param j Instruction to insert before i in list * @return instruction handle of the first inserted instruction */ public InstructionHandle insert(final Instruction i, final Instruction j) { return insert(i, new InstructionList(j)); } /** * Insert a compound instruction before instruction i. * ! * @param i Instruction in list ! * @param c The composite instruction (containing an InstructionList) * @return instruction handle of the first inserted instruction */ public InstructionHandle insert(final Instruction i, final CompoundInstruction c) { return insert(i, c.getInstructionList()); } /** * Insert a compound instruction. * ! * @param c The composite instruction (containing an InstructionList) * @return instruction handle of the first inserted instruction */ public InstructionHandle insert(final CompoundInstruction c) { return insert(c.getInstructionList()); } /** ! * Insert an instruction before instruction (handle) ih contained in this ! * list. * ! * @param ih where to insert to the instruction list ! * @param i Instruction to insert * @return instruction handle of the first inserted instruction */ public InstructionHandle insert(final InstructionHandle ih, final Instruction i) { return insert(ih, new InstructionList(i)); } /** * Insert a compound instruction. * ! * @param ih where to insert the instruction list ! * @param c The composite instruction (containing an InstructionList) * @return instruction handle of the first inserted instruction */ public InstructionHandle insert(final InstructionHandle ih, final CompoundInstruction c) { return insert(ih, c.getInstructionList()); } /** ! * Insert an instruction before instruction (handle) ih contained in this ! * list. * ! * @param ih where to insert to the instruction list ! * @param i Instruction to insert * @return instruction handle of the first inserted instruction */ public BranchHandle insert(final InstructionHandle ih, final BranchInstruction i) { final BranchHandle bh = BranchHandle.getBranchHandle(i); final InstructionList il = new InstructionList(); --- 541,617 ---- /** * Insert a single instruction j before another instruction i, which must be * in this list of course! * ! * @param i ! * Instruction in list ! * @param j ! * Instruction to insert before i in list * @return instruction handle of the first inserted instruction */ public InstructionHandle insert(final Instruction i, final Instruction j) { return insert(i, new InstructionList(j)); } /** * Insert a compound instruction before instruction i. * ! * @param i ! * Instruction in list ! * @param c ! * The composite instruction (containing an InstructionList) * @return instruction handle of the first inserted instruction */ public InstructionHandle insert(final Instruction i, final CompoundInstruction c) { return insert(i, c.getInstructionList()); } /** * Insert a compound instruction. * ! * @param c ! * The composite instruction (containing an InstructionList) * @return instruction handle of the first inserted instruction */ public InstructionHandle insert(final CompoundInstruction c) { return insert(c.getInstructionList()); } /** ! * Insert an instruction before instruction (handle) ih contained in this list. * ! * @param ih ! * where to insert to the instruction list ! * @param i ! * Instruction to insert * @return instruction handle of the first inserted instruction */ public InstructionHandle insert(final InstructionHandle ih, final Instruction i) { return insert(ih, new InstructionList(i)); } /** * Insert a compound instruction. * ! * @param ih ! * where to insert the instruction list ! * @param c ! * The composite instruction (containing an InstructionList) * @return instruction handle of the first inserted instruction */ public InstructionHandle insert(final InstructionHandle ih, final CompoundInstruction c) { return insert(ih, c.getInstructionList()); } /** ! * Insert an instruction before instruction (handle) ih contained in this list. * ! * @param ih ! * where to insert to the instruction list ! * @param i ! * Instruction to insert * @return instruction handle of the first inserted instruction */ public BranchHandle insert(final InstructionHandle ih, final BranchInstruction i) { final BranchHandle bh = BranchHandle.getBranchHandle(i); final InstructionList il = new InstructionList();
*** 585,602 **** } /** * Take all instructions (handles) from "start" to "end" and append them * after the new location "target". Of course, "end" must be after "start" ! * and target must not be located withing this range. If you want to move ! * something to the start of the list use null as value for target.<br> * Any instruction targeters pointing to handles within the block, keep * their targets. * ! * @param start of moved block ! * @param end of moved block ! * @param target of moved block */ public void move(final InstructionHandle start, final InstructionHandle end, final InstructionHandle target) { // Step 1: Check constraints if ((start == null) || (end == null)) { throw new ClassGenException("Invalid null handle: From " + start + " to " + end); --- 621,642 ---- } /** * Take all instructions (handles) from "start" to "end" and append them * after the new location "target". Of course, "end" must be after "start" ! * and target must not be located within this range. If you want to move ! * something to the start of the list use null as value for target. ! * <p> * Any instruction targeters pointing to handles within the block, keep * their targets. * ! * @param start ! * of moved block ! * @param end ! * of moved block ! * @param target ! * of moved block */ public void move(final InstructionHandle start, final InstructionHandle end, final InstructionHandle target) { // Step 1: Check constraints if ((start == null) || (end == null)) { throw new ClassGenException("Invalid null handle: From " + start + " to " + end);
*** 646,669 **** } /** * Move a single instruction (handle) to a new location. * ! * @param ih moved instruction ! * @param target new location of moved instruction */ public void move(final InstructionHandle ih, final InstructionHandle target) { move(ih, ih, target); } /** * Remove from instruction `prev' to instruction `next' both contained in * this list. Throws TargetLostException when one of the removed instruction * handles is still being targeted. * ! * @param prev where to start deleting (predecessor, exclusive) ! * @param next where to end deleting (successor, exclusive) */ private void remove(final InstructionHandle prev, InstructionHandle next) throws TargetLostException { InstructionHandle first; InstructionHandle last; // First and last deleted instruction if ((prev == null) && (next == null)) { --- 686,713 ---- } /** * Move a single instruction (handle) to a new location. * ! * @param ih ! * moved instruction ! * @param target ! * new location of moved instruction */ public void move(final InstructionHandle ih, final InstructionHandle target) { move(ih, ih, target); } /** * Remove from instruction `prev' to instruction `next' both contained in * this list. Throws TargetLostException when one of the removed instruction * handles is still being targeted. * ! * @param prev ! * where to start deleting (predecessor, exclusive) ! * @param next ! * where to end deleting (successor, exclusive) */ private void remove(final InstructionHandle prev, InstructionHandle next) throws TargetLostException { InstructionHandle first; InstructionHandle last; // First and last deleted instruction if ((prev == null) && (next == null)) {
*** 714,734 **** /** * Remove instruction from this list. The corresponding Instruction handles * must not be reused! * ! * @param ih instruction (handle) to remove */ public void delete(final InstructionHandle ih) throws TargetLostException { remove(ih.getPrev(), ih.getNext()); } /** ! * Remove instruction from this list. The corresponding Instruction handles ! * must not be reused! * ! * @param i instruction to remove */ public void delete(final Instruction i) throws TargetLostException { InstructionHandle ih; if ((ih = findInstruction1(i)) == null) { throw new ClassGenException("Instruction " + i + " is not contained in this list."); --- 758,779 ---- /** * Remove instruction from this list. The corresponding Instruction handles * must not be reused! * ! * @param ih ! * instruction (handle) to remove */ public void delete(final InstructionHandle ih) throws TargetLostException { remove(ih.getPrev(), ih.getNext()); } /** ! * Remove instruction from this list. The corresponding Instruction handles must not be reused! * ! * @param i ! * instruction to remove */ public void delete(final Instruction i) throws TargetLostException { InstructionHandle ih; if ((ih = findInstruction1(i)) == null) { throw new ClassGenException("Instruction " + i + " is not contained in this list.");
*** 740,751 **** * Remove instructions from instruction `from' to instruction `to' contained * in this list. The user must ensure that `from' is an instruction before * `to', or risk havoc. The corresponding Instruction handles must not be * reused! * ! * @param from where to start deleting (inclusive) ! * @param to where to end deleting (inclusive) */ public void delete(final InstructionHandle from, final InstructionHandle to) throws TargetLostException { remove(from.getPrev(), to.getNext()); } --- 785,798 ---- * Remove instructions from instruction `from' to instruction `to' contained * in this list. The user must ensure that `from' is an instruction before * `to', or risk havoc. The corresponding Instruction handles must not be * reused! * ! * @param from ! * where to start deleting (inclusive) ! * @param to ! * where to end deleting (inclusive) */ public void delete(final InstructionHandle from, final InstructionHandle to) throws TargetLostException { remove(from.getPrev(), to.getNext()); }
*** 753,764 **** * Remove instructions from instruction `from' to instruction `to' contained * in this list. The user must ensure that `from' is an instruction before * `to', or risk havoc. The corresponding Instruction handles must not be * reused! * ! * @param from where to start deleting (inclusive) ! * @param to where to end deleting (inclusive) */ public void delete(final Instruction from, final Instruction to) throws TargetLostException { InstructionHandle from_ih; InstructionHandle to_ih; if ((from_ih = findInstruction1(from)) == null) { --- 800,813 ---- * Remove instructions from instruction `from' to instruction `to' contained * in this list. The user must ensure that `from' is an instruction before * `to', or risk havoc. The corresponding Instruction handles must not be * reused! * ! * @param from ! * where to start deleting (inclusive) ! * @param to ! * where to end deleting (inclusive) */ public void delete(final Instruction from, final Instruction to) throws TargetLostException { InstructionHandle from_ih; InstructionHandle to_ih; if ((from_ih = findInstruction1(from)) == null) {
*** 771,781 **** } /** * Search for given Instruction reference, start at beginning of list. * ! * @param i instruction to search for * @return instruction found on success, null otherwise */ private InstructionHandle findInstruction1(final Instruction i) { for (InstructionHandle ih = start; ih != null; ih = ih.getNext()) { if (ih.getInstruction() == i) { --- 820,831 ---- } /** * Search for given Instruction reference, start at beginning of list. * ! * @param i ! * instruction to search for * @return instruction found on success, null otherwise */ private InstructionHandle findInstruction1(final Instruction i) { for (InstructionHandle ih = start; ih != null; ih = ih.getNext()) { if (ih.getInstruction() == i) {
*** 786,796 **** } /** * Search for given Instruction reference, start at end of list * ! * @param i instruction to search for * @return instruction found on success, null otherwise */ private InstructionHandle findInstruction2(final Instruction i) { for (InstructionHandle ih = end; ih != null; ih = ih.getPrev()) { if (ih.getInstruction() == i) { --- 836,847 ---- } /** * Search for given Instruction reference, start at end of list * ! * @param i ! * instruction to search for * @return instruction found on success, null otherwise */ private InstructionHandle findInstruction2(final Instruction i) { for (InstructionHandle ih = end; ih != null; ih = ih.getPrev()) { if (ih.getInstruction() == i) {
*** 822,833 **** /** * Give all instructions their position number (offset in byte stream), * i.e., make the list ready to be dumped. * ! * @param check Perform sanity checks, e.g. if all targeted instructions ! * really belong to this list */ public void setPositions(final boolean check) { // called by code in other packages int max_additional_bytes = 0; int additional_bytes = 0; int index = 0; --- 873,884 ---- /** * Give all instructions their position number (offset in byte stream), * i.e., make the list ready to be dumped. * ! * @param check ! * Perform sanity checks, e.g. if all targeted instructions really belong to this list */ public void setPositions(final boolean check) { // called by code in other packages int max_additional_bytes = 0; int additional_bytes = 0; int index = 0;
*** 907,923 **** final Instruction i = ih.getInstruction(); ih.setPosition(index); pos[count++] = index; index += i.getLength(); } - if (length == count) { - byte_positions = pos; - } else { byte_positions = new int[count]; // Trim to proper size System.arraycopy(pos, 0, byte_positions, 0, count); } - } /** * When everything is finished, use this method to convert the instruction * list into an array of bytes. * --- 958,970 ----
*** 961,971 **** public String toString() { return toString(true); } /** ! * @param verbose toggle output format * @return String containing all instructions in this list. */ public String toString(final boolean verbose) { final StringBuilder buf = new StringBuilder(); for (InstructionHandle ih = start; ih != null; ih = ih.getNext()) { --- 1008,1019 ---- public String toString() { return toString(true); } /** ! * @param verbose ! * toggle output format * @return String containing all instructions in this list. */ public String toString(final boolean verbose) { final StringBuilder buf = new StringBuilder(); for (InstructionHandle ih = start; ih != null; ih = ih.getNext()) {
*** 1143,1157 **** /** * Redirect all references from old_target to new_target, i.e., update * targets of branch instructions. * ! * @param old_target the old target instruction handle ! * @param new_target the new target instruction handle */ ! public void redirectBranches(final InstructionHandle old_target, ! final InstructionHandle new_target) { for (InstructionHandle ih = start; ih != null; ih = ih.getNext()) { final Instruction i = ih.getInstruction(); if (i instanceof BranchInstruction) { final BranchInstruction b = (BranchInstruction) i; final InstructionHandle target = b.getTarget(); --- 1191,1206 ---- /** * Redirect all references from old_target to new_target, i.e., update * targets of branch instructions. * ! * @param old_target ! * the old target instruction handle ! * @param new_target ! * the new target instruction handle */ ! public void redirectBranches(final InstructionHandle old_target, final InstructionHandle new_target) { for (InstructionHandle ih = start; ih != null; ih = ih.getNext()) { final Instruction i = ih.getInstruction(); if (i instanceof BranchInstruction) { final BranchInstruction b = (BranchInstruction) i; final InstructionHandle target = b.getTarget();
*** 1171,1187 **** } /** * Redirect all references of local variables from old_target to new_target. * ! * @param lg array of local variables ! * @param old_target the old target instruction handle ! * @param new_target the new target instruction handle * @see MethodGen */ ! public void redirectLocalVariables(final LocalVariableGen[] lg, ! final InstructionHandle old_target, final InstructionHandle new_target) { for (final LocalVariableGen element : lg) { final InstructionHandle start = element.getStart(); final InstructionHandle end = element.getEnd(); if (start == old_target) { element.setStart(new_target); --- 1220,1238 ---- } /** * Redirect all references of local variables from old_target to new_target. * ! * @param lg ! * array of local variables ! * @param old_target ! * the old target instruction handle ! * @param new_target ! * the new target instruction handle * @see MethodGen */ ! public void redirectLocalVariables(final LocalVariableGen[] lg, final InstructionHandle old_target, final InstructionHandle new_target) { for (final LocalVariableGen element : lg) { final InstructionHandle start = element.getStart(); final InstructionHandle end = element.getEnd(); if (start == old_target) { element.setStart(new_target);
*** 1191,1206 **** } } } /** ! * Redirect all references of exception handlers from old_target to ! * new_target. * ! * @param exceptions array of exception handlers ! * @param old_target the old target instruction handle ! * @param new_target the new target instruction handle * @see MethodGen */ public void redirectExceptionHandlers(final CodeExceptionGen[] exceptions, final InstructionHandle old_target, final InstructionHandle new_target) { for (final CodeExceptionGen exception : exceptions) { --- 1242,1259 ---- } } } /** ! * Redirect all references of exception handlers from old_target to new_target. * ! * @param exceptions ! * array of exception handlers ! * @param old_target ! * the old target instruction handle ! * @param new_target ! * the new target instruction handle * @see MethodGen */ public void redirectExceptionHandlers(final CodeExceptionGen[] exceptions, final InstructionHandle old_target, final InstructionHandle new_target) { for (final CodeExceptionGen exception : exceptions) {
< prev index next >