lvm_class/member/
method.rs1use crate::attribute::method::MethodAttribute;
2use crate::constant_pool::ConstantPool;
3use crate::error::ClassFormatErr;
4use crate::flags::MethodFlags;
5use lvm_common::utils::cursor::ByteCursor;
6
7#[derive(Debug, Clone)]
11pub struct MethodInfo {
12 pub access_flags: MethodFlags,
13 pub name_index: u16,
14 pub descriptor_index: u16,
15 pub attributes: Vec<MethodAttribute>,
16}
17
18impl<'a> MethodInfo {
19 pub(crate) fn read(
20 constant_pool: &ConstantPool,
21 cursor: &mut ByteCursor<'a>,
22 ) -> Result<Self, ClassFormatErr> {
23 let access_flags = MethodFlags::new(cursor.u16()?);
24 let name_index = cursor.u16()?;
25 let descriptor_index = cursor.u16()?;
26 let attribute_count = cursor.u16()?;
27 let mut attributes = Vec::with_capacity(attribute_count as usize);
28 for _ in 0..attribute_count {
29 attributes.push(MethodAttribute::read(constant_pool, cursor)?);
30 }
31 Ok(Self {
32 access_flags,
33 name_index,
34 descriptor_index,
35 attributes,
36 })
37 }
38}