package sds.classfile.attributes;

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

/**
 * This class is for
 * <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.7.11">
 * SourceDebugExtension Attribute</a>.
 * @author inagakikenichi
 */
public class SourceDebugExtension extends AttributeInfo {
	private int[] debugExtension;

	/**
	 * constructor.
	 * @param nameIndex constant-pool entry index of attribute name
	 * @param length attribute length
	 */
	public SourceDebugExtension(int nameIndex, int length) {
		super(AttributeType.SourceDebugExtension, nameIndex, length);
	}

	/**
	 * returns constant-pool entry index of debugging information.
	 * @return constant-pool entry index of debugging information
	 */
	public int[] getDebugExtension() {
		return debugExtension;
	}

	@Override
	public void read(ClassFileStream data, ConstantPool pool) throws IOException {
		this.debugExtension = new int[this.getAttrLen()];
		for(int i = 0; i < this.getAttrLen(); i++) {
			debugExtension[i] = data.readUnsignedByte();
		}
	}
}
@@ -401,16 +401,38 @@
 tension;
+%0A%09private int attrLen;
 %0A%0A%09/**%0A%09
@@ -451,73 +451,8 @@
 or.%0A
-%09 * @param nameIndex constant-pool entry index of attribute name%0A
 %09 * 
@@ -524,23 +524,8 @@
 int 
-nameIndex, int 
 leng
@@ -576,28 +576,34 @@
 sion
-, nameIndex,
+);%0A%09%09this.attrLen =
  length
-)
 ;%0A%09%7D
@@ -929,33 +929,23 @@
 new int%5B
-this.getA
+a
 ttrLen
-()
 %5D;%0A%09%09for
@@ -964,25 +964,29 @@
 i %3C 
-this.getAttrLen()
+debugExtension.length
 ; i+

delete parameter of name index.