/** Handle adds itself to the list of resuable handles. */ @Override protected void addHandle() { super.setNext(bh_list); bh_list = this; }
/** * 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)); } else { end.setNext(ih); ih.setPrev(end); ih.setNext(null); end = ih; } length++; // Update length }
/** * 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"); } if (il.isEmpty()) { return ih; } final InstructionHandle next = ih.getNext(); final InstructionHandle ret = il.start; ih.setNext(il.start); il.start.setPrev(ih); il.end.setNext(next); if (next != null) { next.setPrev(il.end); } else { end = il.end; // Update end ... } length += il.length; // Update length il.clear(); return ret; }
} else { first = prev.getNext(); prev.setNext(next); last.setNext(null); final List<InstructionHandle> target_vec = new ArrayList<>(); for (InstructionHandle ih = first; ih != null; ih = ih.getNext()) { target_vec.add(ih); buf.append(ih.toString(true)).append(" "); ih.setNext(ih.setPrev(null)); } else { ih.dispose();
/** * 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"); } if (il.isEmpty()) { return ih; } final InstructionHandle prev = ih.getPrev(); final InstructionHandle ret = il.start; ih.setPrev(il.end); il.end.setNext(ih); il.start.setPrev(prev); if (prev != null) { prev.setNext(il.start); } else { start = il.start; // Update start ... } length += il.length; // Update length il.clear(); return ret; }
InstructionHandle next = end.getNext(); if (prev != null) { prev.setNext(next); } else { this.start = next; this.end = prev; start.setPrev(end.setNext(null)); this.start.setPrev(end); end.setNext(this.start); this.start = start; } else { next = target.getNext(); target.setNext(start); start.setPrev(target); end.setNext(next); if (next != null) { next.setPrev(end);