pub struct MethodVisitor { /* private fields */ }Expand description
A visitor to visit a Java method.
Used to generate the bytecode instructions, exception tables, and attributes for a specific method.
Implementations§
Source§impl MethodVisitor
impl MethodVisitor
pub fn new(access_flags: u16, name: &str, descriptor: &str) -> Self
Sourcepub fn visit_code(&mut self) -> &mut Self
pub fn visit_code(&mut self) -> &mut Self
Starts the visit of the method’s code.
Sourcepub fn visit_insn(&mut self, opcode: u8) -> &mut Self
pub fn visit_insn(&mut self, opcode: u8) -> &mut Self
Visits a zero-operand instruction (e.g., NOP, RETURN).
Sourcepub fn visit_var_insn(&mut self, opcode: u8, var_index: u16) -> &mut Self
pub fn visit_var_insn(&mut self, opcode: u8, var_index: u16) -> &mut Self
Visits a local variable instruction (e.g., ILOAD, ASTORE).
Sourcepub fn visit_field_insn(
&mut self,
opcode: u8,
owner: &str,
name: &str,
descriptor: &str,
) -> &mut Self
pub fn visit_field_insn( &mut self, opcode: u8, owner: &str, name: &str, descriptor: &str, ) -> &mut Self
Visits a field instruction (e.g., GETFIELD, PUTSTATIC).
Sourcepub fn visit_method_insn(
&mut self,
opcode: u8,
owner: &str,
name: &str,
descriptor: &str,
_is_interface: bool,
) -> &mut Self
pub fn visit_method_insn( &mut self, opcode: u8, owner: &str, name: &str, descriptor: &str, _is_interface: bool, ) -> &mut Self
Visits a method instruction (e.g., INVOKEVIRTUAL).
pub fn visit_jump_insn(&mut self, opcode: u8, target: Label) -> &mut Self
pub fn visit_label(&mut self, label: Label) -> &mut Self
pub fn visit_line_number(&mut self, line: u16, start: LabelNode) -> &mut Self
Sourcepub fn visit_ldc_insn(&mut self, value: LdcInsnNode) -> &mut Self
pub fn visit_ldc_insn(&mut self, value: LdcInsnNode) -> &mut Self
Visits a constant instruction (LDC).
Sourcepub fn visit_maxs(&mut self, max_stack: u16, max_locals: u16) -> &mut Self
pub fn visit_maxs(&mut self, max_stack: u16, max_locals: u16) -> &mut Self
Visits the maximum stack size and number of local variables.
If COMPUTE_MAXS or COMPUTE_FRAMES was passed to the ClassWriter,
these values may be ignored or recomputed.
Sourcepub fn visit_end(self, class: &mut ClassWriter)
pub fn visit_end(self, class: &mut ClassWriter)
Finalizes the method and attaches it to the parent ClassWriter.
Auto Trait Implementations§
impl Freeze for MethodVisitor
impl RefUnwindSafe for MethodVisitor
impl Send for MethodVisitor
impl Sync for MethodVisitor
impl Unpin for MethodVisitor
impl UnsafeUnpin for MethodVisitor
impl UnwindSafe for MethodVisitor
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