/** * Dump instruction as byte code to stream out. * @param out Output stream */ public void dump(DataOutputStream out) throws IOException { if(wide()) // Need WIDE prefix ? out.writeByte(Constants.WIDE); out.writeByte(opcode); if(length > 1) { // Otherwise ILOAD_n, instruction, e.g. if(wide()) out.writeShort(n); else out.writeByte(n); } }
/** * Dump instruction as byte code to stream out. * @param out Output stream */ @Override public void dump( final DataOutputStream out ) throws IOException { if (wide()) { out.writeByte(Const.WIDE); } out.writeByte(super.getOpcode()); if (super.getLength() > 1) { // Otherwise ILOAD_n, instruction, e.g. if (wide()) { out.writeShort(n); } else { out.writeByte(n); } } }
/** * Set the local variable index */ public void setIndex(int n) { if((n < 0) || (n > Constants.MAX_SHORT)) throw new ClassGenException("Illegal value: " + n); this.n = n; if(n >= 0 && n <= 3) { // Use more compact instruction xLOAD_n opcode = (short)(c_tag + n); length = 1; } else { opcode = canon_tag; if(wide()) // Need WIDE prefix ? length = 4; else length = 2; } }
/** * Set the local variable index. * also updates opcode and length * TODO Why? * @see #setIndexOnly(int) */ @Override public void setIndex( final int n ) { // TODO could be package-protected? if ((n < 0) || (n > Const.MAX_SHORT)) { throw new ClassGenException("Illegal value: " + n); } this.n = n; // Cannot be < 0 as this is checked above if (n <= 3) { // Use more compact instruction xLOAD_n super.setOpcode((short) (c_tag + n)); super.setLength(1); } else { super.setOpcode(canon_tag); if (wide()) { super.setLength(4); } else { super.setLength(2); } } }