package sds.assemble;

import sds.classfile.attributes.LineNumberTable;
import sds.classfile.bytecode.OpcodeInfo;
import sds.classfile.bytecode.Opcodes;

/**
 * This class is for instructions of a line of method.
 * @author inagaki
 */
public class LineInstructions {
	private LineNumberTable.LNTable table;
	private Opcodes opcodes;

	/**
	 * constructor.
	 * @param table line number table 
	 */
	public LineInstructions(LineNumberTable.LNTable table) {
		this.table = table;
		this.opcodes = new Opcodes();
	}

	/**
	 * adds opcode.
	 * @param opcode opcode 
	 */
	public void addOpcode(OpcodeInfo opcode) {
		opcodes.add(opcode.getPc(), opcode);
	}

	/**
	 * returns line number table.
	 * @return line number table
	 */
	public LineNumberTable.LNTable getTable() {
		return table;
	}

	/**
	 * returns opcodes of this line.
	 * @return opcodes
	 */
	public Opcodes getOpcodes() {
		return opcodes;
	}

	/**
	 * returns opcode from specified pc.
	 * @param pc index into the code array.
	 * @return opcode
	 */
	public OpcodeInfo get(int pc) {
		return opcodes.get(pc);
	}
}
@@ -1069,10 +1069,236 @@
 (pc);%0A%09%7D
+%0A%0A%09@Override%0A%09public String toString() %7B%0A%09%09StringBuilder sb = new StringBuilder();%0A%09%09for(OpcodeInfo op : opcodes.getMap().values()) %7B%0A%09%09%09sb.append(op.getPc()).append(%22:%22).append(op).append(%22%5Cn%22);%0A%09%09%7D%0A%09%09return sb.toString();%0A%09%7D
 %0A%7D

implement toString method.