public static MemberInfo ReadMemberInfo(ClassReader reader, ConstantPool pool) { var member = new MemberInfo() { AccessFlags = reader.ReadU2(), NameIndex = reader.ReadU2(), DescriptorIndex = reader.ReadU2(), Attributes = reader.ReadAttributes(pool) }; member.Name = pool.GetUtf8String(member.NameIndex); member.Descriptor = pool.GetUtf8String(member.DescriptorIndex); return(member); }
public static IAttribute ReadAttribute(this ClassReader reader, ConstantPool pool) { var nameIndex = reader.ReadU2(); var length = reader.ReadU4(); var name = pool.GetUtf8String(nameIndex); if (!Enum.TryParse <AttributeType>(name, true, out var type)) { type = AttributeType.Unparsed; } switch (type) { case AttributeType.Deprecated: return(new DeprecatedAttribute()); case AttributeType.Synthetic: return(new SyntheticAttribute()); case AttributeType.SourceFile: var fileNameIndex = reader.ReadU2(); return(new SourceFileAttribute(pool.GetUtf8String(fileNameIndex))); case AttributeType.ConstantValue: var constantIndex = reader.ReadU2(); return(new ConstantValueAttribute(pool.GetConstant(constantIndex))); case AttributeType.Code: ushort stack = reader.ReadU2(), locals = reader.ReadU2(); var codelength = reader.ReadU4(); var code = reader.ReadBytes((int)codelength); return(new CodeAttribute(stack, locals, code, ReadExceptionTables(reader), ReadAttributes(reader, pool))); case AttributeType.Exceptions: return(new ExceptionsAttribute(reader.ReadU2S())); case AttributeType.LineNumberTable: return(new LineNumberTableAttribute(ReadLineNumberTableEntrys(reader))); case AttributeType.LocalVariableTable: return(new LocalVariableTableAttribute(ReadLocalVariableTableEntrys(reader))); } return(new UnparsedAttribute(reader.ReadBytes((int)length))); }