1 7 8 package org.gjt.jclasslib.bytecode; 9 10 import org.gjt.jclasslib.io.ByteCodeInput; 11 import org.gjt.jclasslib.io.ByteCodeOutput; 12 13 import java.io.IOException ; 14 15 21 public class ImmediateByteInstruction extends AbstractInstruction { 22 23 24 protected boolean wide; 25 26 private int immediateByte; 27 28 33 public ImmediateByteInstruction(int opcode, boolean wide) { 34 super(opcode); 35 this.wide = wide; 36 } 37 38 44 public ImmediateByteInstruction(int opcode, boolean wide, int immediateByte) { 45 this(opcode, wide); 46 this.immediateByte = immediateByte; 47 } 48 49 public int getSize() { 50 return super.getSize() + (wide ? 2 : 1); 51 } 52 53 57 public int getImmediateByte() { 58 return immediateByte; 59 } 60 61 65 public void setImmediateByte(int immediateByte) { 66 this.immediateByte = immediateByte; 67 } 68 69 73 public boolean isWide() { 74 return wide; 75 } 76 77 81 public void setWide(boolean wide) { 82 this.wide = wide; 83 } 84 85 public void read(ByteCodeInput in) throws IOException { 86 super.read(in); 87 88 if (wide) { 89 immediateByte = in.readUnsignedShort(); 90 } else { 91 immediateByte = in.readUnsignedByte(); 92 } 93 } 94 95 public void write(ByteCodeOutput out) throws IOException { 96 super.write(out); 97 98 if (wide) { 99 out.writeShort(immediateByte); 100 } else { 101 out.writeByte(immediateByte); 102 } 103 } 104 105 } 106 | Popular Tags |