package sds.classfile.bytecode;

import java.io.IOException;
import sds.classfile.ClassFileStream;

/**
 * This class is for
 * <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.bipush">
 * bipush
 * </a>
 * and
 * <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.sipush">
 * sipush
 * </a>
 * @author inagaki
 */
public class PushOpcode extends OpcodeInfo {
	int value;

	/**
	 * constructor.
	 * @param opcodeType opcode type
	 * @param pc index into the code array
	 */
	public PushOpcode(MnemonicTable opcodeType, int pc) {
		super(opcodeType, pc);
	}

	@Override
	public void read(ClassFileStream data) throws IOException {
		if(this.getOpcodeType() == MnemonicTable.bipush) {
			this.value = data.readByte();
			return;
		}
		if(this.getOpcodeType() == MnemonicTable.sipush) {
			this.value = data.readShort();
		}
	}

	/**
	 * returns push value.
	 * @return push value
	 */
	public int getValue() {
		return value;
	}

	@Override
	public String toString() {
		return super.toString() + ": " + value;
	}
}
@@ -792,60 +792,18 @@
 %7D%0A%09%09
-if(this.getOpcodeType() == MnemonicTable.
+// 
 sipush
-) %7B%0A%09
+%0A
 %09%09th
@@ -831,20 +831,16 @@
 hort();%0A
-%09%09%7D%0A
 %09%7D%0A%0A%09/**

delete unnecessary if-statement.