/* * JavaFieldReader */ public JavaField(JavaReader rdr) { Class = rdr.Class; Flags = (JavaAccessFlags)rdr.Read16(); Name = rdr.ConstUtf8(rdr.Read16()); rdr.Where.Push($"field '{Name}'"); Type = new JavaType(rdr.ConstUtf8(rdr.Read16()), rdr.Where); var attributes = new JavaAttributeSet(rdr); if ((Flags & JavaAccessFlags.ACC_STATIC) != 0) { var constAttr = attributes.GetAttr <JavaAttribute.ConstantValue>(); if (constAttr != null) { InitConstant(constAttr.value, rdr.Where); } } rdr.Where.Pop(); }
public ushort ConstField(JavaType vClass, JavaFieldRef vField) { ushort classIndex = ConstClass(vClass); ushort nameAndTypeIndex = ConstNameAndType(vField.Name, vField.Type.ToDescriptor()); return((ushort)constants.Put( new JavaConstant.FieldRef(classIndex, nameAndTypeIndex), Where)); }
public ushort ConstClass(JavaType v) { string nameOrDescriptor; if (v.ArrayRank != 0) { nameOrDescriptor = v.ToDescriptor(); } else if (v.ClassName != null) { nameOrDescriptor = v.ClassName.Replace('.', '/'); } else { throw Where.Exception("invalid class name"); } ushort stringIndex = ConstUtf8(nameOrDescriptor); return((ushort)constants.Put(new JavaConstant.Class(stringIndex), Where)); }