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 abstract class AbstractInstruction implements Opcodes { 22 23 private int offset; 24 private int opcode; 25 26 30 protected AbstractInstruction(int opcode) { 31 this.opcode = opcode; 32 } 33 34 38 public int getSize() { 39 return 1; 40 } 41 42 46 public int getOpcode() { 47 return opcode; 48 } 49 50 54 public void setOpcode(int opcode) { 55 this.opcode = opcode; 56 } 57 58 62 public String getOpcodeVerbose() { 63 String verbose = OpcodesUtil.getVerbose(opcode); 64 if (verbose == null) { 65 return "invalid opcode"; 66 } else { 67 return verbose; 68 } 69 } 70 71 75 public int getOffset() { 76 return offset; 77 } 78 79 83 public void setOffset(int offset) { 84 this.offset = offset; 85 } 86 87 95 public void read(ByteCodeInput in) throws IOException { 96 offset = in.getBytesRead() - 1; 98 } 99 100 105 public void write(ByteCodeOutput out) throws IOException { 106 out.writeByte(opcode); 107 } 108 109 } 110 | Popular Tags |