pub struct JvmMethod {
pub name: String,
pub descriptor: String,
pub access_flags: JvmAccessFlags,
pub instructions: Vec<JvmInstruction>,
pub max_stack: u16,
pub max_locals: u16,
pub exception_handlers: Vec<JvmExceptionHandler>,
pub exceptions: Vec<String>,
pub attributes: Vec<JvmAttribute>,
}Expand description
JVM 方法信息(高层表示)
Fields§
§name: String方法名称
descriptor: String方法描述符
access_flags: JvmAccessFlags访问标志
instructions: Vec<JvmInstruction>指令列表
max_stack: u16最大栈深度
max_locals: u16最大局部变量数
exception_handlers: Vec<JvmExceptionHandler>异常处理表
exceptions: Vec<String>抛出的异常类名列表(throws 声明)
attributes: Vec<JvmAttribute>属性列表
Implementations§
Source§impl JvmMethod
impl JvmMethod
Sourcepub fn add_exception_handler(&mut self, handler: JvmExceptionHandler)
pub fn add_exception_handler(&mut self, handler: JvmExceptionHandler)
添加异常处理器
Sourcepub fn add_exception(&mut self, exception: String)
pub fn add_exception(&mut self, exception: String)
添加抛出的异常
Sourcepub fn with_access_flags(self, access_flags: JvmAccessFlags) -> Self
pub fn with_access_flags(self, access_flags: JvmAccessFlags) -> Self
设置访问标志
Sourcepub fn with_public(self) -> Self
pub fn with_public(self) -> Self
添加 public 访问修饰符
Sourcepub fn with_private(self) -> Self
pub fn with_private(self) -> Self
添加 private 访问修饰符
Sourcepub fn with_protected(self) -> Self
pub fn with_protected(self) -> Self
添加 protected 访问修饰符
Sourcepub fn with_static(self) -> Self
pub fn with_static(self) -> Self
添加 static 修饰符
Sourcepub fn with_final(self) -> Self
pub fn with_final(self) -> Self
添加 final 修饰符
Sourcepub fn with_abstract(self) -> Self
pub fn with_abstract(self) -> Self
添加 abstract 修饰符
Sourcepub fn with_max_stack(self, max_stack: u16) -> Self
pub fn with_max_stack(self, max_stack: u16) -> Self
设置最大栈深度
Sourcepub fn with_max_locals(self, max_locals: u16) -> Self
pub fn with_max_locals(self, max_locals: u16) -> Self
设置最大局部变量数
Sourcepub fn with_instruction(self, instruction: JvmInstruction) -> Self
pub fn with_instruction(self, instruction: JvmInstruction) -> Self
添加指令
Sourcepub fn with_instructions(self, instructions: Vec<JvmInstruction>) -> Self
pub fn with_instructions(self, instructions: Vec<JvmInstruction>) -> Self
添加多个指令
Sourcepub fn with_exception_handler(self, handler: JvmExceptionHandler) -> Self
pub fn with_exception_handler(self, handler: JvmExceptionHandler) -> Self
添加异常处理器
Sourcepub fn with_attribute(self, attribute: JvmAttribute) -> Self
pub fn with_attribute(self, attribute: JvmAttribute) -> Self
添加属性
Sourcepub fn with_attributes(self, attributes: Vec<JvmAttribute>) -> Self
pub fn with_attributes(self, attributes: Vec<JvmAttribute>) -> Self
添加多个属性
Sourcepub fn add_instruction(&mut self, instruction: JvmInstruction)
pub fn add_instruction(&mut self, instruction: JvmInstruction)
添加指令
Trait Implementations§
Auto Trait Implementations§
impl Freeze for JvmMethod
impl RefUnwindSafe for JvmMethod
impl Send for JvmMethod
impl Sync for JvmMethod
impl Unpin for JvmMethod
impl UnwindSafe for JvmMethod
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more