/** * Creates a new {@link Label}. * * @return a new {@link Label}. */ public Label newLabel() { return new Label(); }
public void visitTableSwitchInsn( final int min, final int max, final Label dflt, final Label labels[]) { // adds the instruction to the bytecode of the method int source = code.length; code.putByte(Opcodes.TABLESWITCH); code.length += (4 - code.length % 4) % 4; dflt.put(this, code, source, true); code.putInt(min).putInt(max); for (int i = 0; i < labels.length; ++i) { labels[i].put(this, code, source, true); } // updates currentBlock visitSwitchInsn(dflt, labels); }
/** * Ends the current basic ast. This method must be used in the case where * the current basic ast does not have any successor. */ private void noSuccessor() { if (compute == FRAMES) { Label l = new Label(); l.frame = new Frame(); l.frame.owner = l; l.resolve(this, code.length, code.data); previousBlock.successor = l; previousBlock = l; } else { currentBlock.outputStackMax = maxStackSize; } currentBlock = null; }
Label l = handler.start.getFirst(); Label h = handler.handler.getFirst(); Label e = handler.end.getFirst(); Label n = e.successor.getFirst(); boolean change = f.merge(cw, n.frame, e.info); if (change && n.next == null) { labels.visitSubroutine(null, 1, subroutines); subroutine.visitSubroutine(null, (id / 32L) << 32 | (1L << (id % 32)), subroutines); subroutine.visitSubroutine(l, 0, subroutines);
label.put(code, code.length - 1, true); } else if (baseOpcode != opcode) { label.put(code, code.length - 1, true); } else { label.put(code, code.length - 1, false); currentBasicBlock.frame.execute(baseOpcode, 0, null, null); label.getCanonicalInstance().flags |= Label.FLAG_JUMP_TARGET; nextBasicBlock = new Label(); nextBasicBlock = new Label(); } else {
public void visitLabel(final Label label) { resize |= label.resolve(this, code.length, code.data);
private void visitSwitchInsn(final Label dflt, final Label[] labels) { // Label currentBlock = this.currentBlock; if (currentBlock != null) { if (compute == FRAMES) { currentBlock.frame.execute(Opcodes.LOOKUPSWITCH, 0, null, null); // adds current block successors addSuccessor(Edge.NORMAL, dflt); dflt.getFirst().status |= Label.TARGET; for (int i = 0; i < labels.length; ++i) { addSuccessor(Edge.NORMAL, labels[i]); labels[i].getFirst().status |= Label.TARGET; } } else { // updates current stack size (max stack size unchanged) --stackSize; // adds current block successors addSuccessor(stackSize, dflt); for (int i = 0; i < labels.length; ++i) { addSuccessor(stackSize, labels[i]); } } // ends current block noSuccessor(); } }
addReference(-1 - source, out.length); out.putInt(-1); addReference(source, out.length); out.putShort(-1);
currentLineNumberTableOffset += 4; createDebugLabel(startPc, labels); labels[startPc].addLineNumber(lineNumber); currentLabel.accept(methodVisitor, (context.parsingOptions & SKIP_DEBUG) == 0);
/** * Puts a reference to this label in the bytecode of a method. If the bytecode offset of the label * is known, the relative bytecode offset between the label and the instruction referencing it is * computed and written directly. Otherwise, a null relative offset is written and a new forward * reference is declared for this label. * * @param code the bytecode of the method. This is where the reference is appended. * @param sourceInsnBytecodeOffset the bytecode offset of the instruction that contains the * reference to be appended. * @param wideReference whether the reference must be stored in 4 bytes (instead of 2 bytes). */ final void put( final ByteVector code, final int sourceInsnBytecodeOffset, final boolean wideReference) { if ((flags & FLAG_RESOLVED) == 0) { if (wideReference) { addForwardReference(sourceInsnBytecodeOffset, FORWARD_REFERENCE_TYPE_WIDE, code.length); code.putInt(-1); } else { addForwardReference(sourceInsnBytecodeOffset, FORWARD_REFERENCE_TYPE_SHORT, code.length); code.putShort(-1); } } else { if (wideReference) { code.putInt(bytecodeOffset - sourceInsnBytecodeOffset); } else { code.putShort(bytecodeOffset - sourceInsnBytecodeOffset); } } }
currentBlock.frame.execute(opcode, 0, null, null); label.getFirst().status |= Label.TARGET; nextInsn = new Label(); addSuccessor(stackSize + 1, label); nextInsn = new Label(); cw.hasAsmInsns = true; label.put(this, code, code.length - 1, true); } else if (isWide) { label.put(this, code, code.length - 1, true); } else { label.put(this, code, code.length - 1, false);
@Override public void visitLabel(final Label label) { hasAsmInstructions |= label.resolve(code.data, code.length);
private void visitSwitchInsn(final Label dflt, final Label[] labels) { // Label currentBlock = this.currentBlock; if (currentBlock != null) { if (compute == FRAMES) { currentBlock.frame.execute(Opcodes.LOOKUPSWITCH, 0, null, null); // adds current ast successors addSuccessor(Edge.NORMAL, dflt); dflt.getFirst().status |= Label.TARGET; for (int i = 0; i < labels.length; ++i) { addSuccessor(Edge.NORMAL, labels[i]); labels[i].getFirst().status |= Label.TARGET; } } else { // updates current stack size (max stack size unchanged) --stackSize; // adds current ast successors addSuccessor(stackSize, dflt); for (int i = 0; i < labels.length; ++i) { addSuccessor(stackSize, labels[i]); } } // ends current ast noSuccessor(); } }
if ((status & RESOLVED) == 0) { if (wideOffset) { addReference(-1 - source, out.length); out.putInt(-1); } else { addReference(source, out.length); out.putShort(-1);
public Label getLabel() { if (label == null) { label = new Label(); } return label; }
/** * Ends the current basic block. This method must be used in the case where * the current basic block does not have any successor. */ private void noSuccessor() { if (compute == FRAMES) { Label l = new Label(); l.frame = new Frame(); l.frame.owner = l; l.resolve(this, code.length, code.data); previousBlock.successor = l; previousBlock = l; } else { currentBlock.outputStackMax = maxStackSize; } if (compute != INSERTED_FRAMES) { currentBlock = null; } }
public void visitLookupSwitchInsn( final Label dflt, final int keys[], final Label labels[]) { // adds the instruction to the bytecode of the method int source = code.length; code.putByte(Opcodes.LOOKUPSWITCH); code.length += (4 - code.length % 4) % 4; dflt.put(this, code, source, true); code.putInt(labels.length); for (int i = 0; i < labels.length; ++i) { code.putInt(keys[i]); labels[i].put(this, code, source, true); } // updates currentBlock visitSwitchInsn(dflt, labels); }
@Override public void visitLabel(final Label label) { cw.hasAsmInsns |= label.resolve(this, code.length, code.data);