package sds.assemble;

import sds.classfile.ConstantPool;
import sds.classfile.MemberInfo;
import sds.classfile.attributes.AttributeInfo;
import sds.classfile.attributes.AttributeType;
import sds.classfile.attributes.ConstantValue;

import static sds.util.Utf8ValueExtractor.extract;

/**
 * This class is for contents of field.
 * @author inagaki
 */
public class FieldContent extends MemberContent {
	private String constVal;

	/**
	 * constructor.
	 * @param info field info
	 * @param pool constant-pool
	 */
	public FieldContent(MemberInfo info, ConstantPool pool) {
		super(info, pool);
		for(AttributeInfo attr : info.getAttr().getAll()) {
			investigateAttribute(attr, pool);
		}
	}

	@Override
	public void investigateAttribute(AttributeInfo info, ConstantPool pool) {
		if(info.getType() == AttributeType.ConstantValue) {
			ConstantValue cv = (ConstantValue)info;
			this.constVal = extract(pool.get(cv.getConstantValueIndex()-1), pool);
		} else {
			super.investigateAttribute(info, pool);
		}
	}

	/**
	 * returns constant value of field.<br>
	 * when field type is primitive or String and field access flag doesn't contain final
	 * , this method returns null.
	 * @return constant value
	 */
	public String getConstVal() {
		return constVal;
	}
}
@@ -163,28 +163,28 @@
 ributes.
-AttributeTyp
+ConstantValu
 e;%0Aimpor
@@ -214,24 +214,67 @@
 tes.
-ConstantValu
+Signature;%0A%0Aimport static sds.util.DescriptorParser.pars
 e;%0A
-%0A
 impo
@@ -820,10 +820,14 @@
 %7B%0A%09%09
-if
+switch
 (inf
@@ -841,26 +841,20 @@
 pe()
- == AttributeType.
+) %7B%0A%09%09%09case 
 Cons
@@ -862,20 +862,19 @@
 antValue
-) %7B%0A
+:%0A%09
 %09%09%09Const
@@ -908,16 +908,17 @@
 e)info;%0A
+%09
 %09%09%09this.
@@ -989,17 +989,172 @@
 ;%0A%09%09
-%7D else %7B%0A
+%09%09break;%0A%09%09%09case Signature:%0A%09%09%09%09Signature sig = (Signature)info;%0A%09%09%09%09this.desc = parse(extract(pool.get(sig.getSignatureIndex()-1), pool));%0A%09%09%09%09break;%0A%09%09%09default:%0A%09
 %09%09%09s
@@ -1184,32 +1184,43 @@
 te(info, pool);%0A
+%09%09%09%09break;%0A
 %09%09%7D%0A%09%7D%0A%0A%09/**%0A%09 *

fix #28.